From 9d93b78296ff98d5e11aed28c1fb012b33e2f1cf Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Thu, 3 Oct 2019 12:04:59 -0400 Subject: [PATCH 1/5] New target for sanity testing of the collection Do not run in Zuul --- .gitignore | 1 + Makefile | 8 ++++++++ awx_collection/make_imports_absolute.yml | 17 +++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 awx_collection/make_imports_absolute.yml diff --git a/.gitignore b/.gitignore index be22f947ae..60d960b66e 100644 --- a/.gitignore +++ b/.gitignore @@ -138,6 +138,7 @@ use_dev_supervisor.txt awx_collection_test_venv/ awx_collection/*.tar.gz awx_collection/galaxy.yml +sanity/ .idea/* *.unison.tmp diff --git a/Makefile b/Makefile index 0a93a8696b..55b65fa2c5 100644 --- a/Makefile +++ b/Makefile @@ -399,6 +399,14 @@ flake8_collection: test_collection_all: prepare_collection_venv test_collection flake8_collection +test_collection_sanity: + rm -rf sanity + mkdir -p sanity/ansible_collections/awx + cp -Ra awx_collection sanity/ansible_collections/awx/awx # symlinks do not work + cd sanity/ansible_collections/awx/awx && ansible-playbook -i localhost, make_imports_absolute.yml # hack because sanity tests do not fully work + cd sanity/ansible_collections/awx/awx && git init && git add . # requires both this file structure and a git repo, so there you go + cd sanity/ansible_collections/awx/awx && ansible-test sanity --test validate-modules + build_collection: ansible-playbook -i localhost, awx_collection/template_galaxy.yml -e collection_package=$(COLLECTION_PACKAGE) -e collection_namespace=$(COLLECTION_NAMESPACE) -e collection_version=$(VERSION) ansible-galaxy collection build awx_collection --output-path=awx_collection diff --git a/awx_collection/make_imports_absolute.yml b/awx_collection/make_imports_absolute.yml new file mode 100644 index 0000000000..184019ea2b --- /dev/null +++ b/awx_collection/make_imports_absolute.yml @@ -0,0 +1,17 @@ +- hosts: localhost + gather_facts: false + connection: local + + tasks: + - name: Find all module files + find: + paths: "{{ playbook_dir }}/plugins/modules" + patterns: "*.py" + register: module_files + + - name: Change module_utils imports to absolute namespace and package names + replace: + path: "{{ item.path }}" + regexp: '^from ..module_utils.ansible_tower' + replace: 'from ansible_collections.awx.awx.plugins.module_utils.ansible_tower' + with_items: "{{ module_files.files }}" From 201ae5f948ec94e418b9165999ad6352e82a5126 Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Mon, 30 Sep 2019 16:01:44 -0400 Subject: [PATCH 2/5] declare types in Ansible Tower module options --- .../plugins/modules/tower_credential.py | 3 ++- .../plugins/modules/tower_credential_type.py | 6 +++++ awx_collection/plugins/modules/tower_group.py | 16 ++++++++++- awx_collection/plugins/modules/tower_host.py | 5 ++++ .../plugins/modules/tower_inventory.py | 7 +++++ .../plugins/modules/tower_inventory_source.py | 20 ++++++++++---- .../plugins/modules/tower_job_cancel.py | 1 + .../plugins/modules/tower_job_launch.py | 15 +++++------ .../plugins/modules/tower_job_list.py | 3 +++ .../plugins/modules/tower_job_template.py | 21 +++++++++++++++ .../plugins/modules/tower_job_wait.py | 4 +++ awx_collection/plugins/modules/tower_label.py | 3 +++ .../plugins/modules/tower_notification.py | 27 +++++++++++++++++++ .../plugins/modules/tower_organization.py | 3 +++ .../plugins/modules/tower_project.py | 12 +++++++++ .../plugins/modules/tower_receive.py | 11 ++++++++ awx_collection/plugins/modules/tower_role.py | 10 +++++++ awx_collection/plugins/modules/tower_send.py | 4 +++ .../plugins/modules/tower_settings.py | 2 ++ awx_collection/plugins/modules/tower_team.py | 7 +++++ awx_collection/plugins/modules/tower_user.py | 6 +++++ .../plugins/modules/tower_workflow_launch.py | 3 +++ .../modules/tower_workflow_template.py | 8 ++++++ 23 files changed, 182 insertions(+), 15 deletions(-) diff --git a/awx_collection/plugins/modules/tower_credential.py b/awx_collection/plugins/modules/tower_credential.py index 587d8205dd..f43d7f5ab3 100644 --- a/awx_collection/plugins/modules/tower_credential.py +++ b/awx_collection/plugins/modules/tower_credential.py @@ -130,7 +130,8 @@ options: become_method: description: - Become method to use for privilege escalation. - choices: ["None", "sudo", "su", "pbrun", "pfexec", "pmrun"] + - Some examples are "None", "sudo", "su", "pbrun" + - Due to become plugins, these can be arbitrary type: str become_username: description: diff --git a/awx_collection/plugins/modules/tower_credential_type.py b/awx_collection/plugins/modules/tower_credential_type.py index 0fd6ebd046..94bb76e90f 100644 --- a/awx_collection/plugins/modules/tower_credential_type.py +++ b/awx_collection/plugins/modules/tower_credential_type.py @@ -28,10 +28,12 @@ options: description: - The name of the credential type. required: True + type: str description: description: - The description of the credential type to give more detail about it. required: False + type: str kind: description: - >- @@ -40,24 +42,28 @@ options: for more information. choices: [ 'ssh', 'vault', 'net', 'scm', 'cloud', 'insights' ] required: False + type: str inputs: description: - >- Enter inputs using either JSON or YAML syntax. Refer to the Ansible Tower documentation for example syntax. required: False + type: dict injectors: description: - >- Enter injectors using either JSON or YAML syntax. Refer to the Ansible Tower documentation for example syntax. required: False + type: dict state: description: - Desired state of the resource. required: False default: "present" choices: ["present", "absent"] + type: str validate_certs: description: - Tower option to avoid certificates check. diff --git a/awx_collection/plugins/modules/tower_group.py b/awx_collection/plugins/modules/tower_group.py index 7fe717666a..bd9feaf91f 100644 --- a/awx_collection/plugins/modules/tower_group.py +++ b/awx_collection/plugins/modules/tower_group.py @@ -27,38 +27,50 @@ options: description: - The name to use for the group. required: True + type: str description: description: - The description to use for the group. + type: str inventory: description: - Inventory the group should be made a member of. required: True + type: str variables: description: - Variables to use for the group, use C(@) for a file. + type: str credential: description: - Credential to use for the group. + type: str source: description: - The source to use for this group. choices: ["manual", "file", "ec2", "rax", "vmware", "gce", "azure", "azure_rm", "openstack", "satellite6" , "cloudforms", "custom"] + default: manual + type: str source_regions: description: - Regions for cloud provider. + type: str source_vars: description: - Override variables from source with variables from this field. + type: str instance_filters: description: - Comma-separated list of filter expressions for matching hosts. + type: str group_by: description: - Limit groups automatically created from inventory source. + type: str source_script: description: - Inventory script to be used when group type is C(custom). + type: str overwrite: description: - Delete child groups and hosts not found in source. @@ -67,6 +79,7 @@ options: overwrite_vars: description: - Override vars in child groups and hosts with those from external source. + type: bool update_on_launch: description: - Refresh inventory data from its source each time a job is run. @@ -77,6 +90,7 @@ options: - Desired state of the resource. default: "present" choices: ["present", "absent"] + type: str extends_documentation_fragment: awx.awx.auth ''' @@ -120,7 +134,7 @@ def main(): group_by=dict(), source_script=dict(), overwrite=dict(type='bool', default=False), - overwrite_vars=dict(), + overwrite_vars=dict(type='bool', default=False), update_on_launch=dict(type='bool', default=False), state=dict(choices=['present', 'absent'], default='present'), ) diff --git a/awx_collection/plugins/modules/tower_host.py b/awx_collection/plugins/modules/tower_host.py index 02946cf4d7..7dfebb0b60 100644 --- a/awx_collection/plugins/modules/tower_host.py +++ b/awx_collection/plugins/modules/tower_host.py @@ -27,13 +27,16 @@ options: description: - The name to use for the host. required: True + type: str description: description: - The description to use for the host. + type: str inventory: description: - Inventory the host should be made a member of. required: True + type: str enabled: description: - If the host should be enabled. @@ -42,11 +45,13 @@ options: variables: description: - Variables to use for the host. Use C(@) for a file. + type: str state: description: - Desired state of the resource. choices: ["present", "absent"] default: "present" + type: str 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 811430a723..d2321f3853 100644 --- a/awx_collection/plugins/modules/tower_inventory.py +++ b/awx_collection/plugins/modules/tower_inventory.py @@ -27,31 +27,38 @@ options: description: - The name to use for the inventory. required: True + type: str description: description: - The description to use for the inventory. + type: str organization: description: - Organization the inventory belongs to. required: True + type: str variables: description: - Inventory variables. Use C(@) to get from file. + type: str kind: description: - The kind field. Cannot be modified after created. default: "" choices: ["", "smart"] version_added: "2.7" + type: str host_filter: description: - The host_filter field. Only useful when C(kind=smart). version_added: "2.7" + type: str state: description: - Desired state of the resource. default: "present" choices: ["present", "absent"] + type: str 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 ede0896d64..331e7a07bb 100644 --- a/awx_collection/plugins/modules/tower_inventory_source.py +++ b/awx_collection/plugins/modules/tower_inventory_source.py @@ -27,13 +27,16 @@ options: description: - The name to use for the inventory source. required: True + type: str description: description: - The description to use for the inventory source. + type: str inventory: description: - The inventory the source is linked to. required: True + type: str source: description: - Types of inventory source. @@ -52,9 +55,11 @@ options: - tower - custom required: True + type: str credential: description: - Credential to use to retrieve the inventory from. + type: str source_vars: description: - >- @@ -62,15 +67,19 @@ options: file. For example with Openstack, specifying *private: false* would change the output of the openstack.py script. It has to be YAML or JSON. + type: str timeout: description: - Number in seconds after which the Tower API methods will time out. + type: int source_project: description: - Use a *project* as a source for the *inventory*. + type: str source_path: description: - Path to the file to use as a source in the selected *project*. + type: str update_on_project_update: description: - >- @@ -83,23 +92,27 @@ options: List of regions for your cloud provider. You can include multiple all regions. Only Hosts associated with the selected regions will be updated. Refer to Ansible Tower documentation for more detail. + type: str instance_filters: description: - >- Provide a comma-separated list of filter expressions. Hosts are imported when all of the filters match. Refer to Ansible Tower documentation for more detail. + type: str group_by: description: - >- Specify which groups to create automatically. Group names will be created similar to the options selected. If blank, all groups above are created. Refer to Ansible Tower documentation for more detail. + type: str source_script: description: - >- The source custom script to use to build the inventory. It needs to exist. + type: str overwrite: description: - >- @@ -133,16 +146,13 @@ options: job runs and callbacks the task system will evaluate the timestamp of the latest sync. If it is older than Cache Timeout, it is not considered current, and a new inventory sync will be performed. + type: int state: description: - Desired state of the resource. default: "present" choices: ["present", "absent"] - validate_certs: - description: - - Tower option to avoid certificates check. - type: bool - aliases: [ tower_verify_ssl ] + type: str 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 f7a80b9f71..f65218b68a 100644 --- a/awx_collection/plugins/modules/tower_job_cancel.py +++ b/awx_collection/plugins/modules/tower_job_cancel.py @@ -27,6 +27,7 @@ options: description: - ID of the job to cancel required: True + type: int fail_if_not_running: description: - Fail loudly if the I(job_id) does not reference a running job. diff --git a/awx_collection/plugins/modules/tower_job_launch.py b/awx_collection/plugins/modules/tower_job_launch.py index 792632fbb4..40fc193b63 100644 --- a/awx_collection/plugins/modules/tower_job_launch.py +++ b/awx_collection/plugins/modules/tower_job_launch.py @@ -27,33 +27,32 @@ options: description: - Name of the job template to use. required: True - job_explanation: - description: - - Job explanation field. + type: str job_type: description: - Job_type to use for the job, only used if prompt for job_type is set. choices: ["run", "check", "scan"] + type: str inventory: description: - Inventory to use for the job, only used if prompt for inventory is set. + type: str credential: description: - Credential to use for job, only used if prompt for credential is set. + type: str extra_vars: description: - Extra_vars to use for the job_template. Prepend C(@) if a file. + type: list limit: description: - Limit to use for the I(job_template). + type: str tags: description: - Specific tags to use for from playbook. - use_job_endpoint: - description: - - Disable launching jobs from job template. - type: bool - default: 'no' + type: list extends_documentation_fragment: awx.awx.auth ''' diff --git a/awx_collection/plugins/modules/tower_job_list.py b/awx_collection/plugins/modules/tower_job_list.py index ef8d8b3b15..63bd7c6f9a 100644 --- a/awx_collection/plugins/modules/tower_job_list.py +++ b/awx_collection/plugins/modules/tower_job_list.py @@ -27,9 +27,11 @@ options: description: - Only list jobs with this status. choices: ['pending', 'waiting', 'running', 'error', 'failed', 'canceled', 'successful'] + type: str page: description: - Page number of the results to fetch. + type: int all_pages: description: - Fetch all the pages and return a single result. @@ -38,6 +40,7 @@ options: query: description: - Query used to further filter the list of jobs. C({"foo":"bar"}) will be passed at C(?foo=bar) + type: dict 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 2600e8884e..c3105f313c 100644 --- a/awx_collection/plugins/modules/tower_job_template.py +++ b/awx_collection/plugins/modules/tower_job_template.py @@ -27,50 +27,63 @@ options: description: - Name to use for the job template. required: True + type: str description: description: - Description to use for the job template. + type: str job_type: description: - The job type to use for the job template. required: True choices: ["run", "check", "scan"] + type: str inventory: description: - Name of the inventory to use for the job template. + type: str project: description: - Name of the project to use for the job template. required: True + type: str playbook: description: - Path to the playbook to use for the job template within the project provided. required: True + type: str credential: description: - Name of the credential to use for the job template. version_added: 2.7 + type: str vault_credential: description: - Name of the vault credential to use for the job template. version_added: 2.7 + type: str forks: description: - The number of parallel or simultaneous processes to use while executing the playbook. + type: int limit: description: - A host pattern to further constrain the list of hosts managed or affected by the playbook + type: str verbosity: description: - Control the output level Ansible produces as the playbook runs. 0 - Normal, 1 - Verbose, 2 - More Verbose, 3 - Debug, 4 - Connection Debug. choices: [0, 1, 2, 3, 4] default: 0 + type: int extra_vars_path: description: - Path to the C(extra_vars) YAML file. + type: path job_tags: description: - Comma separated list of the tags to use for the job template. + type: str force_handlers_enabled: description: - Enable forcing playbook handlers to run even if a task fails. @@ -80,10 +93,12 @@ options: skip_tags: description: - Comma separated list of the tags to skip for the job template. + type: str start_at_task: description: - Start the playbook at the task matching this name. version_added: 2.7 + type: str diff_mode_enabled: description: - Enable diff mode for the job template. @@ -99,6 +114,7 @@ options: host_config_key: description: - Allow provisioning callbacks using this host config key. + type: str ask_diff_mode: description: - Prompt user to enable diff mode (show changes) to files when supported by modules. @@ -171,11 +187,16 @@ options: version_added: 2.7 type: bool default: 'no' + timeout: + description: + - Maximum time in seconds to wait for a job to finish (server-side). + type: int state: description: - Desired state of the resource. default: "present" choices: ["present", "absent"] + type: str extends_documentation_fragment: awx.awx.auth notes: - JSON for survey_spec can be found in Tower API Documentation. See diff --git a/awx_collection/plugins/modules/tower_job_wait.py b/awx_collection/plugins/modules/tower_job_wait.py index 0f0ab806db..c6866db2c8 100644 --- a/awx_collection/plugins/modules/tower_job_wait.py +++ b/awx_collection/plugins/modules/tower_job_wait.py @@ -27,17 +27,21 @@ options: description: - ID of the job to monitor. required: True + type: int min_interval: description: - Minimum interval in seconds, to request an update from Tower. default: 1 + type: float max_interval: description: - Maximum interval in seconds, to request an update from Tower. default: 30 + type: float timeout: description: - Maximum time in seconds to wait for a job to finish. + type: int extends_documentation_fragment: awx.awx.auth ''' diff --git a/awx_collection/plugins/modules/tower_label.py b/awx_collection/plugins/modules/tower_label.py index 09b3b4b6dd..254d9d4986 100644 --- a/awx_collection/plugins/modules/tower_label.py +++ b/awx_collection/plugins/modules/tower_label.py @@ -27,15 +27,18 @@ options: description: - Name to use for the label. required: True + type: str organization: description: - Organization the label should be applied to. required: True + type: str state: description: - Desired state of the resource. default: "present" choices: ["present", "absent"] + type: str 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 eee30a8cd4..b583efc056 100644 --- a/awx_collection/plugins/modules/tower_notification.py +++ b/awx_collection/plugins/modules/tower_notification.py @@ -27,35 +27,43 @@ options: description: - The name of the notification. required: True + type: str description: description: - The description of the notification. required: False + type: str organization: description: - The organization the notification belongs to. required: False + type: str notification_type: description: - The type of notification to be sent. required: True choices: ["email", "slack", "twilio", "pagerduty", "hipchat", "webhook", "irc"] + type: str notification_configuration: description: - The notification configuration file. Note providing this field would disable all notification-configuration-related fields. required: False + type: str username: description: - The mail server username. Required if I(notification_type=email). required: False + type: str sender: description: - The sender email address. Required if I(notification_type=email). required: False + type: str recipients: description: - The recipients email addresses. Required if I(notification_type=email). required: False + type: list use_tls: description: - The TLS trigger. Required if I(notification_type=email). @@ -65,6 +73,7 @@ options: description: - The mail server host. Required if I(notification_type=email). required: False + type: str use_ssl: description: - The SSL trigger. Required if I(notification_type=email) or if I(notification_type=irc). @@ -74,10 +83,12 @@ options: description: - The mail server password. Required if I(notification_type=email) or if I(notification_type=irc). required: False + type: str port: description: - The mail server port. Required if I(notification_type=email) or if I(notification_type=irc). required: False + type: int channels: description: - The destination Slack channels. Required if I(notification_type=slack). @@ -87,47 +98,58 @@ options: description: - The access token. Required if I(notification_type=slack), if I(notification_type=pagerduty) or if I(notification_type=hipchat). required: False + type: str account_token: description: - The Twillio account token. Required if I(notification_type=twillio). required: False + type: str from_number: description: - The source phone number. Required if I(notification_type=twillio). required: False + type: str to_numbers: description: - The destination phone numbers. Required if I(notification_type=twillio). required: False + type: list account_sid: description: - The Twillio account SID. Required if I(notification_type=twillio). required: False + type: str subdomain: description: - The PagerDuty subdomain. Required if I(notification_type=pagerduty). required: False + type: str service_key: description: - The PagerDuty service/integration API key. Required if I(notification_type=pagerduty). required: False + type: str client_name: description: - The PagerDuty client identifier. Required if I(notification_type=pagerduty). required: False + type: str message_from: description: - The label to be shown with the notification. Required if I(notification_type=hipchat). required: False + type: str api_url: description: - The HipChat API URL. Required if I(notification_type=hipchat). required: False + type: str color: description: - The notification color. Required if I(notification_type=hipchat). required: False choices: ["yellow", "green", "red", "purple", "gray", "random"] + type: str rooms: description: - HipChat rooms to send the notification to. Required if I(notification_type=hipchat). @@ -142,18 +164,22 @@ options: description: - The target URL. Required if I(notification_type=webhook). required: False + type: str headers: description: - The HTTP headers as JSON string. Required if I(notification_type=webhook). required: False + type: dict server: description: - The IRC server address. Required if I(notification_type=irc). required: False + type: str nickname: description: - The IRC nickname. Required if I(notification_type=irc). required: False + type: str targets: description: - The destination channels or users. Required if I(notification_type=irc). @@ -164,6 +190,7 @@ options: - Desired state of the resource. default: "present" choices: ["present", "absent"] + type: str 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 7f261e2f1c..cfdbce711d 100644 --- a/awx_collection/plugins/modules/tower_organization.py +++ b/awx_collection/plugins/modules/tower_organization.py @@ -27,14 +27,17 @@ options: description: - Name to use for the organization. required: True + type: str description: description: - The description to use for the organization. + type: str state: description: - Desired state of the resource. default: "present" choices: ["present", "absent"] + type: str 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 423f63bb7f..ce18b3ae71 100644 --- a/awx_collection/plugins/modules/tower_project.py +++ b/awx_collection/plugins/modules/tower_project.py @@ -27,26 +27,33 @@ options: description: - Name to use for the project. required: True + type: str description: description: - Description to use for the project. + type: str scm_type: description: - Type of SCM resource. choices: ["manual", "git", "hg", "svn"] default: "manual" + type: str scm_url: description: - URL of SCM resource. + type: str local_path: description: - The server playbook directory for manual projects. + type: str scm_branch: description: - The branch to use for the SCM resource. + type: str scm_credential: description: - Name of the credential to use with this SCM resource. + type: str scm_clean: description: - Remove local modifications before updating. @@ -68,23 +75,28 @@ options: - Cache Timeout to cache prior project syncs for a certain number of seconds. Only valid if scm_update_on_launch is to True, otherwise ignored. default: 0 + type: int job_timeout: version_added: "2.8" description: - The amount of time (in seconds) to run before the SCM Update is canceled. A value of 0 means no timeout. default: 0 + type: int custom_virtualenv: version_added: "2.8" description: - Local absolute file path containing a custom Python virtualenv to use + type: str organization: description: - Primary key of organization for project. + type: str state: description: - Desired state of the resource. default: "present" choices: ["present", "absent"] + type: str 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 66d45da58f..1e33f7f6a3 100644 --- a/awx_collection/plugins/modules/tower_receive.py +++ b/awx_collection/plugins/modules/tower_receive.py @@ -32,46 +32,57 @@ options: description: - List of organization names to export default: [] + type: list user: description: - List of user names to export default: [] + type: list team: description: - List of team names to export default: [] + type: list credential_type: description: - List of credential type names to export default: [] + type: list credential: description: - List of credential names to export default: [] + type: list notification_template: description: - List of notification template names to export default: [] + type: list inventory_script: description: - List of inventory script names to export default: [] + type: list inventory: description: - List of inventory names to export default: [] + type: list project: description: - List of project names to export default: [] + type: list job_template: description: - List of job template names to export default: [] + type: list workflow: description: - List of workflow names to export default: [] + type: list requirements: - "ansible-tower-cli >= 3.3.0" diff --git a/awx_collection/plugins/modules/tower_role.py b/awx_collection/plugins/modules/tower_role.py index 9352827d8b..991bd426bd 100644 --- a/awx_collection/plugins/modules/tower_role.py +++ b/awx_collection/plugins/modules/tower_role.py @@ -26,38 +26,48 @@ options: user: description: - User that receives the permissions specified by the role. + type: str team: description: - Team that receives the permissions specified by the role. + type: str role: description: - The role type to grant/revoke. required: True choices: ["admin", "read", "member", "execute", "adhoc", "update", "use", "auditor", "project_admin", "inventory_admin", "credential_admin", "workflow_admin", "notification_admin", "job_template_admin"] + type: str target_team: description: - Team that the role acts on. + type: str inventory: description: - Inventory the role acts on. + type: str job_template: description: - The job template the role acts on. + type: str credential: description: - Credential the role acts on. + type: str organization: description: - Organization the role acts on. + type: str project: description: - Project the role acts on. + type: str state: description: - Desired state of the resource. default: "present" choices: ["present", "absent"] + type: str 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 eaa5b9d69f..07334d5589 100644 --- a/awx_collection/plugins/modules/tower_send.py +++ b/awx_collection/plugins/modules/tower_send.py @@ -28,16 +28,19 @@ options: - The assets to import. - This can be the output of tower_receive or loaded from a file required: False + type: str files: description: - List of files to import. required: False default: [] + type: list prevent: description: - A list of asset types to prevent import for required: false default: [] + type: list password_management: description: - The password management option to use. @@ -45,6 +48,7 @@ options: required: false default: 'default' choices: ["default", "random"] + type: str notes: - One of assets or files needs to be passed in diff --git a/awx_collection/plugins/modules/tower_settings.py b/awx_collection/plugins/modules/tower_settings.py index 8de8c2e6f9..8d0da8ed0d 100644 --- a/awx_collection/plugins/modules/tower_settings.py +++ b/awx_collection/plugins/modules/tower_settings.py @@ -27,10 +27,12 @@ options: description: - Name of setting to modify required: True + type: str value: description: - Value to be modified for given setting. required: True + type: str extends_documentation_fragment: awx.awx.auth ''' diff --git a/awx_collection/plugins/modules/tower_team.py b/awx_collection/plugins/modules/tower_team.py index 165f801b20..80aff36f04 100644 --- a/awx_collection/plugins/modules/tower_team.py +++ b/awx_collection/plugins/modules/tower_team.py @@ -27,15 +27,22 @@ options: description: - Name to use for the team. required: True + type: str + description: + description: + - The description to use for the team. + type: str organization: description: - Organization the team should be made a member of. required: True + type: str state: description: - Desired state of the resource. choices: ["present", "absent"] default: "present" + type: str 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 a5fea6d861..87e9e8f9c1 100644 --- a/awx_collection/plugins/modules/tower_user.py +++ b/awx_collection/plugins/modules/tower_user.py @@ -27,19 +27,24 @@ options: description: - The username of the user. required: True + type: str first_name: description: - First name of the user. + type: str last_name: description: - Last name of the user. + type: str email: description: - Email address of the user. required: True + type: str password: description: - Password of the user. + type: str superuser: description: - User is a system wide administrator. @@ -55,6 +60,7 @@ options: - Desired state of the resource. default: "present" choices: ["present", "absent"] + type: str requirements: - ansible-tower-cli >= 3.2.0 diff --git a/awx_collection/plugins/modules/tower_workflow_launch.py b/awx_collection/plugins/modules/tower_workflow_launch.py index 8e0c06d33c..c0bf96fef6 100644 --- a/awx_collection/plugins/modules/tower_workflow_launch.py +++ b/awx_collection/plugins/modules/tower_workflow_launch.py @@ -24,10 +24,12 @@ options: description: - The name of the workflow template to run. required: True + type: str extra_vars: description: - Any extra vars required to launch the job. required: False + type: str wait: description: - Wait for the workflow to complete. @@ -38,6 +40,7 @@ options: description: - If waiting for the workflow to complete this will abort after this amount of seconds + type: int requirements: - "python >= 2.6" diff --git a/awx_collection/plugins/modules/tower_workflow_template.py b/awx_collection/plugins/modules/tower_workflow_template.py index 3805079d01..56f85850b6 100644 --- a/awx_collection/plugins/modules/tower_workflow_template.py +++ b/awx_collection/plugins/modules/tower_workflow_template.py @@ -40,26 +40,32 @@ options: description: description: - The description to use for the workflow. + type: str extra_vars: description: - Extra variables used by Ansible in YAML or key=value format. + type: str inventory: description: - Name of the inventory to use for the job template. version_added: "2.9" + type: str name: description: - The name to use for the workflow. required: True + type: str organization: description: - The organization the workflow is linked to. + type: str schema: description: - > The schema is a JSON- or YAML-formatted string defining the hierarchy structure that connects the nodes. Refer to Tower documentation for more information. + type: str survey_enabled: description: - Setting that variable will prompt the user for job type on the @@ -68,11 +74,13 @@ options: survey: description: - The definition of the survey associated to the workflow. + type: str state: description: - Desired state of the resource. default: "present" choices: ["present", "absent"] + type: str extends_documentation_fragment: awx.awx.auth ''' From 0434c611f0d6b7644c759bb7ce913bd771cb0051 Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Tue, 22 Oct 2019 14:26:56 -0400 Subject: [PATCH 3/5] add release note --- awx_collection/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/awx_collection/README.md b/awx_collection/README.md index 31fd683c5c..1a1a1e1a62 100644 --- a/awx_collection/README.md +++ b/awx_collection/README.md @@ -8,6 +8,17 @@ inside the folder `lib/ansible/modules/web_infrastructure/ansible_tower` as well as other folders for the inventory plugin, module utils, and doc fragment. +## Release and Upgrade Notes + +The release 7.0.0 of the `awx.awx` collection is intended to be identical +to the content prior to the migration, aside from changes necessary to +have it function as a collection. + +The following notes are changes that may require changes to playbooks. + + - Specifying `inputs` or `injectors` as strings in the + `tower_credential_type` module is no longer supported. Provide as dictionaries instead. + ## Running To use this collection, the "old" tower-cli needs to be installed From b394862210d4ce42eee95977f2734324aa898480 Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Thu, 24 Oct 2019 14:58:55 -0400 Subject: [PATCH 4/5] Ignore import errors due to bugs in Ansible core --- .gitignore | 8 ++++---- awx_collection/tests/sanity/ignore-2.10.txt | 20 ++++++++++++++++++++ awx_collection/tests/sanity/ignore-2.9.txt | 20 ++++++++++++++++++++ 3 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 awx_collection/tests/sanity/ignore-2.10.txt create mode 100644 awx_collection/tests/sanity/ignore-2.9.txt diff --git a/.gitignore b/.gitignore index 60d960b66e..ac443e2acd 100644 --- a/.gitignore +++ b/.gitignore @@ -135,10 +135,10 @@ use_dev_supervisor.txt # Ansible module tests -awx_collection_test_venv/ -awx_collection/*.tar.gz -awx_collection/galaxy.yml -sanity/ +/awx_collection_test_venv/ +/awx_collection/*.tar.gz +/awx_collection/galaxy.yml +/sanity/ .idea/* *.unison.tmp diff --git a/awx_collection/tests/sanity/ignore-2.10.txt b/awx_collection/tests/sanity/ignore-2.10.txt new file mode 100644 index 0000000000..b97a2b4060 --- /dev/null +++ b/awx_collection/tests/sanity/ignore-2.10.txt @@ -0,0 +1,20 @@ +plugins/modules/tower_credential_type.py validate-modules:missing-module-utils-import +plugins/modules/tower_group.py validate-modules:missing-module-utils-import +plugins/modules/tower_host.py validate-modules:missing-module-utils-import +plugins/modules/tower_inventory.py validate-modules:missing-module-utils-import +plugins/modules/tower_inventory_source.py validate-modules:missing-module-utils-import +plugins/modules/tower_job_cancel.py validate-modules:missing-module-utils-import +plugins/modules/tower_job_launch.py validate-modules:missing-module-utils-import +plugins/modules/tower_job_list.py validate-modules:missing-module-utils-import +plugins/modules/tower_job_template.py validate-modules:missing-module-utils-import +plugins/modules/tower_label.py validate-modules:missing-module-utils-import +plugins/modules/tower_notification.py validate-modules:missing-module-utils-import +plugins/modules/tower_organization.py validate-modules:missing-module-utils-import +plugins/modules/tower_project.py validate-modules:missing-module-utils-import +plugins/modules/tower_receive.py validate-modules:missing-module-utils-import +plugins/modules/tower_role.py validate-modules:missing-module-utils-import +plugins/modules/tower_settings.py validate-modules:missing-module-utils-import +plugins/modules/tower_team.py validate-modules:missing-module-utils-import +plugins/modules/tower_user.py validate-modules:missing-module-utils-import +plugins/modules/tower_workflow_launch.py validate-modules:missing-module-utils-import +plugins/modules/tower_workflow_template.py validate-modules:missing-module-utils-import \ No newline at end of file diff --git a/awx_collection/tests/sanity/ignore-2.9.txt b/awx_collection/tests/sanity/ignore-2.9.txt new file mode 100644 index 0000000000..b97a2b4060 --- /dev/null +++ b/awx_collection/tests/sanity/ignore-2.9.txt @@ -0,0 +1,20 @@ +plugins/modules/tower_credential_type.py validate-modules:missing-module-utils-import +plugins/modules/tower_group.py validate-modules:missing-module-utils-import +plugins/modules/tower_host.py validate-modules:missing-module-utils-import +plugins/modules/tower_inventory.py validate-modules:missing-module-utils-import +plugins/modules/tower_inventory_source.py validate-modules:missing-module-utils-import +plugins/modules/tower_job_cancel.py validate-modules:missing-module-utils-import +plugins/modules/tower_job_launch.py validate-modules:missing-module-utils-import +plugins/modules/tower_job_list.py validate-modules:missing-module-utils-import +plugins/modules/tower_job_template.py validate-modules:missing-module-utils-import +plugins/modules/tower_label.py validate-modules:missing-module-utils-import +plugins/modules/tower_notification.py validate-modules:missing-module-utils-import +plugins/modules/tower_organization.py validate-modules:missing-module-utils-import +plugins/modules/tower_project.py validate-modules:missing-module-utils-import +plugins/modules/tower_receive.py validate-modules:missing-module-utils-import +plugins/modules/tower_role.py validate-modules:missing-module-utils-import +plugins/modules/tower_settings.py validate-modules:missing-module-utils-import +plugins/modules/tower_team.py validate-modules:missing-module-utils-import +plugins/modules/tower_user.py validate-modules:missing-module-utils-import +plugins/modules/tower_workflow_launch.py validate-modules:missing-module-utils-import +plugins/modules/tower_workflow_template.py validate-modules:missing-module-utils-import \ No newline at end of file From e40f29092bf6d8c15381afd6dfaaae676a42955c Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Thu, 24 Oct 2019 15:10:38 -0400 Subject: [PATCH 5/5] Fully rely on error ignoring for sanity rel imports --- Makefile | 1 - awx_collection/make_imports_absolute.yml | 17 -------------- awx_collection/tests/sanity/ignore-2.10.txt | 26 ++++++++++++++++++++- awx_collection/tests/sanity/ignore-2.9.txt | 26 ++++++++++++++++++++- 4 files changed, 50 insertions(+), 20 deletions(-) delete mode 100644 awx_collection/make_imports_absolute.yml diff --git a/Makefile b/Makefile index 55b65fa2c5..7ce3323339 100644 --- a/Makefile +++ b/Makefile @@ -403,7 +403,6 @@ test_collection_sanity: rm -rf sanity mkdir -p sanity/ansible_collections/awx cp -Ra awx_collection sanity/ansible_collections/awx/awx # symlinks do not work - cd sanity/ansible_collections/awx/awx && ansible-playbook -i localhost, make_imports_absolute.yml # hack because sanity tests do not fully work cd sanity/ansible_collections/awx/awx && git init && git add . # requires both this file structure and a git repo, so there you go cd sanity/ansible_collections/awx/awx && ansible-test sanity --test validate-modules diff --git a/awx_collection/make_imports_absolute.yml b/awx_collection/make_imports_absolute.yml deleted file mode 100644 index 184019ea2b..0000000000 --- a/awx_collection/make_imports_absolute.yml +++ /dev/null @@ -1,17 +0,0 @@ -- hosts: localhost - gather_facts: false - connection: local - - tasks: - - name: Find all module files - find: - paths: "{{ playbook_dir }}/plugins/modules" - patterns: "*.py" - register: module_files - - - name: Change module_utils imports to absolute namespace and package names - replace: - path: "{{ item.path }}" - regexp: '^from ..module_utils.ansible_tower' - replace: 'from ansible_collections.awx.awx.plugins.module_utils.ansible_tower' - with_items: "{{ module_files.files }}" diff --git a/awx_collection/tests/sanity/ignore-2.10.txt b/awx_collection/tests/sanity/ignore-2.10.txt index b97a2b4060..4d3942ddf0 100644 --- a/awx_collection/tests/sanity/ignore-2.10.txt +++ b/awx_collection/tests/sanity/ignore-2.10.txt @@ -17,4 +17,28 @@ plugins/modules/tower_settings.py validate-modules:missing-module-utils-import plugins/modules/tower_team.py validate-modules:missing-module-utils-import plugins/modules/tower_user.py validate-modules:missing-module-utils-import plugins/modules/tower_workflow_launch.py validate-modules:missing-module-utils-import -plugins/modules/tower_workflow_template.py validate-modules:missing-module-utils-import \ No newline at end of file +plugins/modules/tower_workflow_template.py validate-modules:missing-module-utils-import +plugins/modules/tower_credential_type.py validate-modules:import-error +plugins/modules/tower_credential.py validate-modules:import-error +plugins/modules/tower_group.py validate-modules:import-error +plugins/modules/tower_host.py validate-modules:import-error +plugins/modules/tower_inventory.py validate-modules:import-error +plugins/modules/tower_inventory_source.py validate-modules:import-error +plugins/modules/tower_job_cancel.py validate-modules:import-error +plugins/modules/tower_job_launch.py validate-modules:import-error +plugins/modules/tower_job_list.py validate-modules:import-error +plugins/modules/tower_job_wait.py validate-modules:import-error +plugins/modules/tower_job_template.py validate-modules:import-error +plugins/modules/tower_label.py validate-modules:import-error +plugins/modules/tower_notification.py validate-modules:import-error +plugins/modules/tower_organization.py validate-modules:import-error +plugins/modules/tower_project.py validate-modules:import-error +plugins/modules/tower_receive.py validate-modules:import-error +plugins/modules/tower_role.py validate-modules:import-error +plugins/modules/tower_settings.py validate-modules:import-error +plugins/modules/tower_send.py validate-modules:import-error +plugins/modules/tower_team.py validate-modules:import-error +plugins/modules/tower_user.py validate-modules:import-error +plugins/modules/tower_workflow_launch.py validate-modules:import-error +plugins/modules/tower_workflow_template.py validate-modules:import-error +plugins/modules/tower_workflow_job_template.py validate-modules:import-error \ No newline at end of file diff --git a/awx_collection/tests/sanity/ignore-2.9.txt b/awx_collection/tests/sanity/ignore-2.9.txt index b97a2b4060..4d3942ddf0 100644 --- a/awx_collection/tests/sanity/ignore-2.9.txt +++ b/awx_collection/tests/sanity/ignore-2.9.txt @@ -17,4 +17,28 @@ plugins/modules/tower_settings.py validate-modules:missing-module-utils-import plugins/modules/tower_team.py validate-modules:missing-module-utils-import plugins/modules/tower_user.py validate-modules:missing-module-utils-import plugins/modules/tower_workflow_launch.py validate-modules:missing-module-utils-import -plugins/modules/tower_workflow_template.py validate-modules:missing-module-utils-import \ No newline at end of file +plugins/modules/tower_workflow_template.py validate-modules:missing-module-utils-import +plugins/modules/tower_credential_type.py validate-modules:import-error +plugins/modules/tower_credential.py validate-modules:import-error +plugins/modules/tower_group.py validate-modules:import-error +plugins/modules/tower_host.py validate-modules:import-error +plugins/modules/tower_inventory.py validate-modules:import-error +plugins/modules/tower_inventory_source.py validate-modules:import-error +plugins/modules/tower_job_cancel.py validate-modules:import-error +plugins/modules/tower_job_launch.py validate-modules:import-error +plugins/modules/tower_job_list.py validate-modules:import-error +plugins/modules/tower_job_wait.py validate-modules:import-error +plugins/modules/tower_job_template.py validate-modules:import-error +plugins/modules/tower_label.py validate-modules:import-error +plugins/modules/tower_notification.py validate-modules:import-error +plugins/modules/tower_organization.py validate-modules:import-error +plugins/modules/tower_project.py validate-modules:import-error +plugins/modules/tower_receive.py validate-modules:import-error +plugins/modules/tower_role.py validate-modules:import-error +plugins/modules/tower_settings.py validate-modules:import-error +plugins/modules/tower_send.py validate-modules:import-error +plugins/modules/tower_team.py validate-modules:import-error +plugins/modules/tower_user.py validate-modules:import-error +plugins/modules/tower_workflow_launch.py validate-modules:import-error +plugins/modules/tower_workflow_template.py validate-modules:import-error +plugins/modules/tower_workflow_job_template.py validate-modules:import-error \ No newline at end of file