From 199b4b6b47b8e20baedec0faf30738e38f2b9c8d Mon Sep 17 00:00:00 2001 From: Seth Foster Date: Mon, 7 Jun 2021 14:00:43 -0400 Subject: [PATCH] fixed up jinja2 templating and documentation --- awx_collection/TESTING.md | 17 +++++++++-------- .../tools/roles/generate/templates/module.j2 | 14 +++++++------- .../template_galaxy/templates/README.md.j2 | 4 +++- awx_collection/tools/vars/associations.yml | 3 +++ awx_collection/tools/vars/examples.yml | 10 +++++----- awx_collection/tools/vars/resolution.yml | 11 +++++++++-- 6 files changed, 36 insertions(+), 23 deletions(-) diff --git a/awx_collection/TESTING.md b/awx_collection/TESTING.md index 0ecf99c26e..97ada687fb 100644 --- a/awx_collection/TESTING.md +++ b/awx_collection/TESTING.md @@ -12,7 +12,8 @@ The unit tests are stored in the `test/awx` directory and, where possible, test Let's take a closer look at the `test_token.py` file (which tests the `token` module): ``` -from __future__ import (absolute_import, division, print_function) +from __future__ import absolute_import, division, print_function + __metaclass__ = type import pytest @@ -27,12 +28,12 @@ def test_create_token(run_module, admin_user): 'description': 'barfoo', 'state': 'present', 'scope': 'read', - 'tower_host': None, - 'tower_username': None, - 'tower_password': None, + 'controller_host': None, + 'controller_username': None, + 'controller_password': None, 'validate_certs': None, - 'tower_oauthtoken': None, - 'tower_config_file': None, + 'controller_oauthtoken': None, + 'controller_config_file': None, } result = run_module('token', module_args, admin_user) @@ -97,7 +98,7 @@ While not strictly followed, the general flow of a test should be: ``` - name: Try to use a token as a dict which is missing the token parameter job_list: - tower_oauthtoken: + controller_oauthtoken: not_token: "This has no token entry" register: results ignore_errors: true @@ -105,7 +106,7 @@ While not strictly followed, the general flow of a test should be: - assert: that: - results is failed - - '"The provided dict in tower_oauthtoken did not properly contain the token entry" == results.msg' + - '"The provided dict in controller_oauthtoken did not properly contain the token entry" == results.msg' ``` - **`Block:`** diff --git a/awx_collection/tools/roles/generate/templates/module.j2 b/awx_collection/tools/roles/generate/templates/module.j2 index 407cbd8530..57e6bc4c77 100644 --- a/awx_collection/tools/roles/generate/templates/module.j2 +++ b/awx_collection/tools/roles/generate/templates/module.j2 @@ -22,12 +22,12 @@ ANSIBLE_METADATA = {'metadata_version': '1.1', DOCUMENTATION = ''' --- -module: tower_{{ singular_item_type }} +module: {{ singular_item_type }} author: "John Westcott IV (@john-westcott-iv)" version_added: "4.0.0" -short_description: create, update, or destroy Ansible Tower {{ human_readable }}. +short_description: create, update, or destroy Automation Platform Controller {{ human_readable }}. description: - - Create, update, or destroy Ansible Tower {{ human_readable }}. See + - Create, update, or destroy Automation Platform Controller {{ human_readable }}. See U(https://www.ansible.com/tower) for an overview. options: {% for option in item['json']['actions']['POST'] %} @@ -37,12 +37,12 @@ options: {% if 'help_text' in item['json']['actions']['POST'][option] %} - {{ item['json']['actions']['POST'][option]['help_text'] }} {% else %} - - NO DESCRIPTION GIVEN IN THE TOWER API + - NO DESCRIPTION GIVEN IN THE API {% endif %} required: {{ item['json']['actions']['POST'][option]['required'] }} type: {{ type_map[ item['json']['actions']['POST'][option]['type'] ] }} {% if 'default' in item['json']['actions']['POST'][option] %} -{# for tower_job_template/extra vars, its type is dict but its default is '', so we want to make that {} #} +{# for job_template/extra vars, its type is dict but its default is '', so we want to make that {} #} {% if item['json']['actions']['POST'][option]['default'] == '' and type_map[ item['json']['actions']['POST'][option]['type'] ] == 'dict' %} default: {} {% else %} @@ -82,9 +82,9 @@ options: choices: ["present", "absent"] default: "present" type: str - tower_oauthtoken: + controller_oauthtoken: description: - - The Tower OAuth token to use. + - The OAuth token to use. required: False type: str extends_documentation_fragment: awx.awx.auth diff --git a/awx_collection/tools/roles/template_galaxy/templates/README.md.j2 b/awx_collection/tools/roles/template_galaxy/templates/README.md.j2 index 274df392b5..88fd3c4739 100644 --- a/awx_collection/tools/roles/template_galaxy/templates/README.md.j2 +++ b/awx_collection/tools/roles/template_galaxy/templates/README.md.j2 @@ -76,11 +76,13 @@ Notable releases of the `{{ collection_namespace }}.{{ collection_package }}` co - 0.0.1-devel is the version you should see if installing from source, which is intended for development and expected to be unstable. {% else %} - 3.7.0 initial release + - 4.0.0 ansible.tower renamed to ansible.controller + - tower_ prefix is dropped from the module names, e.g. tower_inventory becomes inventory {% endif %} The following notes are changes that may require changes to playbooks: - - The module tower_notification was renamed tower_notification_template. In ansible >= 2.10 there is a seemless redirect. Ansible 2.9 does not respect the redirect. + - The module tower_notification was renamed tower_notification_template. In ansible >= 2.10 there is a seamless redirect. Ansible 2.9 does not respect the redirect. - When a project is created, it will wait for the update/sync to finish by default; this can be turned off with the `wait` parameter, if desired. - Creating a "scan" type job template is no longer supported. - Specifying a custom certificate via the `TOWER_CERTIFICATE` environment variable no longer works. diff --git a/awx_collection/tools/vars/associations.yml b/awx_collection/tools/vars/associations.yml index 9d95bd666e..467d83ec27 100644 --- a/awx_collection/tools/vars/associations.yml +++ b/awx_collection/tools/vars/associations.yml @@ -4,10 +4,13 @@ associations: - related_item: credentials endpoint: credentials description: "The credentials used by this job template" + required: False groups: - related_item: hosts endpoint: hosts description: "The hosts associated with this group" + required: False - related_item: groups endpoint: children description: "The hosts associated with this group" + required: False diff --git a/awx_collection/tools/vars/examples.yml b/awx_collection/tools/vars/examples.yml index 95fe4a3f53..f3c612f60e 100644 --- a/awx_collection/tools/vars/examples.yml +++ b/awx_collection/tools/vars/examples.yml @@ -9,7 +9,7 @@ examples: first_name: John last_name: Doe state: present - tower_config_file: "~/tower_cli.cfg" + controller_config_file: "~/tower_cli.cfg" - name: Add user as a system administrator user: @@ -18,7 +18,7 @@ examples: email: jdoe@example.org superuser: yes state: present - tower_config_file: "~/tower_cli.cfg" + controller_config_file: "~/tower_cli.cfg" - name: Add user as a system auditor user: @@ -27,14 +27,14 @@ examples: email: jdoe@example.org auditor: yes state: present - tower_config_file: "~/tower_cli.cfg" + controller_config_file: "~/tower_cli.cfg" - name: Delete user user: username: jdoe email: jdoe@example.org state: absent - tower_config_file: "~/tower_cli.cfg" + controller_config_file: "~/tower_cli.cfg" job_templates: | - name: Create Ping job template @@ -46,6 +46,6 @@ examples: playbook: "ping.yml" credential: "Local" state: "present" - tower_config_file: "~/tower_cli.cfg" + controller_config_file: "~/tower_cli.cfg" survey_enabled: yes survey_spec: "{{ '{{' }} lookup('file', 'my_survey.json') {{ '}}' }}" diff --git a/awx_collection/tools/vars/resolution.yml b/awx_collection/tools/vars/resolution.yml index 2beda0ff23..de946a6cf2 100644 --- a/awx_collection/tools/vars/resolution.yml +++ b/awx_collection/tools/vars/resolution.yml @@ -1,7 +1,14 @@ --- name_to_id_endpoint_resolution: webhook_credential: credentials - project: projects + credential: credentials + credential_type: credential_types + default_environment: execution_environments + execution_environment: execution_environments inventory: inventories organization: organizations - credential: credentials + project: projects + source_project: projects + team: teams + unified_job_template: unified_job_templates + user: users