update-json-file: add role to combine values into a .json

Ansible doens't really have a great built-in way to modify a json file
(unlike ini files).  The extant docker role does what seems to be the
usual standard, which is slurp in the file, parse it and then write it
back out.

In a follow-on change (I338616c41a65b007d56648fdab6da2a6a6b909f4) we
need to set some more values in the docker configuration .json file,
which made me think it's generic enough that we can have a role to
basically run read the file, |combine and write it back out.

This adds such a role with various options, and converts the existing
json configuration update in ensure-docker to use it.

Change-Id: I155a409945e0175249cf2dc630b839c7a97fb452
This commit is contained in:
Ian Wienand
2020-08-19 15:26:58 +10:00
parent a086fb4333
commit 0b9fad9583
7 changed files with 146 additions and 26 deletions

View File

@@ -642,6 +642,14 @@
- name: fedora-32
label: fedora-32
- job:
name: zuul-jobs-test-update-json-file
description: Test the json edit role
run: test-playbooks/update-json-file.yaml
files:
- test-playbooks/update-json-file.yaml
- roles/update-json-file/.*
# -* AUTOGENERATED *-
# The following project section is autogenerated by
# tox -e update-test-platforms
@@ -692,6 +700,7 @@
- zuul-jobs-test-upload-git-mirror
- zuul-jobs-test-shake-build
- zuul-jobs-test-ensure-zookeeper
- zuul-jobs-test-update-json-file
gate:
jobs: &id001
- zuul-jobs-test-add-authorized-keys
@@ -732,5 +741,6 @@
- zuul-jobs-test-upload-git-mirror
- zuul-jobs-test-shake-build
- zuul-jobs-test-ensure-zookeeper
- zuul-jobs-test-update-json-file
periodic-weekly:
jobs: *id001