From ef56571772e462b206e8f592627b3dbe7430fe14 Mon Sep 17 00:00:00 2001 From: Seth Foster Date: Fri, 30 Apr 2021 15:41:01 -0400 Subject: [PATCH] controller_meta, templating --- awx_collection/README.md | 49 ++----------------- awx_collection/galaxy.yml | 4 +- awx_collection/meta/runtime.yml | 2 +- .../modules/{meta.py => controller_meta.py} | 6 +-- awx_collection/test/awx/test_completeness.py | 4 +- .../targets/lookup_api_plugin/tasks/main.yml | 2 +- .../targets/schedule_rrule/tasks/main.yml | 2 +- .../integration/targets/token/tasks/main.yml | 4 +- awx_collection/tests/sanity/ignore-2.10.txt | 28 +++++------ .../roles/template_galaxy/tasks/main.yml | 6 +-- 10 files changed, 34 insertions(+), 73 deletions(-) rename awx_collection/plugins/modules/{meta.py => controller_meta.py} (92%) diff --git a/awx_collection/README.md b/awx_collection/README.md index 0a9e47a5ab..a1a2a959d5 100644 --- a/awx_collection/README.md +++ b/awx_collection/README.md @@ -1,4 +1,4 @@ -# AWX Ansible Collection +# Tower Ansible Collection [comment]: # (*******************************************************) [comment]: # (* *) @@ -12,7 +12,7 @@ [comment]: # (* upon build of the collection *) [comment]: # (*******************************************************) -This Ansible collection allows for easy interaction with an AWX server via Ansible playbooks. +This Ansible collection allows for easy interaction with an Ansible Tower server via Ansible playbooks. This source for this collection lives in the `awx_collection` folder inside of the AWX source. @@ -22,12 +22,7 @@ doc fragment. ## Building and Installing -This collection templates the `galaxy.yml` file it uses. -Run `make build_collection` from the root folder of the AWX source tree. -This will create the `tar.gz` file inside the `awx_collection` folder -with the current AWX version, for example: `awx_collection/awx-awx-9.2.0.tar.gz`. - -Installing the `tar.gz` involves no special instructions. +This collection should be installed from [Content Hub](https://cloud.redhat.com/ansible/automation-hub/ansible/tower/) ## Running @@ -63,11 +58,9 @@ oauth_token = LEdCpKVKc4znzffcpQL5vLG8oyeku6 ## Release and Upgrade Notes -Notable releases of the `awx.awx` collection: +Notable releases of the `ansible.controller` collection: - - 7.0.0 is intended to be identical to the content prior to the migration, aside from changes necessary to function as a collection. - - 11.0.0 has no non-deprecated modules that depend on the deprecated `tower-cli` [PyPI](https://pypi.org/project/ansible-tower-cli/). - - 0.0.1-devel is the version you should see if installing from source, which is intended for development and expected to be unstable. + - 3.7.0 initial release The following notes are changes that may require changes to playbooks: @@ -96,38 +89,6 @@ The following notes are changes that may require changes to playbooks: - `tower_credential` no longer supports passing a file name to ssh_key_data. - The HipChat `notification_type` has been removed and can no longer be created using the `tower_notification_template` module. -## Running Unit Tests - -Tests to verify compatibility with the most recent AWX code are in `awx_collection/test/awx`. -These can be ran by `make test_collection` in the development container. - -To run outside of the development container, or to run against -Ansible source, set up a working environment: - -``` -mkvirtualenv my_new_venv -# may need to replace psycopg2 with psycopg2-binary in requirements/requirements.txt -pip install -r requirements/requirements.txt -r requirements/requirements_dev.txt -r requirements/requirements_git.txt -make clean-api -pip install -e -pip install -e . -pip install -e awxkit -py.test awx_collection/test/awx/ -``` - -## Running Integration Tests - -The integration tests require a virtualenv with `ansible` >= 2.9 and `awxkit`. -The collection must first be installed, which can be done using `make install_collection`. -You also need a configuration file, as described in the running section. - -Run the tests: - -``` -# ansible-test must be run from the directory in which the collection is installed -cd ~/.ansible/collections/ansible_collections/awx/awx/ -ansible-test integration -``` ## Licensing diff --git a/awx_collection/galaxy.yml b/awx_collection/galaxy.yml index 15ae9cdcbb..3a94c6a718 100644 --- a/awx_collection/galaxy.yml +++ b/awx_collection/galaxy.yml @@ -19,8 +19,8 @@ homepage: https://www.ansible.com/ issues: https://github.com/ansible/awx/issues?q=is%3Aissue+label%3Acomponent%3Aawx_collection license: - GPL-3.0-only -name: awx -namespace: awx +name: controller +namespace: ansible readme: README.md repository: https://github.com/ansible/awx tags: diff --git a/awx_collection/meta/runtime.yml b/awx_collection/meta/runtime.yml index b2a565da39..ff29c22ba7 100644 --- a/awx_collection/meta/runtime.yml +++ b/awx_collection/meta/runtime.yml @@ -75,7 +75,7 @@ plugin_routing: tower_settings: redirect: settings tower_meta: - redirect: meta + redirect: controller_meta tower_export: redirect: export tower_ad_hoc_command_cancel: diff --git a/awx_collection/plugins/modules/meta.py b/awx_collection/plugins/modules/controller_meta.py similarity index 92% rename from awx_collection/plugins/modules/meta.py rename to awx_collection/plugins/modules/controller_meta.py index dafa023a25..d0812c9753 100644 --- a/awx_collection/plugins/modules/meta.py +++ b/awx_collection/plugins/modules/controller_meta.py @@ -13,7 +13,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported DOCUMENTATION = ''' --- -module: meta +module: controller_meta author: "Alan Rominger (@alancoding)" short_description: Returns metadata about the collection this module lives in. description: @@ -49,7 +49,7 @@ version: EXAMPLES = ''' -- meta: +- controller_meta: register: result - name: Show details about the collection @@ -66,7 +66,7 @@ from ..module_utils.controller_api import ControllerAPIModule def main(): module = ControllerAPIModule(argument_spec={}) - namespace = {'awx': 'awx', 'tower': 'ansible'}.get(module._COLLECTION_TYPE, 'unknown') + namespace = {'awx': 'awx', 'controller': 'ansible'}.get(module._COLLECTION_TYPE, 'unknown') namespace_name = '{0}.{1}'.format(namespace, module._COLLECTION_TYPE) module.exit_json(prefix=namespace_name, name=module._COLLECTION_TYPE, namespace=namespace, version=module._COLLECTION_VERSION) diff --git a/awx_collection/test/awx/test_completeness.py b/awx_collection/test/awx/test_completeness.py index dcfe95f48f..a2667d9cd6 100644 --- a/awx_collection/test/awx/test_completeness.py +++ b/awx_collection/test/awx/test_completeness.py @@ -25,7 +25,7 @@ no_module_for_endpoint = [] # Some modules work on the related fields of an endpoint. These modules will not have an auto-associated endpoint no_endpoint_for_module = [ 'import', - 'meta', + 'controller_meta', 'export', 'inventory_source_update', 'job_launch', @@ -170,7 +170,7 @@ def test_completeness(collection_import, request, admin_user, job_template, exec if root == module_directory: for filename in files: # must begin with a letter a-z, and end in .py - if re.match('^[a-z].*\.py$', filename): + if re.match(r'^[a-z].*.py$', filename): module_name = filename[:-3] option_comparison[module_name] = { 'endpoint': 'N/A', diff --git a/awx_collection/tests/integration/targets/lookup_api_plugin/tasks/main.yml b/awx_collection/tests/integration/targets/lookup_api_plugin/tasks/main.yml index 416ec855bd..b9be9607b0 100644 --- a/awx_collection/tests/integration/targets/lookup_api_plugin/tasks/main.yml +++ b/awx_collection/tests/integration/targets/lookup_api_plugin/tasks/main.yml @@ -16,7 +16,7 @@ group_name: "AWX-Collection-tests-tower_api_lookup-group1-{{ test_id }}" - name: Get our collection package - meta: + controller_meta: register: tower_meta - name: Generate the name of our plugin diff --git a/awx_collection/tests/integration/targets/schedule_rrule/tasks/main.yml b/awx_collection/tests/integration/targets/schedule_rrule/tasks/main.yml index 84ff069b51..f7a1b0e2b0 100644 --- a/awx_collection/tests/integration/targets/schedule_rrule/tasks/main.yml +++ b/awx_collection/tests/integration/targets/schedule_rrule/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: Get our collection package - meta: + controller_meta: register: tower_meta - name: Generate the name of our plugin diff --git a/awx_collection/tests/integration/targets/token/tasks/main.yml b/awx_collection/tests/integration/targets/token/tasks/main.yml index 9ff781adc3..afbcb84768 100644 --- a/awx_collection/tests/integration/targets/token/tasks/main.yml +++ b/awx_collection/tests/integration/targets/token/tasks/main.yml @@ -5,7 +5,7 @@ - name: Try to use a token as a dict which is missing the token parameter job_list: - oauthtoken: + tower_oauthtoken: not_token: "This has no token entry" register: results ignore_errors: true @@ -17,7 +17,7 @@ - name: Try to use a token as a list job_list: - oauthtoken: + tower_oauthtoken: - dummy_token register: results ignore_errors: true diff --git a/awx_collection/tests/sanity/ignore-2.10.txt b/awx_collection/tests/sanity/ignore-2.10.txt index a0e41bd790..b990470a8d 100644 --- a/awx_collection/tests/sanity/ignore-2.10.txt +++ b/awx_collection/tests/sanity/ignore-2.10.txt @@ -1,16 +1,16 @@ -plugins/modules/tower_receive.py validate-modules:deprecation-mismatch -plugins/modules/tower_send.py validate-modules:deprecation-mismatch -plugins/modules/tower_workflow_template.py validate-modules:deprecation-mismatch -plugins/modules/tower_credential.py pylint:wrong-collection-deprecated-version-tag -plugins/modules/tower_job_wait.py pylint:wrong-collection-deprecated-version-tag -plugins/modules/tower_notification_template.py pylint:wrong-collection-deprecated-version-tag -plugins/inventory/tower.py pylint:raise-missing-from -plugins/inventory/tower.py pylint:super-with-arguments -plugins/lookup/tower_schedule_rrule.py pylint:raise-missing-from -plugins/module_utils/tower_api.py pylint:super-with-arguments -plugins/module_utils/tower_awxkit.py pylint:super-with-arguments +plugins/modules/receive.py validate-modules:deprecation-mismatch +plugins/modules/send.py validate-modules:deprecation-mismatch +plugins/modules/workflow_template.py validate-modules:deprecation-mismatch +plugins/modules/credential.py pylint:wrong-collection-deprecated-version-tag +plugins/modules/job_wait.py pylint:wrong-collection-deprecated-version-tag +plugins/modules/notification_template.py pylint:wrong-collection-deprecated-version-tag +plugins/inventory/controller.py pylint:raise-missing-from +plugins/inventory/controller.py pylint:super-with-arguments +plugins/lookup/schedule_rrule.py pylint:raise-missing-from +plugins/module_utils/controller_api.py pylint:super-with-arguments +plugins/module_utils/awxkit.py pylint:super-with-arguments plugins/module_utils/tower_legacy.py pylint:super-with-arguments -plugins/module_utils/tower_module.py pylint:super-with-arguments -plugins/module_utils/tower_module.py pylint:raise-missing-from +plugins/module_utils/controller_module.py pylint:super-with-arguments +plugins/module_utils/controller_module.py pylint:raise-missing-from test/awx/conftest.py pylint:raise-missing-from -plugins/module_utils/tower_api.py pep8:E203 +plugins/module_utils/controller_api.py pep8:E203 diff --git a/awx_collection/tools/roles/template_galaxy/tasks/main.yml b/awx_collection/tools/roles/template_galaxy/tasks/main.yml index 1b12854c0d..99f3356a47 100644 --- a/awx_collection/tools/roles/template_galaxy/tasks/main.yml +++ b/awx_collection/tools/roles/template_galaxy/tasks/main.yml @@ -24,15 +24,15 @@ with_fileglob: - "{{ collection_path }}/plugins/inventory/*.py" - "{{ collection_path }}/plugins/lookup/*.py" - - "{{ collection_path }}/plugins/modules/tower_*.py" + - "{{ collection_path }}/plugins/modules/*.py" loop_control: label: "{{ item | basename }}" - name: Change inventory file to support desired namespace and package names replace: path: "{{ collection_path }}/plugins/inventory/controller.py" - regexp: "^ NAME = 'awx.awx.tower' # REPLACE$" - replace: " NAME = '{{ collection_namespace }}.{{ collection_package }}.tower' # REPLACE" + regexp: "^ NAME = 'awx.awx.controller' # REPLACE$" + replace: " NAME = '{{ collection_namespace }}.{{ collection_package }}.controller' # REPLACE" - name: get list of test files find: