From 8ee47ae3a29e8f2a5d227701dac9f7597a26a97d Mon Sep 17 00:00:00 2001 From: caoyuan Date: Mon, 22 Oct 2018 22:37:11 +0800 Subject: [PATCH] Merge the merge_yaml and merge_config module into one move the merge_yaml and merge_config module's DOCUMENTATION and EXAMPLES into action_plugins. Change-Id: I84c5b94afb870fc9a25838782389f7b1f8b882fd Closes-Bug: #1799236 --- ansible/action_plugins/merge_configs.py | 35 +++++++++++++++++ ansible/action_plugins/merge_yaml.py | 35 +++++++++++++++++ ansible/library/merge_configs.py | 51 ------------------------- ansible/library/merge_yaml.py | 51 ------------------------- 4 files changed, 70 insertions(+), 102 deletions(-) delete mode 100644 ansible/library/merge_configs.py delete mode 100644 ansible/library/merge_yaml.py diff --git a/ansible/action_plugins/merge_configs.py b/ansible/action_plugins/merge_configs.py index 4377dd8c1a..bc5df494eb 100644 --- a/ansible/action_plugins/merge_configs.py +++ b/ansible/action_plugins/merge_configs.py @@ -15,6 +15,41 @@ # See the License for the specific language governing permissions and # limitations under the License. +DOCUMENTATION = ''' +--- +module: merge_configs +short_description: Merge ini-style configs +description: + - ConfigParser is used to merge several ini-style configs into one +options: + dest: + description: + - The destination file name + required: True + type: str + sources: + description: + - A list of files on the destination node to merge together + default: None + required: True + type: str +author: Sam Yaple +''' + +EXAMPLES = ''' +Merge multiple configs: + +- hosts: database + tasks: + - name: Merge configs + merge_configs: + sources: + - "/tmp/config_1.cnf" + - "/tmp/config_2.cnf" + - "/tmp/config_3.cnf" + dest: + - "/etc/mysql/my.cnf" +''' import collections import inspect diff --git a/ansible/action_plugins/merge_yaml.py b/ansible/action_plugins/merge_yaml.py index 371905d0d4..98648b6e02 100755 --- a/ansible/action_plugins/merge_yaml.py +++ b/ansible/action_plugins/merge_yaml.py @@ -15,6 +15,41 @@ # See the License for the specific language governing permissions and # limitations under the License. +DOCUMENTATION = ''' +--- +module: merge_yaml +short_description: Merge yaml-style configs +description: + - PyYAML is used to merge several yaml files into one +options: + dest: + description: + - The destination file name + required: True + type: str + sources: + description: + - A list of files on the destination node to merge together + default: None + required: True + type: str +author: Sean Mooney +''' + +EXAMPLES = ''' +Merge multiple yaml files: + +- hosts: localhost + tasks: + - name: Merge yaml files + merge_yaml: + sources: + - "/tmp/default.yml" + - "/tmp/override.yml" + dest: + - "/tmp/out.yml" +''' + import inspect import os import shutil diff --git a/ansible/library/merge_configs.py b/ansible/library/merge_configs.py deleted file mode 100644 index 1a73e31018..0000000000 --- a/ansible/library/merge_configs.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env python - -# Copyright 2015 Sam Yaple -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -DOCUMENTATION = ''' ---- -module: merge_configs -short_description: Merge ini-style configs -description: - - ConfigParser is used to merge several ini-style configs into one -options: - dest: - description: - - The destination file name - required: True - type: str - sources: - description: - - A list of files on the destination node to merge together - default: None - required: True - type: str -author: Sam Yaple -''' - -EXAMPLES = ''' -Merge multiple configs: - -- hosts: database - tasks: - - name: Merge configs - merge_configs: - sources: - - "/tmp/config_1.cnf" - - "/tmp/config_2.cnf" - - "/tmp/config_3.cnf" - dest: - - "/etc/mysql/my.cnf" -''' diff --git a/ansible/library/merge_yaml.py b/ansible/library/merge_yaml.py deleted file mode 100644 index 4d54b437d1..0000000000 --- a/ansible/library/merge_yaml.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env python - -# Copyright 2015 Sam Yaple -# Copyright 2016 intel -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -DOCUMENTATION = ''' ---- -module: merge_yaml -short_description: Merge yaml-style configs -description: - - PyYAML is used to merge several yaml files into one -options: - dest: - description: - - The destination file name - required: True - type: str - sources: - description: - - A list of files on the destination node to merge together - default: None - required: True - type: str -author: Sean Mooney -''' - -EXAMPLES = ''' -Merge multiple yaml files: - -- hosts: localhost - tasks: - - name: Merge yaml files - merge_yaml: - sources: - - "/tmp/default.yml" - - "/tmp/override.yml" - dest: - - "/tmp/out.yml" -'''