From 7dd8e35e8c8a231fd0b27cb3c36279694ac1a441 Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Wed, 18 Sep 2019 08:43:36 -0400 Subject: [PATCH] Use namespaced doc fragment, cleanup doc fragment will now be at awx.awx.auth changed from just tower, which source from core remove Makefile things no longer needed --- Makefile | 4 -- awx_collection/README.md | 4 +- awx_collection/plugins/doc_fragments/auth.py | 46 +++++++++++++++++++ .../plugins/modules/tower_credential.py | 2 +- .../plugins/modules/tower_credential_type.py | 2 +- awx_collection/plugins/modules/tower_group.py | 2 +- awx_collection/plugins/modules/tower_host.py | 2 +- .../plugins/modules/tower_inventory.py | 2 +- .../plugins/modules/tower_inventory_source.py | 2 +- .../plugins/modules/tower_job_cancel.py | 2 +- .../plugins/modules/tower_job_launch.py | 2 +- .../plugins/modules/tower_job_list.py | 2 +- .../plugins/modules/tower_job_template.py | 2 +- .../plugins/modules/tower_job_wait.py | 2 +- awx_collection/plugins/modules/tower_label.py | 2 +- .../plugins/modules/tower_notification.py | 2 +- .../plugins/modules/tower_organization.py | 2 +- .../plugins/modules/tower_project.py | 2 +- .../plugins/modules/tower_receive.py | 2 +- awx_collection/plugins/modules/tower_role.py | 2 +- awx_collection/plugins/modules/tower_send.py | 2 +- .../plugins/modules/tower_settings.py | 2 +- awx_collection/plugins/modules/tower_team.py | 2 +- awx_collection/plugins/modules/tower_user.py | 2 +- .../plugins/modules/tower_workflow_launch.py | 2 +- .../modules/tower_workflow_template.py | 2 +- awx_collection/template_galaxy.yml | 17 +++++++ 27 files changed, 88 insertions(+), 29 deletions(-) create mode 100644 awx_collection/plugins/doc_fragments/auth.py diff --git a/Makefile b/Makefile index db38368173..c0ada60b61 100644 --- a/Makefile +++ b/Makefile @@ -374,11 +374,9 @@ test: fi; \ PYTHONDONTWRITEBYTECODE=1 py.test -p no:cacheprovider -n auto $(TEST_DIRS) cd awxkit && $(VENV_BASE)/awx/bin/tox -re py2,py3 - make test_collection_all awx-manage check_migrations --dry-run --check -n 'vNNN_missing_migration_file' prepare_collection_venv: - cd /awx_devel rm -rf $(COLLECTION_VENV) mkdir $(COLLECTION_VENV) ln -s /usr/lib/python2.7/site-packages/ansible $(COLLECTION_VENV)/ansible @@ -397,8 +395,6 @@ test_collection: flake8_collection: flake8 awx_collection/ # Different settings, in main exclude list -prepare_test_collection: prepare_collection_venv test_collection # deprecated - test_collection_all: prepare_collection_venv test_collection flake8_collection build_collection: diff --git a/awx_collection/README.md b/awx_collection/README.md index eaa1b29980..fe65d0d013 100644 --- a/awx_collection/README.md +++ b/awx_collection/README.md @@ -1,11 +1,11 @@ # AWX Ansible Collection -This Ansible collection allow for easy interaction with an AWX or Ansible Tower +This Ansible collection allows for easy interaction with an AWX or Ansible Tower server in Ansible playbooks. The previous home for this collection was in https://github.com/ansible/ansible inside the folder `lib/ansible/modules/web_infrastructure/ansible_tower` -as well as other places for the inventory plugin, module utils, and +as well as other folders for the inventory plugin, module utils, and doc fragment. ## Running diff --git a/awx_collection/plugins/doc_fragments/auth.py b/awx_collection/plugins/doc_fragments/auth.py new file mode 100644 index 0000000000..5583710201 --- /dev/null +++ b/awx_collection/plugins/doc_fragments/auth.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- + +# Copyright: (c) 2017, Wayne Witzel III +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + + +class ModuleDocFragment(object): + + # Ansible Tower documentation fragment + DOCUMENTATION = r''' +options: + tower_host: + description: + - URL to your Tower or AWX instance. + type: str + tower_username: + description: + - Username for your Tower or AWX instance. + type: str + tower_password: + description: + - Password for your Tower or AWX instance. + type: str + validate_certs: + description: + - Whether to allow insecure connections to Tower or AWX. + - If C(no), SSL certificates will not be validated. + - This should only be used on personally controlled sites using self-signed certificates. + type: bool + aliases: [ tower_verify_ssl ] + tower_config_file: + description: + - Path to the Tower or AWX config file. + type: path + +requirements: +- ansible-tower-cli >= 3.0.2 + +notes: +- If no I(config_file) is provided we will attempt to use the tower-cli library + defaults to find your Tower host information. +- I(config_file) should contain Tower configuration in the following format + host=hostname + username=username + password=password +''' diff --git a/awx_collection/plugins/modules/tower_credential.py b/awx_collection/plugins/modules/tower_credential.py index aac3d9406a..7ac08b28d6 100644 --- a/awx_collection/plugins/modules/tower_credential.py +++ b/awx_collection/plugins/modules/tower_credential.py @@ -145,7 +145,7 @@ options: choices: ["present", "absent"] default: "present" type: str -extends_documentation_fragment: tower +extends_documentation_fragment: awx.awx.auth ''' diff --git a/awx_collection/plugins/modules/tower_credential_type.py b/awx_collection/plugins/modules/tower_credential_type.py index d8b97ccc08..0fd6ebd046 100644 --- a/awx_collection/plugins/modules/tower_credential_type.py +++ b/awx_collection/plugins/modules/tower_credential_type.py @@ -64,7 +64,7 @@ options: required: False type: bool aliases: [ tower_verify_ssl ] -extends_documentation_fragment: tower +extends_documentation_fragment: awx.awx.auth ''' diff --git a/awx_collection/plugins/modules/tower_group.py b/awx_collection/plugins/modules/tower_group.py index 8df1a73221..7fe717666a 100644 --- a/awx_collection/plugins/modules/tower_group.py +++ b/awx_collection/plugins/modules/tower_group.py @@ -77,7 +77,7 @@ options: - Desired state of the resource. default: "present" choices: ["present", "absent"] -extends_documentation_fragment: tower +extends_documentation_fragment: awx.awx.auth ''' diff --git a/awx_collection/plugins/modules/tower_host.py b/awx_collection/plugins/modules/tower_host.py index c6011ab27b..02946cf4d7 100644 --- a/awx_collection/plugins/modules/tower_host.py +++ b/awx_collection/plugins/modules/tower_host.py @@ -47,7 +47,7 @@ options: - Desired state of the resource. choices: ["present", "absent"] default: "present" -extends_documentation_fragment: tower +extends_documentation_fragment: awx.awx.auth ''' diff --git a/awx_collection/plugins/modules/tower_inventory.py b/awx_collection/plugins/modules/tower_inventory.py index 20eaa19b0f..811430a723 100644 --- a/awx_collection/plugins/modules/tower_inventory.py +++ b/awx_collection/plugins/modules/tower_inventory.py @@ -52,7 +52,7 @@ options: - Desired state of the resource. default: "present" choices: ["present", "absent"] -extends_documentation_fragment: tower +extends_documentation_fragment: awx.awx.auth ''' diff --git a/awx_collection/plugins/modules/tower_inventory_source.py b/awx_collection/plugins/modules/tower_inventory_source.py index 063eeeea81..ede0896d64 100644 --- a/awx_collection/plugins/modules/tower_inventory_source.py +++ b/awx_collection/plugins/modules/tower_inventory_source.py @@ -143,7 +143,7 @@ options: - Tower option to avoid certificates check. type: bool aliases: [ tower_verify_ssl ] -extends_documentation_fragment: tower +extends_documentation_fragment: awx.awx.auth ''' diff --git a/awx_collection/plugins/modules/tower_job_cancel.py b/awx_collection/plugins/modules/tower_job_cancel.py index 1a658f02f5..f7a80b9f71 100644 --- a/awx_collection/plugins/modules/tower_job_cancel.py +++ b/awx_collection/plugins/modules/tower_job_cancel.py @@ -32,7 +32,7 @@ options: - Fail loudly if the I(job_id) does not reference a running job. default: False type: bool -extends_documentation_fragment: tower +extends_documentation_fragment: awx.awx.auth ''' EXAMPLES = ''' diff --git a/awx_collection/plugins/modules/tower_job_launch.py b/awx_collection/plugins/modules/tower_job_launch.py index e790603ec9..792632fbb4 100644 --- a/awx_collection/plugins/modules/tower_job_launch.py +++ b/awx_collection/plugins/modules/tower_job_launch.py @@ -54,7 +54,7 @@ options: - Disable launching jobs from job template. type: bool default: 'no' -extends_documentation_fragment: tower +extends_documentation_fragment: awx.awx.auth ''' EXAMPLES = ''' diff --git a/awx_collection/plugins/modules/tower_job_list.py b/awx_collection/plugins/modules/tower_job_list.py index e89589b498..ef8d8b3b15 100644 --- a/awx_collection/plugins/modules/tower_job_list.py +++ b/awx_collection/plugins/modules/tower_job_list.py @@ -38,7 +38,7 @@ options: query: description: - Query used to further filter the list of jobs. C({"foo":"bar"}) will be passed at C(?foo=bar) -extends_documentation_fragment: tower +extends_documentation_fragment: awx.awx.auth ''' diff --git a/awx_collection/plugins/modules/tower_job_template.py b/awx_collection/plugins/modules/tower_job_template.py index f1ee9e5775..2600e8884e 100644 --- a/awx_collection/plugins/modules/tower_job_template.py +++ b/awx_collection/plugins/modules/tower_job_template.py @@ -176,7 +176,7 @@ options: - Desired state of the resource. default: "present" choices: ["present", "absent"] -extends_documentation_fragment: tower +extends_documentation_fragment: awx.awx.auth notes: - JSON for survey_spec can be found in Tower API Documentation. See U(https://docs.ansible.com/ansible-tower/latest/html/towerapi/api_ref.html#/Job_Templates/Job_Templates_job_templates_survey_spec_create) diff --git a/awx_collection/plugins/modules/tower_job_wait.py b/awx_collection/plugins/modules/tower_job_wait.py index bc6aa89b3f..0f0ab806db 100644 --- a/awx_collection/plugins/modules/tower_job_wait.py +++ b/awx_collection/plugins/modules/tower_job_wait.py @@ -38,7 +38,7 @@ options: timeout: description: - Maximum time in seconds to wait for a job to finish. -extends_documentation_fragment: tower +extends_documentation_fragment: awx.awx.auth ''' EXAMPLES = ''' diff --git a/awx_collection/plugins/modules/tower_label.py b/awx_collection/plugins/modules/tower_label.py index b29a001a02..09b3b4b6dd 100644 --- a/awx_collection/plugins/modules/tower_label.py +++ b/awx_collection/plugins/modules/tower_label.py @@ -36,7 +36,7 @@ options: - Desired state of the resource. default: "present" choices: ["present", "absent"] -extends_documentation_fragment: tower +extends_documentation_fragment: awx.awx.auth ''' diff --git a/awx_collection/plugins/modules/tower_notification.py b/awx_collection/plugins/modules/tower_notification.py index 96833ce1dd..eee30a8cd4 100644 --- a/awx_collection/plugins/modules/tower_notification.py +++ b/awx_collection/plugins/modules/tower_notification.py @@ -164,7 +164,7 @@ options: - Desired state of the resource. default: "present" choices: ["present", "absent"] -extends_documentation_fragment: tower +extends_documentation_fragment: awx.awx.auth ''' diff --git a/awx_collection/plugins/modules/tower_organization.py b/awx_collection/plugins/modules/tower_organization.py index d38d47b8b3..7f261e2f1c 100644 --- a/awx_collection/plugins/modules/tower_organization.py +++ b/awx_collection/plugins/modules/tower_organization.py @@ -35,7 +35,7 @@ options: - Desired state of the resource. default: "present" choices: ["present", "absent"] -extends_documentation_fragment: tower +extends_documentation_fragment: awx.awx.auth ''' diff --git a/awx_collection/plugins/modules/tower_project.py b/awx_collection/plugins/modules/tower_project.py index 9216eb59f3..423f63bb7f 100644 --- a/awx_collection/plugins/modules/tower_project.py +++ b/awx_collection/plugins/modules/tower_project.py @@ -85,7 +85,7 @@ options: - Desired state of the resource. default: "present" choices: ["present", "absent"] -extends_documentation_fragment: tower +extends_documentation_fragment: awx.awx.auth ''' diff --git a/awx_collection/plugins/modules/tower_receive.py b/awx_collection/plugins/modules/tower_receive.py index 6c61d927d7..66d45da58f 100644 --- a/awx_collection/plugins/modules/tower_receive.py +++ b/awx_collection/plugins/modules/tower_receive.py @@ -79,7 +79,7 @@ requirements: notes: - Specifying a name of "all" for any asset type will export all items of that asset type. -extends_documentation_fragment: tower +extends_documentation_fragment: awx.awx.auth ''' EXAMPLES = ''' diff --git a/awx_collection/plugins/modules/tower_role.py b/awx_collection/plugins/modules/tower_role.py index 92b806e8f2..9352827d8b 100644 --- a/awx_collection/plugins/modules/tower_role.py +++ b/awx_collection/plugins/modules/tower_role.py @@ -58,7 +58,7 @@ options: - Desired state of the resource. default: "present" choices: ["present", "absent"] -extends_documentation_fragment: tower +extends_documentation_fragment: awx.awx.auth ''' diff --git a/awx_collection/plugins/modules/tower_send.py b/awx_collection/plugins/modules/tower_send.py index 3cd46ff613..eaa5b9d69f 100644 --- a/awx_collection/plugins/modules/tower_send.py +++ b/awx_collection/plugins/modules/tower_send.py @@ -54,7 +54,7 @@ requirements: - six.moves.StringIO - sys -extends_documentation_fragment: tower +extends_documentation_fragment: awx.awx.auth ''' EXAMPLES = ''' diff --git a/awx_collection/plugins/modules/tower_settings.py b/awx_collection/plugins/modules/tower_settings.py index c429463450..8de8c2e6f9 100644 --- a/awx_collection/plugins/modules/tower_settings.py +++ b/awx_collection/plugins/modules/tower_settings.py @@ -31,7 +31,7 @@ options: description: - Value to be modified for given setting. required: True -extends_documentation_fragment: tower +extends_documentation_fragment: awx.awx.auth ''' RETURN = ''' # ''' diff --git a/awx_collection/plugins/modules/tower_team.py b/awx_collection/plugins/modules/tower_team.py index 554e730382..165f801b20 100644 --- a/awx_collection/plugins/modules/tower_team.py +++ b/awx_collection/plugins/modules/tower_team.py @@ -36,7 +36,7 @@ options: - Desired state of the resource. choices: ["present", "absent"] default: "present" -extends_documentation_fragment: tower +extends_documentation_fragment: awx.awx.auth ''' diff --git a/awx_collection/plugins/modules/tower_user.py b/awx_collection/plugins/modules/tower_user.py index e361412eb3..a5fea6d861 100644 --- a/awx_collection/plugins/modules/tower_user.py +++ b/awx_collection/plugins/modules/tower_user.py @@ -59,7 +59,7 @@ options: requirements: - ansible-tower-cli >= 3.2.0 -extends_documentation_fragment: tower +extends_documentation_fragment: awx.awx.auth ''' diff --git a/awx_collection/plugins/modules/tower_workflow_launch.py b/awx_collection/plugins/modules/tower_workflow_launch.py index 8df65e8919..8e0c06d33c 100644 --- a/awx_collection/plugins/modules/tower_workflow_launch.py +++ b/awx_collection/plugins/modules/tower_workflow_launch.py @@ -41,7 +41,7 @@ options: requirements: - "python >= 2.6" -extends_documentation_fragment: tower +extends_documentation_fragment: awx.awx.auth ''' RETURN = ''' diff --git a/awx_collection/plugins/modules/tower_workflow_template.py b/awx_collection/plugins/modules/tower_workflow_template.py index b3fc6e14d3..3805079d01 100644 --- a/awx_collection/plugins/modules/tower_workflow_template.py +++ b/awx_collection/plugins/modules/tower_workflow_template.py @@ -73,7 +73,7 @@ options: - Desired state of the resource. default: "present" choices: ["present", "absent"] -extends_documentation_fragment: tower +extends_documentation_fragment: awx.awx.auth ''' diff --git a/awx_collection/template_galaxy.yml b/awx_collection/template_galaxy.yml index 0064548c28..e7f57d1074 100644 --- a/awx_collection/template_galaxy.yml +++ b/awx_collection/template_galaxy.yml @@ -7,5 +7,22 @@ package_version: 0.0.1 tasks: + - name: Do file content replacements for non-default namespace or package name + block: + - name: Find all module files + find: + paths: "{{ playbook_dir }}/plugins/modules" + patterns: "*.py" + register: module_files + + - name: Change files to support desired namespace and package names + replace: + path: "{{ item.path }}" + regexp: '^extends_documentation_fragment: awx.awx.auth$' + replace: 'extends_documentation_fragment: {{ namespace_name }}.{{ package_name }}.auth' + with_items: "{{ module_files.files }}" + when: + - (package_name != 'awx') or (namespace_name != 'awx') + - name: Template the galaxy.yml file template: src={{ playbook_dir }}/galaxy.yml.j2 dest={{ playbook_dir }}/galaxy.yml