Browse Source

jsonconfig playbook fix

pull/1943/head
Greg Szabo 7 years ago
parent
commit
b818d98875
2 changed files with 5 additions and 6 deletions
  1. +0
    -1
      ansible/getfile.yml
  2. +5
    -5
      ansible/roles/jsonconfig/library/jsonconfig.py

+ 0
- 1
ansible/getfile.yml View File

@ -1,6 +1,5 @@
--- ---
#variable "service" is required
#variable "source" is required #variable "source" is required
- hosts: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}:tag_Environment_{{ lookup('env','TF_VAR_TESTNET_NAME') | regex_replace('-','_') }}" - hosts: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}:tag_Environment_{{ lookup('env','TF_VAR_TESTNET_NAME') | regex_replace('-','_') }}"


+ 5
- 5
ansible/roles/jsonconfig/library/jsonconfig.py View File

@ -181,7 +181,7 @@ def deepdiff(d1, d2):
return None return None
def present(module, dest, conf, jsonbool, merge, create, backup):
def present(module, dest, conf, merge, create, backup):
diff = {'before': '', diff = {'before': '',
'after': '', 'after': '',
@ -226,7 +226,7 @@ def present(module, dest, conf, jsonbool, merge, create, backup):
else: else:
mergedconfig = deepmerge(jsonconfig,config) mergedconfig = deepmerge(jsonconfig,config)
if jsonconfig != mergedconfig: if jsonconfig != mergedconfig:
b_lines_new = to_bytes(json.dumps(mergedconfig), sort_keys=True, indent=4, separators=(',', ': ')))
b_lines_new = to_bytes(json.dumps(mergedconfig, sort_keys=True, indent=4, separators=(',', ': ')))
msg = 'config merged' msg = 'config merged'
changed = True changed = True
@ -252,7 +252,7 @@ def present(module, dest, conf, jsonbool, merge, create, backup):
module.exit_json(changed=changed, msg=msg, backup=backupdest, diff=difflist) module.exit_json(changed=changed, msg=msg, backup=backupdest, diff=difflist)
def absent(module, dest, conf, jsonbool, backup):
def absent(module, dest, conf, backup):
b_dest = to_bytes(dest, errors='surrogate_or_strict') b_dest = to_bytes(dest, errors='surrogate_or_strict')
if not os.path.exists(b_dest): if not os.path.exists(b_dest):
@ -351,9 +351,9 @@ def main():
conf = params['json'] conf = params['json']
if params['state'] == 'present': if params['state'] == 'present':
present(module, dest, conf, jsonbool, merge, create, backup)
present(module, dest, conf, merge, create, backup)
else: else:
absent(module, dest, conf, jsonbool, backup)
absent(module, dest, conf, backup)
if __name__ == '__main__': if __name__ == '__main__':
main() main()


Loading…
Cancel
Save