fixed up jinja2 templating and documentation

This commit is contained in:
Seth Foster 2021-06-07 14:00:43 -04:00
parent f06485feca
commit 199b4b6b47
No known key found for this signature in database
GPG Key ID: 86E90D96F7184028
6 changed files with 36 additions and 23 deletions

View File

@ -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:`**

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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') {{ '}}' }}"

View File

@ -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