From f604d490d97e3b580029bd4cfade324174555dc2 Mon Sep 17 00:00:00 2001
From: Petr OspalĂ˝
Date: Mon, 4 Mar 2019 06:56:33 +0100
Subject: Add default logging settings for docker
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- Default configuration of logging for docker daemon.
- New ansible module for generic handling of JSON files.
- New setting in ansible.cfg: jinja2_native = True
To preserve double-quotes in json values (OOM-1698).
Issue-ID: OOM-1681
Change-Id: I8f8e19ebc290fd48a63146e96f418b98344e4433
Signed-off-by: Petr OspalĂ˝
---
ansible/library/json_add.py | 90 ---------------------------------------------
1 file changed, 90 deletions(-)
delete mode 100644 ansible/library/json_add.py
(limited to 'ansible/library/json_add.py')
diff --git a/ansible/library/json_add.py b/ansible/library/json_add.py
deleted file mode 100644
index 6aad2d7c..00000000
--- a/ansible/library/json_add.py
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/usr/bin/python
-
-from ansible.module_utils.basic import AnsibleModule
-import json
-import os
-
-DOCUMENTATION="""
----
-module: json_add
-descritption:
- - This module will search top level objects in json and adds specified
- value into list for specified key.
- - If file does not exists module will create it automatically.
-
-options:
- path:
- required: true
- aliases=[name, destfile, dest]
- description:
- - The json file to modify.
- key:
- required: true
- description:
- - Top level object.
- value:
- required: true
- description:
- - Value to add to specified key.
-"""
-
-def load_json(path):
- if os.path.exists(path):
- with open(path, 'r') as f:
- return json.load(f)
- else:
- return {}
-
-def value_is_set(path, key, value, json_obj):
- return value in json_obj.get(key, [])
-
-def insert_to_json(path, key, value, check_mode=False):
- json_obj = load_json(path)
- if not value_is_set(path, key, value, json_obj):
- if not check_mode:
- json_obj.setdefault(key, []).append(value)
- store_json(path, json_obj)
- return True, 'Value %s added to %s.' % (value, key)
- else:
- return False, ''
-
-def store_json(path, json_obj):
- with open(path, 'w') as f:
- json.dump(json_obj, f, indent=4)
-
-def check_file_attrs(module, changed, message, diff):
- file_args = module.load_file_common_arguments(module.params)
- if module.set_fs_attributes_if_different(file_args, False, diff=diff):
-
- if changed:
- message += ' '
- changed = True
- message += 'File attributes changed.'
-
- return changed, message
-
-def run_module():
- module = AnsibleModule(
- argument_spec=dict(
- path=dict(type='path', required=True, aliases=['name', 'destfile', 'dest']),
- key=dict(type='str', required=True),
- value=dict(type='str', required=True),
- ),
- add_file_common_args=True,
- supports_check_mode=True
- )
- params = module.params
- path = params['path']
- key = params['key']
- value = params['value']
- try:
- changed, msg = insert_to_json(path, key, value, module.check_mode)
- fs_diff = {}
- changed, msg = check_file_attrs(module, changed, msg, fs_diff)
- module.exit_json(changed=changed, msg=msg, file_attr_diff=fs_diff)
- except IOError as e:
- module.fail_json(msg=e.msg)
-
-if __name__ == '__main__':
- run_module()
-
--
cgit 1.2.3-korg