From f45b00f9817336b2d10759ba74868f0246bbcef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Aragon=C3=A9s=20Muniesa?= <26822043+ivarmu@users.noreply.github.com> Date: Wed, 1 Nov 2023 01:32:17 +0100 Subject: [PATCH] Added role to host global vars to all other roles. Updated tasks tittles to solve issue707 (#716) --- .ansible-lint-ignore | 2 + EXPORT_README.md | 2 +- plugins/lookup/controller_object_diff.py | 3 +- plugins/modules/controller_export_diff.py | 2 +- roles/applications/README.md | 2 +- roles/applications/meta/main.yml | 7 +- roles/applications/tasks/main.yml | 8 +- roles/credential_input_sources/README.md | 2 +- roles/credential_input_sources/meta/main.yml | 7 +- roles/credential_input_sources/tasks/main.yml | 8 +- roles/credential_types/README.md | 2 +- roles/credential_types/meta/main.yml | 7 +- roles/credential_types/tasks/main.yml | 8 +- roles/credentials/README.md | 2 +- roles/credentials/meta/main.yml | 7 +- roles/credentials/tasks/main.yml | 12 ++- roles/dispatch/tasks/main.yml | 2 +- roles/execution_environments/README.md | 2 +- roles/execution_environments/meta/main.yml | 7 +- roles/execution_environments/tasks/main.yml | 16 +-- .../current_notification_templates.j2 | 2 +- roles/global_vars/README.md | 45 +++++++++ roles/global_vars/defaults/main.yml | 10 ++ roles/global_vars/meta/main.yml | 54 +++++++++++ roles/global_vars/vars/main.yml | 3 + roles/groups/README.md | 2 +- roles/groups/meta/main.yml | 7 +- roles/groups/tasks/main.yml | 30 +++--- roles/hosts/README.md | 2 +- roles/hosts/meta/main.yml | 7 +- roles/hosts/tasks/main.yml | 14 ++- roles/instance_groups/README.md | 2 +- roles/instance_groups/meta/main.yml | 7 +- roles/instance_groups/tasks/main.yml | 27 +++--- roles/instances/tasks/main.yml | 8 +- roles/inventories/README.md | 2 +- roles/inventories/meta/main.yml | 5 + roles/inventories/tasks/main.yml | 22 +++-- roles/inventory_sources/README.md | 2 +- roles/inventory_sources/meta/main.yml | 5 + roles/inventory_sources/tasks/main.yml | 50 +++++----- roles/job_templates/README.md | 2 +- roles/job_templates/meta/main.yml | 7 +- roles/job_templates/tasks/main.yml | 97 ++++++++++--------- roles/labels/README.md | 2 +- roles/labels/meta/main.yml | 5 + roles/labels/tasks/main.yml | 8 +- roles/license/tasks/subscription.yml | 2 +- roles/notification_templates/README.md | 2 +- roles/notification_templates/meta/main.yml | 7 +- roles/notification_templates/tasks/main.yml | 16 +-- roles/object_diff/tasks/roles.yml | 4 - roles/organizations/README.md | 2 +- roles/organizations/meta/main.yml | 7 +- roles/organizations/tasks/main.yml | 22 +++-- roles/projects/README.md | 2 +- roles/projects/meta/main.yml | 7 +- roles/projects/tasks/main.yml | 46 +++++---- roles/roles/README.md | 2 +- roles/roles/meta/main.yml | 7 +- roles/roles/tasks/main.yml | 30 +++--- roles/schedules/README.md | 2 +- roles/schedules/meta/main.yml | 7 +- roles/schedules/tasks/main.yml | 32 +++--- roles/teams/README.md | 2 +- roles/teams/meta/main.yml | 7 +- roles/teams/tasks/main.yml | 10 +- roles/users/README.md | 2 +- roles/users/meta/main.yml | 7 +- roles/users/tasks/main.yml | 16 +-- roles/workflow_job_templates/README.md | 2 +- roles/workflow_job_templates/meta/main.yml | 7 +- .../tasks/add_workflows_schema.yml | 4 +- roles/workflow_job_templates/tasks/main.yml | 61 ++++++------ tests/configure_controller.yml | 2 +- .../templated_role_example/defaults/main.yml | 2 +- 76 files changed, 535 insertions(+), 319 deletions(-) create mode 100644 .ansible-lint-ignore create mode 100644 roles/global_vars/README.md create mode 100644 roles/global_vars/defaults/main.yml create mode 100644 roles/global_vars/meta/main.yml create mode 100644 roles/global_vars/vars/main.yml diff --git a/.ansible-lint-ignore b/.ansible-lint-ignore new file mode 100644 index 000000000..b13484a1d --- /dev/null +++ b/.ansible-lint-ignore @@ -0,0 +1,2 @@ +plugins/lookup/controller_object_diff.py yaml[document-end] +plugins/modules/controller_export_diff.py yaml[document-end] diff --git a/EXPORT_README.md b/EXPORT_README.md index 0a85a767b..b63fa3aa1 100644 --- a/EXPORT_README.md +++ b/EXPORT_README.md @@ -50,7 +50,7 @@ awx export --conf.host https://localhost --conf.username admin --conf.password * - name: Export projects to file ansible.builtin.copy: - content: "{{ export_results | to_nice_yaml( width=50, explicit_start=True, explicit_end=True) }}" + content: "{{ export_results | to_nice_yaml(width=50, explicit_start=True, explicit_end=True) }}" dest: projects.yaml ... ``` diff --git a/plugins/lookup/controller_object_diff.py b/plugins/lookup/controller_object_diff.py index b9926cea1..47b5821a8 100644 --- a/plugins/lookup/controller_object_diff.py +++ b/plugins/lookup/controller_object_diff.py @@ -69,14 +69,13 @@ set_fact: project_difference: "{{ query('infra.controller_configuration.controller_object_diff', api_list=controller_api_results, compare_list=differential_item.differential_test_items, - with_present=true, set_absent=true ) }}" + with_present=true, set_absent=true) }}" - name: Add Projects include_role: name: infra.controller_configuration.projects vars: controller_projects: "{{ project_difference }}" - """ RETURN = """ diff --git a/plugins/modules/controller_export_diff.py b/plugins/modules/controller_export_diff.py index 4150267ef..4b0b0d344 100644 --- a/plugins/modules/controller_export_diff.py +++ b/plugins/modules/controller_export_diff.py @@ -192,7 +192,7 @@ scm_url: https://github.com/ansible/ansible-examples.git description: ansible-examples organization: - name: Satellite + name: Satellite credential: gitlab-personal-access-token for satqe_auto_droid wait: false controller_host: https://controller diff --git a/roles/applications/README.md b/roles/applications/README.md index a37f682f6..68c69d618 100644 --- a/roles/applications/README.md +++ b/roles/applications/README.md @@ -2,7 +2,7 @@ ## Description -An Ansible Role to create Applications on Ansible Controller. +An Ansible Role to create/update/remove Applications on Ansible Controller. ## Requirements diff --git a/roles/applications/meta/main.yml b/roles/applications/meta/main.yml index 391b3f678..44b002e81 100644 --- a/roles/applications/meta/main.yml +++ b/roles/applications/meta/main.yml @@ -41,7 +41,8 @@ collections: - ansible.controller - awx.awx -dependencies: [] -# List your role dependencies here, one per line. Be sure to remove the '[]' above, -# if you add dependencies to this list. +dependencies: + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. + - role: global_vars ... diff --git a/roles/applications/tasks/main.yml b/roles/applications/tasks/main.yml index 43394d54f..ad046c9f8 100644 --- a/roles/applications/tasks/main.yml +++ b/roles/applications/tasks/main.yml @@ -1,6 +1,6 @@ --- # Create Controller applications -- name: Add Controller Applications +- name: "Managing Controller Applications" application: name: "{{ __application_item.name | mandatory }}" new_name: "{{ __application_item.new_name | default(omit, true) }}" @@ -23,15 +23,17 @@ loop: "{{ applications if applications is defined else controller_applications }}" loop_control: loop_var: "__application_item" + label: "{{ __operation.verb }} Controller Application {{ __application_item.name }}" no_log: "{{ controller_configuration_applications_secure_logging }}" async: 1000 poll: 0 register: __applications_job_async changed_when: not __applications_job_async.changed vars: + __operation: "{{ operation_translate[__application_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' -- name: "Create Applications | Wait for finish the Applications creation" +- name: "Managing Controller Applications | Wait for finish the Application management" ansible.builtin.async_status: jid: "{{ __applications_job_async_results_item.ansible_job_id }}" register: __applications_job_async_result @@ -41,8 +43,10 @@ loop: "{{ __applications_job_async.results }}" loop_control: loop_var: __applications_job_async_results_item + label: "{{ __operation.verb }} Controller Application {{ __applications_job_async_results_item.__application_item.name }} | Wait for finish the Application {{ __operation.action }}" when: __applications_job_async_results_item.ansible_job_id is defined no_log: "{{ controller_configuration_applications_secure_logging }}" vars: + __operation: "{{ operation_translate[__applications_job_async_results_item.__application_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' ... diff --git a/roles/credential_input_sources/README.md b/roles/credential_input_sources/README.md index d74ad2bbd..963f34f4c 100644 --- a/roles/credential_input_sources/README.md +++ b/roles/credential_input_sources/README.md @@ -2,7 +2,7 @@ ## Description -An Ansible Role to create credential input sources on Ansible Controller, the below example is for CyberArk as an input source, change accordingly to match your input source type. +An Ansible Role to create/update/remove credential input sources on Ansible Controller, the below example is for CyberArk as an input source, change accordingly to match your input source type. ## Requirements diff --git a/roles/credential_input_sources/meta/main.yml b/roles/credential_input_sources/meta/main.yml index 444fdf8fb..c4c085400 100644 --- a/roles/credential_input_sources/meta/main.yml +++ b/roles/credential_input_sources/meta/main.yml @@ -45,7 +45,8 @@ collections: - ansible.controller - awx.awx -dependencies: [] -# List your role dependencies here, one per line. Be sure to remove the '[]' above, -# if you add dependencies to this list. +dependencies: + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. + - role: global_vars ... diff --git a/roles/credential_input_sources/tasks/main.yml b/roles/credential_input_sources/tasks/main.yml index c5e6139ad..854718ade 100644 --- a/roles/credential_input_sources/tasks/main.yml +++ b/roles/credential_input_sources/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: Add Controller Credential Input Sources +- name: "Managing Controller Credential Input Sources" credential_input_source: target_credential: "{{ __cred_input_src_item.target_credential | mandatory }}" input_field_name: "{{ __cred_input_src_item.input_field_name | mandatory }}" @@ -19,15 +19,17 @@ loop: "{{ controller_credential_input_sources }}" loop_control: loop_var: "__cred_input_src_item" + label: "{{ __operation.verb }} Controller Credential Input Source for Credential {{ __cred_input_src_item.target_credential }}" no_log: "{{ controller_configuration_credential_input_sources_secure_logging }}" async: 1000 poll: 0 register: __credential_input_sources_job_async changed_when: not __credential_input_sources_job_async.changed vars: + __operation: "{{ operation_translate[__cred_input_src_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' -- name: "Create Controller Credential Input Sources | Wait for finish the Controller Credential Input Sources creation" +- name: "Managing Controller Credential Input Sources | Wait for finish the Controller Credential Input Sources management" ansible.builtin.async_status: jid: "{{ __credential_input_sources_job_async_results_item.ansible_job_id }}" register: __credential_input_sources_job_async_result @@ -37,8 +39,10 @@ loop: "{{ __credential_input_sources_job_async.results }}" loop_control: loop_var: __credential_input_sources_job_async_results_item + label: "{{ __operation.verb }} Controller Credential Input Source for Credential {{ __credential_input_sources_job_async_results_item.__cred_input_src_item.target_credential }}" when: __credential_input_sources_job_async_results_item.ansible_job_id is defined no_log: "{{ controller_configuration_credential_input_sources_secure_logging }}" vars: + __operation: "{{ operation_translate[__credential_input_sources_job_async_results_item.__cred_input_src_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' ... diff --git a/roles/credential_types/README.md b/roles/credential_types/README.md index 8cb81cac8..0443f91a8 100644 --- a/roles/credential_types/README.md +++ b/roles/credential_types/README.md @@ -2,7 +2,7 @@ ## Description -An Ansible Role to create Credential Types on Ansible Controller. +An Ansible Role to create/update/remove Credential Types on Ansible Controller. ## Requirements diff --git a/roles/credential_types/meta/main.yml b/roles/credential_types/meta/main.yml index ea9933c0e..8617a76d0 100644 --- a/roles/credential_types/meta/main.yml +++ b/roles/credential_types/meta/main.yml @@ -40,7 +40,8 @@ collections: - ansible.controller - awx.awx -dependencies: [] -# List your role dependencies here, one per line. Be sure to remove the '[]' above, -# if you add dependencies to this list. +dependencies: + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. + - role: global_vars ... diff --git a/roles/credential_types/tasks/main.yml b/roles/credential_types/tasks/main.yml index 21f085af4..9b09bab67 100644 --- a/roles/credential_types/tasks/main.yml +++ b/roles/credential_types/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: Add Credential Types +- name: "Managing Credential Types" credential_type: name: "{{ __controller_credential_type_item.name | mandatory }}" new_name: "{{ __controller_credential_type_item.new_name | default(omit, true) }}" @@ -20,15 +20,17 @@ loop: "{{ credential_types if credential_types is defined else controller_credential_types }}" loop_control: loop_var: __controller_credential_type_item + label: "{{ __operation.verb }} Credential Type {{ __controller_credential_type_item.name }}" no_log: "{{ controller_configuration_credential_types_secure_logging }}" async: 1000 poll: 0 register: __credentialtypes_job_async changed_when: not __credentialtypes_job_async.changed vars: + __operation: "{{ operation_translate[__controller_credential_type_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' -- name: "Configure Controller Credential Types | Wait for finish the credential types creation" +- name: "Managing Controller Credential Types | Wait for finish the credential types management" ansible.builtin.async_status: jid: "{{ __credentialtypes_job_async_result_item.ansible_job_id }}" register: __credentialtypes_job_async_result @@ -38,8 +40,10 @@ loop: "{{ __credentialtypes_job_async.results }}" loop_control: loop_var: __credentialtypes_job_async_result_item + label: "{{ __operation.verb }} Controller Credential Type {{ __credentialtypes_job_async_result_item }} | Wait for finish the credential type {{ __operation.action }}" when: __credentialtypes_job_async_result_item.ansible_job_id is defined no_log: "{{ controller_configuration_credential_types_secure_logging }}" vars: + __operation: "{{ operation_translate[__credentialtypes_job_async_result_item.__controller_credential_type_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' ... diff --git a/roles/credentials/README.md b/roles/credentials/README.md index dfc307380..4a7c61fd6 100644 --- a/roles/credentials/README.md +++ b/roles/credentials/README.md @@ -2,7 +2,7 @@ ## Description -An Ansible Role to create Credentials on Ansible Controller. +An Ansible Role to create/update/remove Credentials on Ansible Controller. ## Requirements diff --git a/roles/credentials/meta/main.yml b/roles/credentials/meta/main.yml index 96e0f7f84..a3ab27bfb 100644 --- a/roles/credentials/meta/main.yml +++ b/roles/credentials/meta/main.yml @@ -40,7 +40,8 @@ collections: - ansible.controller - awx.awx -dependencies: [] -# List your role dependencies here, one per line. Be sure to remove the '[]' above, -# if you add dependencies to this list. +dependencies: + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. + - role: global_vars ... diff --git a/roles/credentials/tasks/main.yml b/roles/credentials/tasks/main.yml index 108fc691d..810c09a43 100644 --- a/roles/credentials/tasks/main.yml +++ b/roles/credentials/tasks/main.yml @@ -1,12 +1,12 @@ --- -- name: Add Credentials +- name: "Managing Credentials" credential: name: "{{ __controller_credentials_item.name | mandatory }}" new_name: "{{ __controller_credentials_item.new_name | default(omit, true) }}" copy_from: "{{ __controller_credentials_item.copy_from | default(omit, true) }}" description: "{{ __controller_credentials_item.description | default(('' if controller_configuration_credentials_enforce_defaults else omit), true) }}" organization: "{{ __controller_credentials_item.organization.name | default(__controller_credentials_item.organization | default(('' if controller_configuration_credentials_enforce_defaults else omit), true)) }}" - credential_type: "{{ __controller_credentials_item.credential_type.name | default(__controller_credentials_item.credential_type | mandatory ) }}" + credential_type: "{{ __controller_credentials_item.credential_type.name | default(__controller_credentials_item.credential_type | mandatory) }}" inputs: "{{ __controller_credentials_item.inputs | default(({} if controller_configuration_credentials_enforce_defaults else omit), true) }}" user: "{{ __controller_credentials_item.user.username | default(__controller_credentials_item.user | default(('' if controller_configuration_credentials_enforce_defaults else omit), true)) }}" team: "{{ __controller_credentials_item.team.name | default(__controller_credentials_item.team | default(('' if controller_configuration_credentials_enforce_defaults else omit), true)) }}" @@ -23,16 +23,17 @@ loop: "{{ credentials if credentials is defined else controller_credentials }}" loop_control: loop_var: __controller_credentials_item - label: "{{ __controller_credentials_item.name | mandatory }}" + label: "{{ __operation.verb }} Credential {{ __controller_credentials_item.name }}" no_log: "{{ controller_configuration_credentials_secure_logging }}" async: 1000 poll: 0 register: __credentials_job_async changed_when: not __credentials_job_async.changed vars: + __operation: "{{ operation_translate[__controller_credentials_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' -- name: "Configure Controller Credentials | Wait for finish the credential creation" +- name: "Managing Controller Credentials | Wait for finish the credential management" ansible.builtin.async_status: jid: "{{ __credentials_job_async_results_item.ansible_job_id }}" register: __credentials_job_async_result @@ -42,9 +43,10 @@ loop: "{{ __credentials_job_async.results }}" loop_control: loop_var: __credentials_job_async_results_item - label: "{{ __credentials_job_async_results_item.__controller_credentials_item.name }}" + label: "{{ __operation.verb }} Credential {{ __credentials_job_async_results_item.__controller_credentials_item.name }} | Wait for finish the credential {{ __operation.action }}" when: __credentials_job_async_results_item.ansible_job_id is defined no_log: "{{ controller_configuration_credentials_secure_logging }}" vars: + __operation: "{{ operation_translate[__controller_credentials_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' ... diff --git a/roles/dispatch/tasks/main.yml b/roles/dispatch/tasks/main.yml index 0a0273087..34a25fba0 100644 --- a/roles/dispatch/tasks/main.yml +++ b/roles/dispatch/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: "Run infra.controller_configuration.{{ __role.role }}" +- name: "Run the following infra.controller_configuration roles: {{ controller_configuration_dispatcher_roles | map(attribute='role') | join(', ') }}" ansible.builtin.include_role: name: "{{ __role.role }}" apply: diff --git a/roles/execution_environments/README.md b/roles/execution_environments/README.md index d37728813..268bfdb5b 100644 --- a/roles/execution_environments/README.md +++ b/roles/execution_environments/README.md @@ -2,7 +2,7 @@ ## Description -An Ansible Role to create execution_environments on Ansible Controller. +An Ansible Role to create/update/remove execution_environments on Ansible Controller. ## Requirements diff --git a/roles/execution_environments/meta/main.yml b/roles/execution_environments/meta/main.yml index a4b64a4f5..921f946cd 100644 --- a/roles/execution_environments/meta/main.yml +++ b/roles/execution_environments/meta/main.yml @@ -41,7 +41,8 @@ collections: - ansible.controller - awx.awx -dependencies: [] -# List your role dependencies here, one per line. Be sure to remove the '[]' above, -# if you add dependencies to this list. +dependencies: + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. + - role: global_vars ... diff --git a/roles/execution_environments/tasks/main.yml b/roles/execution_environments/tasks/main.yml index 0012b2861..85c509091 100644 --- a/roles/execution_environments/tasks/main.yml +++ b/roles/execution_environments/tasks/main.yml @@ -1,14 +1,14 @@ --- # Create Controller Execution Environments -- name: Add Controller Execution Environments +- name: "Managing Controller Execution Environments" execution_environment: name: "{{ __execution_environments_item.name | mandatory }}" new_name: "{{ __execution_environments_item.new_name | default(omit, true) }}" - description: "{{ __execution_environments_item.description | default(( '' if controller_configuration_execution_environments_enforce_defaults else omit), true) }}" + description: "{{ __execution_environments_item.description | default(('' if controller_configuration_execution_environments_enforce_defaults else omit), true) }}" image: "{{ __execution_environments_item.image | mandatory }}" - organization: "{{ __execution_environments_item.organization.name | default(__execution_environments_item.organization | default(( '' if controller_configuration_execution_environments_enforce_defaults else omit), true)) }}" - credential: "{{ __execution_environments_item.credential | default(( '' if controller_configuration_execution_environments_enforce_defaults else omit), true) }}" - pull: "{{ __execution_environments_item.pull | default(( 'missing' if controller_configuration_execution_environments_enforce_defaults else omit), true) }}" + organization: "{{ __execution_environments_item.organization.name | default(__execution_environments_item.organization | default(('' if controller_configuration_execution_environments_enforce_defaults else omit), true)) }}" + credential: "{{ __execution_environments_item.credential | default(('' if controller_configuration_execution_environments_enforce_defaults else omit), true) }}" + pull: "{{ __execution_environments_item.pull | default(('missing' if controller_configuration_execution_environments_enforce_defaults else omit), true) }}" state: "{{ __execution_environments_item.state | default(controller_state | default('present')) }}" # Role specific options @@ -22,6 +22,7 @@ loop: "{{ execution_environments if execution_environments is defined else controller_execution_environments }}" loop_control: loop_var: "__execution_environments_item" + label: "{{ __operation.verb }} Controller Execution Environment {{ __execution_environments_item }}" no_log: "{{ controller_configuration_execution_environments_secure_logging }}" when: controller_execution_environments is defined async: 1000 @@ -29,9 +30,10 @@ register: __execution_environments_job_async changed_when: not __execution_environments_job_async.changed vars: + __operation: "{{ operation_translate[__execution_environments_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' -- name: "Create Controller Execution Environments | Wait for finish the Controller Execution Environments creation" +- name: "Managing Controller Execution Environments | Wait for finish the Controller Execution Environments management" ansible.builtin.async_status: jid: "{{ __execution_environments_job_async_results_item.ansible_job_id }}" register: __execution_environments_job_async_result @@ -41,8 +43,10 @@ loop: "{{ __execution_environments_job_async.results }}" loop_control: loop_var: __execution_environments_job_async_results_item + label: "{{ __operation.verb }} Controller Execution Environment {{ __execution_environments_job_async_results_item.__execution_environments_item.name }} | Wait for finish the Controller Execution Environment {{ __operation.action }}" when: __execution_environments_job_async_results_item.ansible_job_id is defined no_log: "{{ controller_configuration_execution_environments_secure_logging }}" vars: + __operation: "{{ operation_translate[__execution_environments_job_async_results_item.__execution_environments_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' ... diff --git a/roles/filetree_create/templates/current_notification_templates.j2 b/roles/filetree_create/templates/current_notification_templates.j2 index 18008c56a..c98d04497 100644 --- a/roles/filetree_create/templates/current_notification_templates.j2 +++ b/roles/filetree_create/templates/current_notification_templates.j2 @@ -12,7 +12,7 @@ controller_notifications: {% elif (value | lower) is match('true') or (value | lower) is match('false') %} {{ key }}: {{ value | bool }} {% else %} - {{ key }}: {{ '!unsafe ' if ( value | regex_search('{{')) }}"{{ value | replace('\n','\\n') | replace('"', '\\"') }}" + {{ key }}: {{ '!unsafe ' if (value | regex_search('{{')) }}"{{ value | replace('\n','\\n') | replace('"', '\\"') }}" {% endif %} {% endfor %} {% if current_notification_templates_asset_value.messages is defined and current_notification_templates_asset_value.messages %} diff --git a/roles/global_vars/README.md b/roles/global_vars/README.md new file mode 100644 index 000000000..2c9106280 --- /dev/null +++ b/roles/global_vars/README.md @@ -0,0 +1,45 @@ +# controller_configuration.global_vars + +## Description + +An ansible role to define global variables that will be available to all of the +roles in the collection, if they are configured as follows: + +```console +# tail -4 meta/main.yml + +dependencies: +# List your role dependencies here, one per line. Be sure to remove the '[]' above, +# if you add dependencies to this list. + - global_vars +``` + +## Provided Variables + +This is currently providing the following variables: + +| Variable Name | Default Value | Required | Description | +|:---|:---:|:---:|:---| +| `operation_translate` | [See the default value below](#operation_translate-default-value) | Yes | Provides translation from object states to human interpretation | + +### operation_translate Default value + +```yaml +--- +operation_translate: + present: + verb: "Create/Update" + action: "creation" + absent: + verb: "Remove" + action: "deletion" +... +``` + +## License + +[MIT](https://github.com/redhat-cop/controller_configuration#licensing) + +## Author + +[Ivan Aragonés](https://github.com/ivarmu) diff --git a/roles/global_vars/defaults/main.yml b/roles/global_vars/defaults/main.yml new file mode 100644 index 000000000..1abfda9ab --- /dev/null +++ b/roles/global_vars/defaults/main.yml @@ -0,0 +1,10 @@ +--- +# defaults file for global_vars +operation_translate: + present: + verb: "Create/Update" + action: "creation" + absent: + verb: "Remove" + action: "deletion" +... diff --git a/roles/global_vars/meta/main.yml b/roles/global_vars/meta/main.yml new file mode 100644 index 000000000..eb87d9e61 --- /dev/null +++ b/roles/global_vars/meta/main.yml @@ -0,0 +1,54 @@ +--- +galaxy_info: + author: "Ivan Aragonés" + description: "Global variables to be consumed by any other role in the collection" + company: "Red Hat" + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: MIT + + min_ansible_version: "2.1" + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] +# List your role dependencies here, one per line. Be sure to remove the '[]' above, +# if you add dependencies to this list. +... diff --git a/roles/global_vars/vars/main.yml b/roles/global_vars/vars/main.yml new file mode 100644 index 000000000..3e4311bb5 --- /dev/null +++ b/roles/global_vars/vars/main.yml @@ -0,0 +1,3 @@ +--- +# vars file for global_vars +... diff --git a/roles/groups/README.md b/roles/groups/README.md index de6e6c810..4153ceabc 100644 --- a/roles/groups/README.md +++ b/roles/groups/README.md @@ -2,7 +2,7 @@ ## Description -An Ansible Role to create Groups on Ansible Controller. +An Ansible Role to create/update/remove Groups on Ansible Controller. ## Requirements diff --git a/roles/groups/meta/main.yml b/roles/groups/meta/main.yml index c5464bb13..33ea29973 100644 --- a/roles/groups/meta/main.yml +++ b/roles/groups/meta/main.yml @@ -40,7 +40,8 @@ collections: - ansible.controller - awx.awx -dependencies: [] -# List your role dependencies here, one per line. Be sure to remove the '[]' above, -# if you add dependencies to this list. +dependencies: + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. + - role: global_vars ... diff --git a/roles/groups/tasks/main.yml b/roles/groups/tasks/main.yml index dd7fb126f..3a1a77e87 100644 --- a/roles/groups/tasks/main.yml +++ b/roles/groups/tasks/main.yml @@ -1,18 +1,18 @@ --- # The group module is also an ansible.builtin module, but due to supporting both the awx.awx and automation.controller collections # the FQCN cannot be used here. -- name: Add controller group # noqa fqcn[action-core] +- name: "Managing Controller Groups" # noqa fqcn[action-core] group: - name: "{{ controller_groups_item.name | mandatory }}" - new_name: "{{ controller_groups_item.new_name | default(omit, true) }}" - description: "{{ controller_groups_item.description | default(( '' if controller_configuration_groups_enforce_defaults else omit), true) }}" - inventory: "{{ controller_groups_item.inventory | mandatory }}" - variables: "{{ controller_groups_item.variables | default(( {} if controller_configuration_groups_enforce_defaults else omit), true) | regex_replace('[ ]{2,}', '') }}" - hosts: "{{ controller_groups_item.hosts | default(( [] if controller_configuration_groups_enforce_defaults else omit), true) }}" - children: "{{ controller_groups_item.children | default(( [] if controller_configuration_groups_enforce_defaults else omit), true) }}" - preserve_existing_hosts: "{{ controller_groups_item.preserve_existing_hosts | default(( false if controller_configuration_groups_enforce_defaults else omit)) }}" - preserve_existing_children: "{{ controller_groups_item.preserve_existing_children | default(( false if controller_configuration_groups_enforce_defaults else omit)) }}" - state: "{{ controller_groups_item.state | default(controller_state | default('present')) }}" + name: "{{ __controller_groups_item.name | mandatory }}" + new_name: "{{ __controller_groups_item.new_name | default(omit, true) }}" + description: "{{ __controller_groups_item.description | default(('' if controller_configuration_groups_enforce_defaults else omit), true) }}" + inventory: "{{ __controller_groups_item.inventory | mandatory }}" + variables: "{{ __controller_groups_item.variables | default(({} if controller_configuration_groups_enforce_defaults else omit), true) | regex_replace('[ ]{2,}', '') }}" + hosts: "{{ __controller_groups_item.hosts | default(([] if controller_configuration_groups_enforce_defaults else omit), true) }}" + children: "{{ __controller_groups_item.children | default(([] if controller_configuration_groups_enforce_defaults else omit), true) }}" + preserve_existing_hosts: "{{ __controller_groups_item.preserve_existing_hosts | default((false if controller_configuration_groups_enforce_defaults else omit)) }}" + preserve_existing_children: "{{ __controller_groups_item.preserve_existing_children | default((false if controller_configuration_groups_enforce_defaults else omit)) }}" + state: "{{ __controller_groups_item.state | default(controller_state | default('present')) }}" # Role Standard Options controller_username: "{{ controller_username | default(omit, true) }}" @@ -24,16 +24,18 @@ validate_certs: "{{ controller_validate_certs | default(omit) }}" loop: "{{ controller_groups }}" loop_control: - loop_var: controller_groups_item + loop_var: __controller_groups_item + label: "{{ __operation.verb }} Controller Group {{ __controller_groups_item.name }}" no_log: "{{ controller_configuration_group_secure_logging }}" async: 1000 poll: 0 register: __group_job_async changed_when: not __group_job_async.changed vars: + __operation: "{{ operation_translate[__controller_groups_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' -- name: "Create Controller Group | Wait for finish the Controller Group creation" +- name: "Managing Controller Groups | Wait for finish the Controller Groups management" ansible.builtin.async_status: jid: "{{ __group_job_async_results_item.ansible_job_id }}" register: __group_job_async_result @@ -43,8 +45,10 @@ loop: "{{ __group_job_async.results }}" loop_control: loop_var: __group_job_async_results_item + label: "{{ __operation.verb }} Controller Group {{ __group_job_async_results_item.__controller_groups_item.name }} | Wait for finish the Controller Group {{ __operation.action }}" when: __group_job_async_results_item.ansible_job_id is defined no_log: "{{ controller_configuration_group_secure_logging }}" vars: + __operation: "{{ operation_translate[__group_job_async_results_item.__controller_groups_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' ... diff --git a/roles/hosts/README.md b/roles/hosts/README.md index 1cf4357df..eade78f2f 100644 --- a/roles/hosts/README.md +++ b/roles/hosts/README.md @@ -2,7 +2,7 @@ ## Description -An Ansible Role to add hosts on Ansible Controller. +An Ansible Role to add/update/remove hosts on Ansible Controller. ## Requirements diff --git a/roles/hosts/meta/main.yml b/roles/hosts/meta/main.yml index 445ed9941..6a95ef857 100644 --- a/roles/hosts/meta/main.yml +++ b/roles/hosts/meta/main.yml @@ -40,7 +40,8 @@ collections: - ansible.controller - awx.awx -dependencies: [] -# List your role dependencies here, one per line. Be sure to remove the '[]' above, -# if you add dependencies to this list. +dependencies: + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. + - role: global_vars ... diff --git a/roles/hosts/tasks/main.yml b/roles/hosts/tasks/main.yml index 7fbca6f07..f0dae5d5c 100644 --- a/roles/hosts/tasks/main.yml +++ b/roles/hosts/tasks/main.yml @@ -1,13 +1,13 @@ --- -- name: Add Controller host +- name: "Managing Controller Hosts" host: name: "{{ __controller_host_item.name | mandatory }}" new_name: "{{ __controller_host_item.new_name | default(omit, true) }}" - description: "{{ __controller_host_item.description | default(( '' if controller_configuration_host_enforce_defaults else omit), true) }}" + description: "{{ __controller_host_item.description | default(('' if controller_configuration_host_enforce_defaults else omit), true) }}" inventory: "{{ __controller_host_item.inventory | mandatory }}" - enabled: "{{ __controller_host_item.enabled | default(( false if controller_configuration_host_enforce_defaults else omit), true) }}" + enabled: "{{ __controller_host_item.enabled | default((false if controller_configuration_host_enforce_defaults else omit), true) }}" state: "{{ __controller_host_item.state | default(controller_state | default('present')) }}" - variables: "{{ __controller_host_item.variables | default(( {} if controller_configuration_host_enforce_defaults else omit), true) | regex_replace('[ ]{2,}', '') }}" + variables: "{{ __controller_host_item.variables | default(({} if controller_configuration_host_enforce_defaults else omit), true) | regex_replace('[ ]{2,}', '') }}" # Role Standard Options controller_host: "{{ controller_hostname | default(omit, true) }}" @@ -20,15 +20,17 @@ loop: "{{ controller_hosts }}" loop_control: loop_var: __controller_host_item + label: "{{ __operation.verb }} Controller host {{ __controller_host_item.name }}" no_log: "{{ controller_configuration_hosts_secure_logging }}" async: 1000 poll: 0 register: __host_job_async changed_when: not __host_job_async.changed vars: + __operation: "{{ operation_translate[__controller_host_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' -- name: "Configure Controller Hosts | Wait for finish the Hosts creation" +- name: "Managing Controller Hosts | Wait for finish the Hosts management" ansible.builtin.async_status: jid: "{{ __host_job_async_results_item.ansible_job_id }}" register: __host_job_async_result @@ -38,8 +40,10 @@ loop: "{{ __host_job_async.results }}" loop_control: loop_var: __host_job_async_results_item + label: "{{ __operation.verb }} Controller Host {{ __host_job_async_results_item.__controller_host_item.name }} | Wait for finish the Hosts {{ __operation.action }}" when: __host_job_async_results_item.ansible_job_id is defined no_log: "{{ controller_configuration_hosts_secure_logging }}" vars: + __operation: "{{ operation_translate[__host_job_async_results_item.__controller_host_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' ... diff --git a/roles/instance_groups/README.md b/roles/instance_groups/README.md index 9500e7406..bab234a25 100644 --- a/roles/instance_groups/README.md +++ b/roles/instance_groups/README.md @@ -2,7 +2,7 @@ ## Description -An Ansible Role to create instance groups on Ansible Controller. +An Ansible Role to create/update/remove instance groups on Ansible Controller. ## Requirements diff --git a/roles/instance_groups/meta/main.yml b/roles/instance_groups/meta/main.yml index ca726137e..b8a6c949b 100644 --- a/roles/instance_groups/meta/main.yml +++ b/roles/instance_groups/meta/main.yml @@ -40,7 +40,8 @@ collections: - ansible.controller - awx.awx -dependencies: [] -# List your role dependencies here, one per line. Be sure to remove the '[]' above, -# if you add dependencies to this list. +dependencies: + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. + - role: global_vars ... diff --git a/roles/instance_groups/tasks/main.yml b/roles/instance_groups/tasks/main.yml index cfeee70fe..6454ec12e 100644 --- a/roles/instance_groups/tasks/main.yml +++ b/roles/instance_groups/tasks/main.yml @@ -1,18 +1,17 @@ --- -# Add Controller Instance Group -- name: Add Controller Instance Group +- name: "Managing Controller Instance Groups" instance_group: name: "{{ __controller_instance_group_item.name | mandatory }}" new_name: "{{ __controller_instance_group_item.new_name | default(omit, true) }}" - credential: "{{ __controller_instance_group_item.credential | default(( '' if controller_configuration_instance_groups_enforce_defaults else omit), true) }}" - is_container_group: "{{ __controller_instance_group_item.is_container_group | default(( false if controller_configuration_instance_groups_enforce_defaults else omit), true) }}" - policy_instance_percentage: "{{ __controller_instance_group_item.policy_instance_percentage | default(( 0 if controller_configuration_instance_groups_enforce_defaults else omit), true) }}" - policy_instance_minimum: "{{ __controller_instance_group_item.policy_instance_minimum | default(( 0 if controller_configuration_instance_groups_enforce_defaults else omit), true) }}" - policy_instance_list: "{{ __controller_instance_group_item.policy_instance_list | default(( [] if controller_configuration_instance_groups_enforce_defaults else omit), true) }}" - max_concurrent_jobs: "{{ __controller_instance_group_item.max_concurrent_jobs | default(( 0 if controller_configuration_instance_groups_enforce_defaults else omit), true) }}" - max_forks: "{{ __controller_instance_group_item.max_forks | default(( 0 if controller_configuration_instance_groups_enforce_defaults else omit), true) }}" - pod_spec_override: "{{ __controller_instance_group_item.pod_spec_override | default(( '' if controller_configuration_instance_groups_enforce_defaults else omit), true) }}" - instances: "{{ __controller_instance_group_item.instances | default(( [] if controller_configuration_instance_groups_enforce_defaults else omit), true) }}" + credential: "{{ __controller_instance_group_item.credential | default(('' if controller_configuration_instance_groups_enforce_defaults else omit), true) }}" + is_container_group: "{{ __controller_instance_group_item.is_container_group | default((false if controller_configuration_instance_groups_enforce_defaults else omit), true) }}" + policy_instance_percentage: "{{ __controller_instance_group_item.policy_instance_percentage | default((0 if controller_configuration_instance_groups_enforce_defaults else omit), true) }}" + policy_instance_minimum: "{{ __controller_instance_group_item.policy_instance_minimum | default((0 if controller_configuration_instance_groups_enforce_defaults else omit), true) }}" + policy_instance_list: "{{ __controller_instance_group_item.policy_instance_list | default(([] if controller_configuration_instance_groups_enforce_defaults else omit), true) }}" + max_concurrent_jobs: "{{ __controller_instance_group_item.max_concurrent_jobs | default((0 if controller_configuration_instance_groups_enforce_defaults else omit), true) }}" + max_forks: "{{ __controller_instance_group_item.max_forks | default((0 if controller_configuration_instance_groups_enforce_defaults else omit), true) }}" + pod_spec_override: "{{ __controller_instance_group_item.pod_spec_override | default(('' if controller_configuration_instance_groups_enforce_defaults else omit), true) }}" + instances: "{{ __controller_instance_group_item.instances | default(([] if controller_configuration_instance_groups_enforce_defaults else omit), true) }}" state: "{{ __controller_instance_group_item.state | default(controller_state | default('present')) }}" # Role Standard Options @@ -26,6 +25,7 @@ loop: "{{ controller_instance_groups }}" loop_control: loop_var: __controller_instance_group_item + label: "{{ __operation.verb }} Controller Instance Group {{ __controller_instance_group_item.name }}" no_log: "{{ controller_configuration_instance_groups_secure_logging }}" when: controller_instance_groups is defined async: 1000 @@ -33,9 +33,10 @@ register: __instance_groups_job_async changed_when: not __instance_groups_job_async.changed vars: + __operation: "{{ operation_translate[__controller_instance_group_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' -- name: "Configure Controller instance groups | Wait for finish the instance groups creation" +- name: "Managing Controller instance groups | Wait for finish the instance groups management" ansible.builtin.async_status: jid: "{{ __instance_groups_job_async_results_item.ansible_job_id }}" register: __instance_groups_job_async_result @@ -45,8 +46,10 @@ loop: "{{ __instance_groups_job_async.results }}" loop_control: loop_var: __instance_groups_job_async_results_item + label: "{{ __operation.verb }} Controller instance group {{ __instance_groups_job_async_results_item.__controller_instance_group_item.name }} | Wait for finish the instance groups {{ __operation.action }}" when: __instance_groups_job_async_results_item.ansible_job_id is defined no_log: "{{ controller_configuration_instance_groups_secure_logging }}" vars: + __operation: "{{ operation_translate[__instance_groups_job_async_results_item.__controller_instance_group_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' ... diff --git a/roles/instances/tasks/main.yml b/roles/instances/tasks/main.yml index 033cd4909..6e50fcc54 100644 --- a/roles/instances/tasks/main.yml +++ b/roles/instances/tasks/main.yml @@ -3,12 +3,12 @@ - name: Add Controller Instance instance: hostname: "{{ __controller_instance_item.hostname | mandatory }}" - capacity_adjustment: "{{ __controller_instance_item.capacity_adjustment | default(( 1.0 if controller_configuration_instances_enforce_defaults else omit), true) }}" - enabled: "{{ __controller_instance_item.enabled | default(( true if controller_configuration_instances_enforce_defaults else omit), true) }}" - managed_by_policy: "{{ __controller_instance_item.managed_by_policy | default(( true if controller_configuration_instances_enforce_defaults else omit), true) }}" + capacity_adjustment: "{{ __controller_instance_item.capacity_adjustment | default((1.0 if controller_configuration_instances_enforce_defaults else omit), true) }}" + enabled: "{{ __controller_instance_item.enabled | default((true if controller_configuration_instances_enforce_defaults else omit), true) }}" + managed_by_policy: "{{ __controller_instance_item.managed_by_policy | default((true if controller_configuration_instances_enforce_defaults else omit), true) }}" node_type: "{{ __controller_instance_item.node_type | default(omit, true) }}" node_state: "{{ __controller_instance_item.node_state | default(omit, true) }}" - listener_port: "{{ __controller_instance_item.listener_port | default(( 27199 if controller_configuration_instances_enforce_defaults else omit), true) }}" + listener_port: "{{ __controller_instance_item.listener_port | default((27199 if controller_configuration_instances_enforce_defaults else omit), true) }}" # Role Standard Options controller_username: "{{ controller_username | default(omit, true) }}" diff --git a/roles/inventories/README.md b/roles/inventories/README.md index 13dbaa0fe..fe3ea718e 100644 --- a/roles/inventories/README.md +++ b/roles/inventories/README.md @@ -2,7 +2,7 @@ ## Description -An Ansible Role to create inventories on Ansible Controller. +An Ansible Role to create/update/remove inventories on Ansible Controller. ## Requirements diff --git a/roles/inventories/meta/main.yml b/roles/inventories/meta/main.yml index c02f4191b..41ca95146 100644 --- a/roles/inventories/meta/main.yml +++ b/roles/inventories/meta/main.yml @@ -26,4 +26,9 @@ galaxy_info: collections: - ansible.controller - awx.awx + +dependencies: + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. + - role: global_vars ... diff --git a/roles/inventories/tasks/main.yml b/roles/inventories/tasks/main.yml index 403678e20..e3b9f88c8 100644 --- a/roles/inventories/tasks/main.yml +++ b/roles/inventories/tasks/main.yml @@ -1,17 +1,17 @@ --- -- name: Create inventory +- name: "Managing Inventories" inventory: name: "{{ __controller_inventory_item.name | mandatory }}" new_name: "{{ __controller_inventory_item.new_name | default(omit, true) }}" copy_from: "{{ __controller_inventory_item.copy_from | default(omit, true) }}" - description: "{{ __controller_inventory_item.description | default(( '' if controller_configuration_inventories_enforce_defaults else omit), true) }}" + description: "{{ __controller_inventory_item.description | default(('' if controller_configuration_inventories_enforce_defaults else omit), true) }}" organization: "{{ __controller_inventory_item.organization.name | default(__controller_inventory_item.organization) | mandatory }}" - instance_groups: "{{ __controller_inventory_item.instance_groups | default(( [] if controller_configuration_inventories_enforce_defaults else omit), true) }}" - input_inventories: "{{ __controller_inventory_item.input_inventories | default(( [] if controller_configuration_inventories_enforce_defaults else omit), true) }}" - variables: "{{ __controller_inventory_item.variables | default(( {} if controller_configuration_inventories_enforce_defaults else omit), true) | regex_replace('[ ]{2,}', '') }}" - kind: "{{ __controller_inventory_item.kind | default(( '' if controller_configuration_inventories_enforce_defaults else omit), true) }}" - host_filter: "{{ __controller_inventory_item.host_filter | default(( '' if controller_configuration_inventories_enforce_defaults else omit), true) }}" - prevent_instance_group_fallback: "{{ __controller_inventory_item.prevent_instance_group_fallback | default(( false if controller_configuration_inventories_enforce_defaults else omit), true) }}" + instance_groups: "{{ __controller_inventory_item.instance_groups | default(([] if controller_configuration_inventories_enforce_defaults else omit), true) }}" + input_inventories: "{{ __controller_inventory_item.input_inventories | default(([] if controller_configuration_inventories_enforce_defaults else omit), true) }}" + variables: "{{ __controller_inventory_item.variables | default(({} if controller_configuration_inventories_enforce_defaults else omit), true) | regex_replace('[ ]{2,}', '') }}" + kind: "{{ __controller_inventory_item.kind | default(('' if controller_configuration_inventories_enforce_defaults else omit), true) }}" + host_filter: "{{ __controller_inventory_item.host_filter | default(('' if controller_configuration_inventories_enforce_defaults else omit), true) }}" + prevent_instance_group_fallback: "{{ __controller_inventory_item.prevent_instance_group_fallback | default((false if controller_configuration_inventories_enforce_defaults else omit), true) }}" state: "{{ __controller_inventory_item.state | default(controller_state | default('present')) }}" # Role Standard Options @@ -25,15 +25,17 @@ loop: "{{ inventory if inventory is defined else controller_inventories }}" loop_control: loop_var: __controller_inventory_item + label: "{{ __operation.verb }} inventory {{ __controller_inventory_item.name }}" no_log: "{{ controller_configuration_inventories_secure_logging }}" async: 1000 poll: 0 register: __inventories_job_async changed_when: not __inventories_job_async.changed vars: + __operation: "{{ operation_translate[__controller_inventory_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' -- name: "Create Controller inventories | Wait for finish the inventories creation" +- name: "Managing Controller Inventories | Wait for finish the inventories management" ansible.builtin.async_status: jid: "{{ __inventories_job_async_result_item.ansible_job_id }}" register: __inventories_job_async_result @@ -43,8 +45,10 @@ loop: "{{ __inventories_job_async.results }}" loop_control: loop_var: __inventories_job_async_result_item + label: "{{ __operation.verb }} Controller inventorie {{ __inventories_job_async_result_item.__controller_inventory_item.name }} | Wait for finish the inventories {{ __operation.action }}" when: __inventories_job_async_result_item.ansible_job_id is defined no_log: "{{ controller_configuration_inventories_secure_logging }}" vars: + __operation: "{{ operation_translate[__inventories_job_async_result_item.__controller_inventory_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' ... diff --git a/roles/inventory_sources/README.md b/roles/inventory_sources/README.md index 630e2ead8..0a9ba43d8 100644 --- a/roles/inventory_sources/README.md +++ b/roles/inventory_sources/README.md @@ -2,7 +2,7 @@ ## Description -An Ansible role to create inventory sources on Ansible Controller. +An Ansible Role to create/update/remove inventory sources on Ansible Controller. ## Requirements diff --git a/roles/inventory_sources/meta/main.yml b/roles/inventory_sources/meta/main.yml index 6dcc6b3de..78fdc7af8 100644 --- a/roles/inventory_sources/meta/main.yml +++ b/roles/inventory_sources/meta/main.yml @@ -26,4 +26,9 @@ galaxy_info: collections: - ansible.controller - awx.awx + +dependencies: + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. + - role: global_vars ... diff --git a/roles/inventory_sources/tasks/main.yml b/roles/inventory_sources/tasks/main.yml index d94ee19e1..652e1053c 100644 --- a/roles/inventory_sources/tasks/main.yml +++ b/roles/inventory_sources/tasks/main.yml @@ -1,33 +1,33 @@ --- -- name: Add an inventory source +- name: "Managing Inventory Sources" inventory_source: name: "{{ __controller_source_item.name | mandatory }}" new_name: "{{ __controller_source_item.new_name | default(omit, true) }}" - description: "{{ __controller_source_item.description | default(( '' if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" + description: "{{ __controller_source_item.description | default(('' if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" inventory: "{{ __controller_source_item.inventory.name | default(__controller_source_item.inventory) | mandatory }}" - organization: "{{ __controller_source_item.inventory.organization.name | default(__controller_source_item.organization | default(( '' if controller_configuration_inventory_sources_enforce_defaults else omit), true)) }}" - source: "{{ __controller_source_item.source | default(( 'scm' if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" - source_path: "{{ __controller_source_item.source_path | default(( '' if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" - source_vars: "{{ __controller_source_item.source_vars | default(( {} if controller_configuration_inventory_sources_enforce_defaults else omit), true) | regex_replace('[ ]{2,}', '') }}" - enabled_var: "{{ __controller_source_item.enabled_var | default(( '' if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" - enabled_value: "{{ __controller_source_item.enabled_value | default(( '' if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" - host_filter: "{{ __controller_source_item.host_filter | default(( '' if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" - limit: "{{ __controller_source_item.limit | default(( '' if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" + organization: "{{ __controller_source_item.inventory.organization.name | default(__controller_source_item.organization | default(('' if controller_configuration_inventory_sources_enforce_defaults else omit), true)) }}" + source: "{{ __controller_source_item.source | default(('scm' if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" + source_path: "{{ __controller_source_item.source_path | default(('' if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" + source_vars: "{{ __controller_source_item.source_vars | default(({} if controller_configuration_inventory_sources_enforce_defaults else omit), true) | regex_replace('[ ]{2,}', '') }}" + enabled_var: "{{ __controller_source_item.enabled_var | default(('' if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" + enabled_value: "{{ __controller_source_item.enabled_value | default(('' if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" + host_filter: "{{ __controller_source_item.host_filter | default(('' if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" + limit: "{{ __controller_source_item.limit | default(('' if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" credential: "{{ __controller_source_item.credential | default(omit, true) }}" execution_environment: "{{ __controller_source_item.execution_environment | default(omit, true) }}" - overwrite: "{{ __controller_source_item.overwrite | default(( false if controller_configuration_inventory_sources_enforce_defaults else omit)) }}" - overwrite_vars: "{{ __controller_source_item.overwrite_vars | default(( false if controller_configuration_inventory_sources_enforce_defaults else omit)) }}" - custom_virtualenv: "{{ __controller_source_item.custom_virtualenv | default(( '' if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" - timeout: "{{ __controller_source_item.timeout | default(( 0 if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" - verbosity: "{{ __controller_source_item.verbosity | default(( 1 if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" - update_on_launch: "{{ __controller_source_item.update_on_launch | default(( false if controller_configuration_inventory_sources_enforce_defaults else omit)) }}" - update_cache_timeout: "{{ __controller_source_item.update_cache_timeout | default(( 0 if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" - source_project: "{{ __controller_source_item.source_project.name | default(__controller_source_item.source_project | default(( '' if controller_configuration_inventory_sources_enforce_defaults else omit), true)) }}" - scm_branch: "{{ __controller_source_item.scm_branch | default(( '' if controller_configuration_inventory_sources_enforce_defaults else omit), true ) }}" + overwrite: "{{ __controller_source_item.overwrite | default((false if controller_configuration_inventory_sources_enforce_defaults else omit)) }}" + overwrite_vars: "{{ __controller_source_item.overwrite_vars | default((false if controller_configuration_inventory_sources_enforce_defaults else omit)) }}" + custom_virtualenv: "{{ __controller_source_item.custom_virtualenv | default(('' if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" + timeout: "{{ __controller_source_item.timeout | default((0 if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" + verbosity: "{{ __controller_source_item.verbosity | default((1 if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" + update_on_launch: "{{ __controller_source_item.update_on_launch | default((false if controller_configuration_inventory_sources_enforce_defaults else omit)) }}" + update_cache_timeout: "{{ __controller_source_item.update_cache_timeout | default((0 if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" + source_project: "{{ __controller_source_item.source_project.name | default(__controller_source_item.source_project | default(('' if controller_configuration_inventory_sources_enforce_defaults else omit), true)) }}" + scm_branch: "{{ __controller_source_item.scm_branch | default(('' if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" state: "{{ __controller_source_item.state | default(controller_state | default('present')) }}" - notification_templates_started: "{{ (__controller_source_item.related.notification_templates_started | map(attribute='name') | list if __controller_source_item.related.notification_templates_started is defined) | default(__controller_source_item.notification_templates_started) | default(( [] if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" - notification_templates_success: "{{ (__controller_source_item.related.notification_templates_success | map(attribute='name') | list if __controller_source_item.related.notification_templates_success is defined) | default(__controller_source_item.notification_templates_success) | default(( [] if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" - notification_templates_error: "{{ (__controller_source_item.related.notification_templates_error | map(attribute='name') | list if __controller_source_item.related.notification_templates_error is defined) | default(__controller_source_item.notification_templates_error) | default(( [] if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" + notification_templates_started: "{{ (__controller_source_item.related.notification_templates_started | map(attribute='name') | list if __controller_source_item.related.notification_templates_started is defined) | default(__controller_source_item.notification_templates_started) | default(([] if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" + notification_templates_success: "{{ (__controller_source_item.related.notification_templates_success | map(attribute='name') | list if __controller_source_item.related.notification_templates_success is defined) | default(__controller_source_item.notification_templates_success) | default(([] if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" + notification_templates_error: "{{ (__controller_source_item.related.notification_templates_error | map(attribute='name') | list if __controller_source_item.related.notification_templates_error is defined) | default(__controller_source_item.notification_templates_error) | default(([] if controller_configuration_inventory_sources_enforce_defaults else omit), true) }}" # Role Standard Options controller_config_file: "{{ controller_config_file | default(omit, true) }}" @@ -40,15 +40,17 @@ loop: "{{ inventory_sources if inventory_sources is defined else controller_inventory_sources }}" loop_control: loop_var: __controller_source_item + label: "{{ __operation.verb }} an Inventory Source {{ __controller_source_item.name }}" no_log: "{{ controller_configuration_inventory_sources_secure_logging }}" async: 1000 poll: 0 register: __inventory_source_job_async changed_when: not __inventory_source_job_async.changed vars: + __operation: "{{ operation_translate[__controller_source_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' -- name: "Configure Inventory Source | Wait for finish the Inventory Source creation" +- name: "Managing Inventory Sources | Wait for finish the Inventory Sources management" ansible.builtin.async_status: jid: "{{ __inventory_source_job_async_results_item.ansible_job_id }}" register: __inventory_source_job_async_result @@ -58,8 +60,10 @@ loop: "{{ __inventory_source_job_async.results }}" loop_control: loop_var: __inventory_source_job_async_results_item + label: "{{ __operation.verb }} Inventory Source {{ __inventory_source_job_async_results_item }} | Wait for finish the Inventory Source {{ __operation.action }}" when: __inventory_source_job_async_results_item.ansible_job_id is defined no_log: "{{ controller_configuration_inventory_sources_secure_logging }}" vars: + __operation: "{{ operation_translate[__inventory_source_job_async_results_item.__controller_source_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' ... diff --git a/roles/job_templates/README.md b/roles/job_templates/README.md index e839d0dd8..68e2dd9c0 100644 --- a/roles/job_templates/README.md +++ b/roles/job_templates/README.md @@ -2,7 +2,7 @@ ## Description -An Ansible Role to create Job Templates on Ansible Controller. +An Ansible Role to create/update/remove Job Templates on Ansible Controller. ## Requirements diff --git a/roles/job_templates/meta/main.yml b/roles/job_templates/meta/main.yml index 4817f30f0..902407dd5 100644 --- a/roles/job_templates/meta/main.yml +++ b/roles/job_templates/meta/main.yml @@ -39,7 +39,8 @@ collections: - ansible.controller - awx.awx -dependencies: [] -# List your role dependencies here, one per line. Be sure to remove the '[]' above, -# if you add dependencies to this list. +dependencies: + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. + - role: global_vars ... diff --git a/roles/job_templates/tasks/main.yml b/roles/job_templates/tasks/main.yml index 0a156daf5..1709ca32b 100644 --- a/roles/job_templates/tasks/main.yml +++ b/roles/job_templates/tasks/main.yml @@ -1,62 +1,61 @@ --- -# Create Controller Template -- name: Add Controller Job Templates +- name: "Managing Controller Job Templates" job_template: name: "{{ __controller_template_item.name | mandatory }}" new_name: "{{ __controller_template_item.new_name | default(omit, true) }}" copy_from: "{{ __controller_template_item.copy_from | default(omit, true) }}" - description: "{{ __controller_template_item.description | default(( '' if controller_configuration_job_templates_enforce_defaults else omit), true) }}" + description: "{{ __controller_template_item.description | default(('' if controller_configuration_job_templates_enforce_defaults else omit), true) }}" execution_environment: "{{ __controller_template_item.execution_environment.name | default(__controller_template_item.execution_environment | default(omit, true)) }}" - custom_virtualenv: "{{ __controller_template_item.custom_virtualenv | default(( '' if controller_configuration_job_templates_enforce_defaults else omit), true) }}" + custom_virtualenv: "{{ __controller_template_item.custom_virtualenv | default(('' if controller_configuration_job_templates_enforce_defaults else omit), true) }}" job_type: "{{ __controller_template_item.job_type | default('run') }}" inventory: "{{ __controller_template_item.inventory.name | default(__controller_template_item.inventory | default(omit, true)) }}" - organization: "{{ __controller_template_item.organization.name | default(__controller_template_item.organization | default(( '' if controller_configuration_job_templates_enforce_defaults else omit), true)) }}" + organization: "{{ __controller_template_item.organization.name | default(__controller_template_item.organization | default(('' if controller_configuration_job_templates_enforce_defaults else omit), true)) }}" project: "{{ __controller_template_item.project.name | default(__controller_template_item.project | default(omit, true)) }}" playbook: "{{ __controller_template_item.playbook | default(omit, true) }}" credentials: "{{ __controller_template_item.credentials | default(__controller_template_item.related.credentials | default([]) | map(attribute='name') | list) | default(omit, true) }}" - forks: "{{ __controller_template_item.forks | default(( 0 if controller_configuration_job_templates_enforce_defaults else omit), true) }}" - limit: "{{ __controller_template_item.limit | default(( '' if controller_configuration_job_templates_enforce_defaults else omit), true) }}" - verbosity: "{{ __controller_template_item.verbosity | default(( 0 if controller_configuration_job_templates_enforce_defaults else omit), true) }}" - extra_vars: "{{ __controller_template_item.extra_vars | default(( {} if controller_configuration_job_templates_enforce_defaults else omit), true) }}" - job_tags: "{{ __controller_template_item.job_tags | default(( '' if controller_configuration_job_templates_enforce_defaults else omit), true) }}" - force_handlers: "{{ __controller_template_item.force_handlers | default(( false if controller_configuration_job_templates_enforce_defaults else omit)) }}" - skip_tags: "{{ __controller_template_item.skip_tags | default(( '' if controller_configuration_job_templates_enforce_defaults else omit), true) }}" - start_at_task: "{{ __controller_template_item.start_at_task | default(( '' if controller_configuration_job_templates_enforce_defaults else omit), true) }}" - diff_mode: "{{ __controller_template_item.diff_mode | default(( false if controller_configuration_job_templates_enforce_defaults else omit)) }}" - use_fact_cache: "{{ __controller_template_item.use_fact_cache | default(( false if controller_configuration_job_templates_enforce_defaults else omit)) }}" - host_config_key: "{{ __controller_template_item.host_config_key | default(( '' if controller_configuration_job_templates_enforce_defaults else omit), true) }}" - ask_scm_branch_on_launch: "{{ __controller_template_item.ask_scm_branch_on_launch | default(( false if controller_configuration_job_templates_enforce_defaults else omit)) }}" - ask_diff_mode_on_launch: "{{ __controller_template_item.ask_diff_mode_on_launch | default(( false if controller_configuration_job_templates_enforce_defaults else omit)) }}" - ask_variables_on_launch: "{{ __controller_template_item.ask_variables_on_launch | default(( false if controller_configuration_job_templates_enforce_defaults else omit)) }}" - ask_limit_on_launch: "{{ __controller_template_item.ask_limit_on_launch | default(( false if controller_configuration_job_templates_enforce_defaults else omit)) }}" - ask_tags_on_launch: "{{ __controller_template_item.ask_tags | default(__controller_template_item.ask_tags_on_launch | default(( false if controller_configuration_job_templates_enforce_defaults else omit))) }}" - ask_skip_tags_on_launch: "{{ __controller_template_item.ask_skip_tags | default(__controller_template_item.ask_skip_tags_on_launch | default(( false if controller_configuration_job_templates_enforce_defaults else omit))) }}" - ask_job_type_on_launch: "{{ __controller_template_item.ask_job_type_on_launch | default(( false if controller_configuration_job_templates_enforce_defaults else omit)) }}" - ask_verbosity_on_launch: "{{ __controller_template_item.ask_verbosity_on_launch | default(( false if controller_configuration_job_templates_enforce_defaults else omit)) }}" - ask_inventory_on_launch: "{{ __controller_template_item.ask_inventory_on_launch | default(( false if controller_configuration_job_templates_enforce_defaults else omit)) }}" - ask_credential_on_launch: "{{ __controller_template_item.ask_credential_on_launch | default(( false if controller_configuration_job_templates_enforce_defaults else omit)) }}" - ask_execution_environment_on_launch: "{{ __controller_template_item.ask_execution_environment_on_launch | default(( false if controller_configuration_job_templates_enforce_defaults else omit)) }}" - ask_forks_on_launch: "{{ __controller_template_item.ask_forks_on_launch | default(( false if controller_configuration_job_templates_enforce_defaults else omit)) }}" - ask_instance_groups_on_launch: "{{ __controller_template_item.ask_instance_groups_on_launch | default(( false if controller_configuration_job_templates_enforce_defaults else omit)) }}" - ask_job_slice_count_on_launch: "{{ __controller_template_item.ask_job_slice_count_on_launch | default(( false if controller_configuration_job_templates_enforce_defaults else omit)) }}" - ask_labels_on_launch: "{{ __controller_template_item.ask_labels_on_launch | default(( false if controller_configuration_job_templates_enforce_defaults else omit)) }}" - ask_timeout_on_launch: "{{ __controller_template_item.ask_timeout_on_launch | default(( false if controller_configuration_job_templates_enforce_defaults else omit)) }}" - prevent_instance_group_fallback: "{{ __controller_template_item.prevent_instance_group_fallback | default(( false if controller_configuration_job_templates_enforce_defaults else omit)) }}" - survey_enabled: "{{ __controller_template_item.survey_enabled | default(( false if controller_configuration_job_templates_enforce_defaults else omit)) }}" - survey_spec: "{{ __controller_template_item.related.survey_spec | default(__controller_template_item.survey_spec | default(__controller_template_item.survey | default(( {} if controller_configuration_job_templates_enforce_defaults else omit), true))) }}" - become_enabled: "{{ __controller_template_item.become_enabled | default(( false if controller_configuration_job_templates_enforce_defaults else omit)) }}" - allow_simultaneous: "{{ __controller_template_item.allow_simultaneous | default(( false if controller_configuration_job_templates_enforce_defaults else omit)) }}" - timeout: "{{ __controller_template_item.timeout | default(( 0 if controller_configuration_job_templates_enforce_defaults else omit), true) }}" - instance_groups: "{{ __controller_template_item.instance_groups | default(( [] if controller_configuration_job_templates_enforce_defaults else omit), true) }}" - job_slice_count: "{{ __controller_template_item.job_slice_count | default(( 1 if controller_configuration_job_templates_enforce_defaults else omit), true) }}" - webhook_service: "{{ __controller_template_item.webhook_service | default(( '' if controller_configuration_job_templates_enforce_defaults else omit), true) }}" + forks: "{{ __controller_template_item.forks | default((0 if controller_configuration_job_templates_enforce_defaults else omit), true) }}" + limit: "{{ __controller_template_item.limit | default(('' if controller_configuration_job_templates_enforce_defaults else omit), true) }}" + verbosity: "{{ __controller_template_item.verbosity | default((0 if controller_configuration_job_templates_enforce_defaults else omit), true) }}" + extra_vars: "{{ __controller_template_item.extra_vars | default(({} if controller_configuration_job_templates_enforce_defaults else omit), true) }}" + job_tags: "{{ __controller_template_item.job_tags | default(('' if controller_configuration_job_templates_enforce_defaults else omit), true) }}" + force_handlers: "{{ __controller_template_item.force_handlers | default((false if controller_configuration_job_templates_enforce_defaults else omit)) }}" + skip_tags: "{{ __controller_template_item.skip_tags | default(('' if controller_configuration_job_templates_enforce_defaults else omit), true) }}" + start_at_task: "{{ __controller_template_item.start_at_task | default(('' if controller_configuration_job_templates_enforce_defaults else omit), true) }}" + diff_mode: "{{ __controller_template_item.diff_mode | default((false if controller_configuration_job_templates_enforce_defaults else omit)) }}" + use_fact_cache: "{{ __controller_template_item.use_fact_cache | default((false if controller_configuration_job_templates_enforce_defaults else omit)) }}" + host_config_key: "{{ __controller_template_item.host_config_key | default(('' if controller_configuration_job_templates_enforce_defaults else omit), true) }}" + ask_scm_branch_on_launch: "{{ __controller_template_item.ask_scm_branch_on_launch | default((false if controller_configuration_job_templates_enforce_defaults else omit)) }}" + ask_diff_mode_on_launch: "{{ __controller_template_item.ask_diff_mode_on_launch | default((false if controller_configuration_job_templates_enforce_defaults else omit)) }}" + ask_variables_on_launch: "{{ __controller_template_item.ask_variables_on_launch | default((false if controller_configuration_job_templates_enforce_defaults else omit)) }}" + ask_limit_on_launch: "{{ __controller_template_item.ask_limit_on_launch | default((false if controller_configuration_job_templates_enforce_defaults else omit)) }}" + ask_tags_on_launch: "{{ __controller_template_item.ask_tags | default(__controller_template_item.ask_tags_on_launch | default((false if controller_configuration_job_templates_enforce_defaults else omit))) }}" + ask_skip_tags_on_launch: "{{ __controller_template_item.ask_skip_tags | default(__controller_template_item.ask_skip_tags_on_launch | default((false if controller_configuration_job_templates_enforce_defaults else omit))) }}" + ask_job_type_on_launch: "{{ __controller_template_item.ask_job_type_on_launch | default((false if controller_configuration_job_templates_enforce_defaults else omit)) }}" + ask_verbosity_on_launch: "{{ __controller_template_item.ask_verbosity_on_launch | default((false if controller_configuration_job_templates_enforce_defaults else omit)) }}" + ask_inventory_on_launch: "{{ __controller_template_item.ask_inventory_on_launch | default((false if controller_configuration_job_templates_enforce_defaults else omit)) }}" + ask_credential_on_launch: "{{ __controller_template_item.ask_credential_on_launch | default((false if controller_configuration_job_templates_enforce_defaults else omit)) }}" + ask_execution_environment_on_launch: "{{ __controller_template_item.ask_execution_environment_on_launch | default((false if controller_configuration_job_templates_enforce_defaults else omit)) }}" + ask_forks_on_launch: "{{ __controller_template_item.ask_forks_on_launch | default((false if controller_configuration_job_templates_enforce_defaults else omit)) }}" + ask_instance_groups_on_launch: "{{ __controller_template_item.ask_instance_groups_on_launch | default((false if controller_configuration_job_templates_enforce_defaults else omit)) }}" + ask_job_slice_count_on_launch: "{{ __controller_template_item.ask_job_slice_count_on_launch | default((false if controller_configuration_job_templates_enforce_defaults else omit)) }}" + ask_labels_on_launch: "{{ __controller_template_item.ask_labels_on_launch | default((false if controller_configuration_job_templates_enforce_defaults else omit)) }}" + ask_timeout_on_launch: "{{ __controller_template_item.ask_timeout_on_launch | default((false if controller_configuration_job_templates_enforce_defaults else omit)) }}" + prevent_instance_group_fallback: "{{ __controller_template_item.prevent_instance_group_fallback | default((false if controller_configuration_job_templates_enforce_defaults else omit)) }}" + survey_enabled: "{{ __controller_template_item.survey_enabled | default((false if controller_configuration_job_templates_enforce_defaults else omit)) }}" + survey_spec: "{{ __controller_template_item.related.survey_spec | default(__controller_template_item.survey_spec | default(__controller_template_item.survey | default(({} if controller_configuration_job_templates_enforce_defaults else omit), true))) }}" + become_enabled: "{{ __controller_template_item.become_enabled | default((false if controller_configuration_job_templates_enforce_defaults else omit)) }}" + allow_simultaneous: "{{ __controller_template_item.allow_simultaneous | default((false if controller_configuration_job_templates_enforce_defaults else omit)) }}" + timeout: "{{ __controller_template_item.timeout | default((0 if controller_configuration_job_templates_enforce_defaults else omit), true) }}" + instance_groups: "{{ __controller_template_item.instance_groups | default(([] if controller_configuration_job_templates_enforce_defaults else omit), true) }}" + job_slice_count: "{{ __controller_template_item.job_slice_count | default((1 if controller_configuration_job_templates_enforce_defaults else omit), true) }}" + webhook_service: "{{ __controller_template_item.webhook_service | default(('' if controller_configuration_job_templates_enforce_defaults else omit), true) }}" webhook_credential: "{{ __controller_template_item.webhook_credential | default(omit, true) }}" - scm_branch: "{{ __controller_template_item.scm_branch | default(( '' if controller_configuration_job_templates_enforce_defaults else omit), true) }}" - labels: "{{ (__controller_template_item.related.labels | map(attribute='name') | list if __controller_template_item.related.labels is defined) | default(__controller_template_item.labels) | default(( [] if controller_configuration_job_templates_enforce_defaults else omit), true) }}" + scm_branch: "{{ __controller_template_item.scm_branch | default(('' if controller_configuration_job_templates_enforce_defaults else omit), true) }}" + labels: "{{ (__controller_template_item.related.labels | map(attribute='name') | list if __controller_template_item.related.labels is defined) | default(__controller_template_item.labels) | default(([] if controller_configuration_job_templates_enforce_defaults else omit), true) }}" state: "{{ __controller_template_item.state | default(controller_state | default('present')) }}" - notification_templates_started: "{{ (__controller_template_item.related.notification_templates_started | map(attribute='name') | list if __controller_template_item.related.notification_templates_started is defined) | default(__controller_template_item.notification_templates_started) | default(( [] if controller_configuration_job_templates_enforce_defaults else omit), true) }}" - notification_templates_success: "{{ (__controller_template_item.related.notification_templates_success | map(attribute='name') | list if __controller_template_item.related.notification_templates_success is defined) | default(__controller_template_item.notification_templates_success) | default(( [] if controller_configuration_job_templates_enforce_defaults else omit), true) }}" - notification_templates_error: "{{ (__controller_template_item.related.notification_templates_error | map(attribute='name') | list if __controller_template_item.related.notification_templates_error is defined) | default(__controller_template_item.notification_templates_error) | default(( [] if controller_configuration_job_templates_enforce_defaults else omit), true) }}" + notification_templates_started: "{{ (__controller_template_item.related.notification_templates_started | map(attribute='name') | list if __controller_template_item.related.notification_templates_started is defined) | default(__controller_template_item.notification_templates_started) | default(([] if controller_configuration_job_templates_enforce_defaults else omit), true) }}" + notification_templates_success: "{{ (__controller_template_item.related.notification_templates_success | map(attribute='name') | list if __controller_template_item.related.notification_templates_success is defined) | default(__controller_template_item.notification_templates_success) | default(([] if controller_configuration_job_templates_enforce_defaults else omit), true) }}" + notification_templates_error: "{{ (__controller_template_item.related.notification_templates_error | map(attribute='name') | list if __controller_template_item.related.notification_templates_error is defined) | default(__controller_template_item.notification_templates_error) | default(([] if controller_configuration_job_templates_enforce_defaults else omit), true) }}" # Role Standard Options controller_username: "{{ controller_username | default(omit, true) }}" @@ -69,15 +68,17 @@ loop: "{{ job_templates if job_templates is defined else controller_templates }}" loop_control: loop_var: __controller_template_item + label: "{{ __operation.verb }} Controller Job Template {{ __controller_template_item.name }}" no_log: "{{ controller_configuration_job_templates_secure_logging }}" async: 1000 poll: 0 register: __job_templates_job_async changed_when: not __job_templates_job_async.changed vars: + __operation: "{{ operation_translate[__controller_template_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' -- name: "Configure Controller Job Templates | Wait for finish the job templates creation" +- name: "Managing Controller Job Templates | Wait for finish the Job Templates management" ansible.builtin.async_status: jid: "{{ __job_templates_job_async_result_item.ansible_job_id }}" register: __job_templates_job_async_result @@ -87,8 +88,10 @@ loop: "{{ __job_templates_job_async.results }}" loop_control: loop_var: __job_templates_job_async_result_item + label: "{{ __operation.verb }} Controller Job Template {{ __job_templates_job_async_result_item.__controller_template_item.name }} | Wait for finish the job templates {{ __operation.action }}" when: __job_templates_job_async_result_item.ansible_job_id is defined no_log: "{{ controller_configuration_job_templates_secure_logging }}" vars: + __operation: "{{ operation_translate[__job_templates_job_asycn_result_item.__controller_template_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' ... diff --git a/roles/labels/README.md b/roles/labels/README.md index dd5dba001..51786ec4d 100644 --- a/roles/labels/README.md +++ b/roles/labels/README.md @@ -1,6 +1,6 @@ # controller_configuration.labels -An Ansible role to create labels for templates on Ansible Controller. +An Ansible role to create/update/remove labels for templates on Ansible Controller. ## Requirements diff --git a/roles/labels/meta/main.yml b/roles/labels/meta/main.yml index 0ebc16986..0947e0d49 100644 --- a/roles/labels/meta/main.yml +++ b/roles/labels/meta/main.yml @@ -25,4 +25,9 @@ galaxy_info: collections: - ansible.controller - awx.awx + +dependencies: + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. + - role: global_vars ... diff --git a/roles/labels/tasks/main.yml b/roles/labels/tasks/main.yml index 1caab28f2..e6adbc421 100644 --- a/roles/labels/tasks/main.yml +++ b/roles/labels/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: Add a label to Controller +- name: "Managing Labels" label: name: "{{ __controller_label_item.name | mandatory }}" new_name: "{{ __controller_label_item.new_name | default(omit, true) }}" @@ -17,15 +17,17 @@ loop: "{{ controller_labels }}" loop_control: loop_var: __controller_label_item + label: "{{ __operation.verb }} the label {{ __controller_label_item.name }} to Controller" no_log: "{{ controller_configuration_labels_secure_logging }}" async: 1000 poll: 0 register: __controller_label_job_async changed_when: not __controller_label_job_async.changed vars: + __operation: "{{ operation_translate[__controller_label_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' -- name: "Configure Labels | Wait for finish the Label creation" +- name: "Managing Labels | Wait for finish the Labels management" ansible.builtin.async_status: jid: "{{ __controller_label_job_async_results_item.ansible_job_id }}" register: __controller_label_job_async_result @@ -35,8 +37,10 @@ loop: "{{ __controller_label_job_async.results }}" loop_control: loop_var: __controller_label_job_async_results_item + label: "{{ __operation.verb }} Label {{ __controller_label_job_async_results_item.__controller_label_item.name }} | Wait for finish the Label {{ __operation.action }}" when: __controller_label_job_async_results_item.ansible_job_id is defined no_log: "{{ controller_configuration_labels_secure_logging }}" vars: + __operation: "{{ operation_translate[__controller_label_job_async_results_item.__controller_label_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' ... diff --git a/roles/license/tasks/subscription.yml b/roles/license/tasks/subscription.yml index f91f8301c..e1d8ab1ac 100644 --- a/roles/license/tasks/subscription.yml +++ b/roles/license/tasks/subscription.yml @@ -21,7 +21,7 @@ - name: Install the Controller license license: - pool_id: "{{ controller_license.pool_id | default(subscription.subscriptions[(controller_license.list_num | default(0))].pool_id)}}" + pool_id: "{{ controller_license.pool_id | default(subscription.subscriptions[(controller_license.list_num | default(0))].pool_id) }}" force: "{{ controller_license.force | default(omit) }}" state: "{{ controller_license.state | default(omit) }}" diff --git a/roles/notification_templates/README.md b/roles/notification_templates/README.md index 7e0954343..f5c8fbb12 100644 --- a/roles/notification_templates/README.md +++ b/roles/notification_templates/README.md @@ -2,7 +2,7 @@ ## Description -An Ansible Role to add notification templates on Ansible Controller. +An Ansible Role to add/update/remove notification templates on Ansible Controller. ## Requirements diff --git a/roles/notification_templates/meta/main.yml b/roles/notification_templates/meta/main.yml index b4aafd405..03fa67280 100644 --- a/roles/notification_templates/meta/main.yml +++ b/roles/notification_templates/meta/main.yml @@ -40,7 +40,8 @@ collections: - ansible.controller - awx.awx -dependencies: [] -# List your role dependencies here, one per line. Be sure to remove the '[]' above, -# if you add dependencies to this list. +dependencies: + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. + - role: global_vars ... diff --git a/roles/notification_templates/tasks/main.yml b/roles/notification_templates/tasks/main.yml index e52d1e54b..259f4b9d3 100644 --- a/roles/notification_templates/tasks/main.yml +++ b/roles/notification_templates/tasks/main.yml @@ -1,14 +1,14 @@ --- -- name: Add Controller notifications +- name: "Managing Controller Notifications" notification_template: name: "{{ __controller_notification_item.name | mandatory }}" new_name: "{{ __controller_notification_item.new_name | default(omit, true) }}" copy_from: "{{ __controller_notification_item.copy_from | default(omit, true) }}" - description: "{{ __controller_notification_item.description | default(( '' if controller_configuration_notifications_enforce_defaults else omit), true) }}" + description: "{{ __controller_notification_item.description | default(('' if controller_configuration_notifications_enforce_defaults else omit), true) }}" organization: "{{ __controller_notification_item.organization.name | default(__controller_notification_item.organization) | mandatory }}" - notification_type: "{{ __controller_notification_item.notification_type | default(omit, true) | mandatory}}" - notification_configuration: "{{ __controller_notification_item.notification_configuration | default(( {} if controller_configuration_notifications_enforce_defaults else omit), true) }}" - messages: "{{ __controller_notification_item.messages | default(( {} if controller_configuration_notifications_enforce_defaults else omit), true) | regex_replace('[ ]{2,}', '') }}" + notification_type: "{{ __controller_notification_item.notification_type | default(omit, true) | mandatory }}" + notification_configuration: "{{ __controller_notification_item.notification_configuration | default(({} if controller_configuration_notifications_enforce_defaults else omit), true) }}" + messages: "{{ __controller_notification_item.messages | default(({} if controller_configuration_notifications_enforce_defaults else omit), true) | regex_replace('[ ]{2,}', '') }}" state: "{{ __controller_notification_item.state | default(controller_state | default('present')) }}" # Role Standard Options @@ -22,15 +22,17 @@ loop: "{{ notification_templates if notification_templates is defined else controller_notifications }}" loop_control: loop_var: __controller_notification_item + label: "{{ __operation.verb }} Controller notification {{ __controller_notification_item.name }}" no_log: "{{ controller_configuration_notifications_secure_logging }}" async: 1000 poll: 0 register: __controller_notification_job_async changed_when: not __controller_notification_job_async.changed vars: + __operation: "{{ operation_translate[__controller_notification_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' -- name: "Configure notifications | Wait for finish the notifications creation" +- name: "Managing Notifications | Wait for finish the Notifications management" ansible.builtin.async_status: jid: "{{ __controller_notification_job_async_results_item.ansible_job_id }}" register: __controller_notification_job_async_result @@ -40,8 +42,10 @@ loop: "{{ __controller_notification_job_async.results }}" loop_control: loop_var: __controller_notification_job_async_results_item + label: "{{ __operation.verb }} notification {{ __controller_notification_job_async_results_item.__controller_notification_item.name }} | Wait for finish the notifications {{ __operation.action }}" when: __controller_notification_job_async_results_item.ansible_job_id is defined no_log: "{{ controller_configuration_notifications_secure_logging }}" vars: + __operation: "{{ operation_translate[__controller_notification_job_async_results_item.__controller_notification_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' ... diff --git a/roles/object_diff/tasks/roles.yml b/roles/object_diff/tasks/roles.yml index dcc3e3bb7..82572428f 100644 --- a/roles/object_diff/tasks/roles.yml +++ b/roles/object_diff/tasks/roles.yml @@ -5,14 +5,10 @@ host=controller_hostname, oauth_token=controller_oauthtoken, verify_ssl=controller_validate_certs) }}" no_log: "{{ controller_configuration_object_diff_secure_logging }}" - tags: - - always - name: "Role differences (block)" when: - __controller_api_current_user_check_is_admin.is_superuser - tags: - - always block: - name: "Get the API list of all roles" # noqa jinja[spacing] diff --git a/roles/organizations/README.md b/roles/organizations/README.md index f9a7603e2..e91f11aca 100644 --- a/roles/organizations/README.md +++ b/roles/organizations/README.md @@ -2,7 +2,7 @@ ## Description -An Ansible Role to create Organizations on Ansible Controller. +An Ansible Role to create/update/remove Organizations on Ansible Controller. ## Requirements diff --git a/roles/organizations/meta/main.yml b/roles/organizations/meta/main.yml index 457622ad8..904560007 100644 --- a/roles/organizations/meta/main.yml +++ b/roles/organizations/meta/main.yml @@ -40,7 +40,8 @@ collections: - ansible.controller - awx.awx -dependencies: [] -# List your role dependencies here, one per line. Be sure to remove the '[]' above, -# if you add dependencies to this list. +dependencies: + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. + - role: global_vars ... diff --git a/roles/organizations/tasks/main.yml b/roles/organizations/tasks/main.yml index c474531a6..7a08e9c07 100644 --- a/roles/organizations/tasks/main.yml +++ b/roles/organizations/tasks/main.yml @@ -1,17 +1,17 @@ --- -- name: Add organizations +- name: "Managing Organizations" organization: name: "{{ __controller_organizations_item.name | mandatory }}" - description: "{{ __controller_organizations_item.description | default(( '' if controller_configuration_organizations_enforce_defaults else omit), true) }}" + description: "{{ __controller_organizations_item.description | default(('' if controller_configuration_organizations_enforce_defaults else omit), true) }}" custom_virtualenv: "{{ __controller_organizations_item.custom_virtualenv | default(omit, true) }}" max_hosts: "{{ __controller_organizations_item.max_hosts | default(omit, true) }}" - instance_groups: "{{ __controller_organizations_item.instance_groups | default(( [] if controller_configuration_organizations_enforce_defaults else omit), true) }}" + instance_groups: "{{ __controller_organizations_item.instance_groups | default(([] if controller_configuration_organizations_enforce_defaults else omit), true) }}" default_environment: "{{ (__controller_organizations_item.default_environment.name | default(__controller_organizations_item.default_environment | default(__controller_organizations_item.execution_environment | default(omit)))) if (assign_default_ee_to_org is defined and assign_default_ee_to_org) else omit }}" - galaxy_credentials: "{{ (__controller_organizations_item.galaxy_credentials | default(( [] if controller_configuration_organizations_enforce_defaults else omit), true)) if (assign_galaxy_credentials_to_org is defined and assign_galaxy_credentials_to_org) else omit }}" - notification_templates_approvals: "{{ (__controller_organizations_item.related.notification_templates_approvals | map(attribute='name') | list if __controller_organizations_item.related.notification_templates_approvals is defined) | default(__controller_organizations_item.notification_templates_approvals) | default(( [] if controller_configuration_organizations_enforce_defaults else omit), true) }}" - notification_templates_started: "{{ (__controller_organizations_item.related.notification_templates_started | map(attribute='name') | list if __controller_organizations_item.related.notification_templates_started is defined) | default(__controller_organizations_item.notification_templates_started) | default(( [] if controller_configuration_organizations_enforce_defaults else omit), true) }}" - notification_templates_success: "{{ (__controller_organizations_item.related.notification_templates_success | map(attribute='name') | list if __controller_organizations_item.related.notification_templates_success is defined) | default(__controller_organizations_item.notification_templates_success) | default(( [] if controller_configuration_organizations_enforce_defaults else omit), true) }}" - notification_templates_error: "{{ (__controller_organizations_item.related.notification_templates_error | map(attribute='name') | list if __controller_organizations_item.related.notification_templates_error is defined) | default(__controller_organizations_item.notification_templates_error) | default(( [] if controller_configuration_organizations_enforce_defaults else omit), true) }}" + galaxy_credentials: "{{ (__controller_organizations_item.galaxy_credentials | default(([] if controller_configuration_organizations_enforce_defaults else omit), true)) if (assign_galaxy_credentials_to_org is defined and assign_galaxy_credentials_to_org) else omit }}" + notification_templates_approvals: "{{ (__controller_organizations_item.related.notification_templates_approvals | map(attribute='name') | list if __controller_organizations_item.related.notification_templates_approvals is defined) | default(__controller_organizations_item.notification_templates_approvals) | default(([] if controller_configuration_organizations_enforce_defaults else omit), true) }}" + notification_templates_started: "{{ (__controller_organizations_item.related.notification_templates_started | map(attribute='name') | list if __controller_organizations_item.related.notification_templates_started is defined) | default(__controller_organizations_item.notification_templates_started) | default(([] if controller_configuration_organizations_enforce_defaults else omit), true) }}" + notification_templates_success: "{{ (__controller_organizations_item.related.notification_templates_success | map(attribute='name') | list if __controller_organizations_item.related.notification_templates_success is defined) | default(__controller_organizations_item.notification_templates_success) | default(([] if controller_configuration_organizations_enforce_defaults else omit), true) }}" + notification_templates_error: "{{ (__controller_organizations_item.related.notification_templates_error | map(attribute='name') | list if __controller_organizations_item.related.notification_templates_error is defined) | default(__controller_organizations_item.notification_templates_error) | default(([] if controller_configuration_organizations_enforce_defaults else omit), true) }}" state: "{{ __controller_organizations_item.state | default(controller_state | default('present')) }}" # Role Standard Options @@ -25,15 +25,17 @@ loop: "{{ organizations if organizations is defined else controller_organizations }}" loop_control: loop_var: __controller_organizations_item + label: "{{ __operation.verb }} organization {{ __controller_organizations_item.name }}" no_log: "{{ controller_configuration_organizations_secure_logging }}" async: 1000 poll: 0 register: __organizations_job_async changed_when: not __organizations_job_async.changed vars: + __operation: "{{ operation_translate[__controller_organizations_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' -- name: "Configure Controller Organizations | Wait for finish the organization creation" +- name: "Managing Controller Organizations | Wait for finish the Organizations management" ansible.builtin.async_status: jid: "{{ __organizations_job_async_results_item.ansible_job_id }}" register: __organizations_job_async_result @@ -43,8 +45,10 @@ loop: "{{ __organizations_job_async.results }}" loop_control: loop_var: __organizations_job_async_results_item + label: "{{ __operation.verb }} Controller Organization {{ __organizations_job_async_results_item.__controller_organizations_item.name }} | Wait for finish the organization {{ __operation.action }}" when: __organizations_job_async_results_item.ansible_job_id is defined no_log: "{{ controller_configuration_organizations_secure_logging }}" vars: + __operation: "{{ operation_translate[__organizations_job_async_results_item.__controller_organizations_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' ... diff --git a/roles/projects/README.md b/roles/projects/README.md index 45b2059de..5655a98e3 100644 --- a/roles/projects/README.md +++ b/roles/projects/README.md @@ -2,7 +2,7 @@ ## Description -An Ansible Role to create Projects on Ansible Controller. +An Ansible Role to create/update/remove Projects on Ansible Controller. ## Requirements diff --git a/roles/projects/meta/main.yml b/roles/projects/meta/main.yml index b94267153..8de201683 100644 --- a/roles/projects/meta/main.yml +++ b/roles/projects/meta/main.yml @@ -40,7 +40,8 @@ collections: - ansible.controller - awx.awx -dependencies: [] -# List your role dependencies here, one per line. Be sure to remove the '[]' above, -# if you add dependencies to this list. +dependencies: + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. + - role: global_vars ... diff --git a/roles/projects/tasks/main.yml b/roles/projects/tasks/main.yml index 6ed6879bd..493783c15 100644 --- a/roles/projects/tasks/main.yml +++ b/roles/projects/tasks/main.yml @@ -1,34 +1,34 @@ --- -- name: Add Projects +- name: "Managing Projects" project: name: "{{ __controller_project_item.name | mandatory }}" new_name: "{{ __controller_project_item.new_name | default(omit, true) }}" copy_from: "{{ __controller_project_item.copy_from | default(omit, true) }}" - description: "{{ __controller_project_item.description | default(( '' if controller_configuration_projects_enforce_defaults else omit), true) }}" + description: "{{ __controller_project_item.description | default(('' if controller_configuration_projects_enforce_defaults else omit), true) }}" scm_type: "{{ __controller_project_item.scm_type | default('manual') }}" - scm_url: "{{ __controller_project_item.scm_url | default(( '' if controller_configuration_projects_enforce_defaults else omit), true) }}" + scm_url: "{{ __controller_project_item.scm_url | default(('' if controller_configuration_projects_enforce_defaults else omit), true) }}" default_environment: "{{ __controller_project_item.default_environment | default(omit, true) }}" - local_path: "{{ __controller_project_item.local_path | default(( '' if controller_configuration_projects_enforce_defaults else omit), true) }}" - scm_branch: "{{ __controller_project_item.scm_branch | default(( '' if controller_configuration_projects_enforce_defaults else omit)) }}" - scm_refspec: "{{ __controller_project_item.scm_refspec | default(( '' if controller_configuration_projects_enforce_defaults else omit), true) }}" + local_path: "{{ __controller_project_item.local_path | default(('' if controller_configuration_projects_enforce_defaults else omit), true) }}" + scm_branch: "{{ __controller_project_item.scm_branch | default(('' if controller_configuration_projects_enforce_defaults else omit)) }}" + scm_refspec: "{{ __controller_project_item.scm_refspec | default(('' if controller_configuration_projects_enforce_defaults else omit), true) }}" credential: "{{ __controller_project_item.credential.name | default(__controller_project_item.credential | default(__controller_project_item.scm_credential | default(omit, true))) }}" signature_validation_credential: "{{ __controller_project_item.signature_validation_credential.name | default(__controller_project_item.signature_validation_credential | default(omit, true)) }}" - scm_clean: "{{ __controller_project_item.scm_clean | default(( false if controller_configuration_projects_enforce_defaults else omit)) }}" - scm_delete_on_update: "{{ __controller_project_item.scm_delete_on_update | default(( false if controller_configuration_projects_enforce_defaults else omit)) }}" - scm_track_submodules: "{{ __controller_project_item.scm_track_submodules | default(( false if controller_configuration_projects_enforce_defaults else omit)) }}" - scm_update_on_launch: "{{ __controller_project_item.scm_update_on_launch | default(( false if controller_configuration_projects_enforce_defaults else omit)) }}" - scm_update_cache_timeout: "{{ __controller_project_item.scm_update_cache_timeout | default(( 0 if controller_configuration_projects_enforce_defaults else omit), true) }}" - allow_override: "{{ __controller_project_item.allow_override | default(( false if controller_configuration_projects_enforce_defaults else omit)) }}" - timeout: "{{ __controller_project_item.job_timeout | default(__controller_project_item.timeout | default(( 0 if controller_configuration_projects_enforce_defaults else omit), true)) }}" - custom_virtualenv: "{{ __controller_project_item.custom_virtualenv | default(( '' if controller_configuration_projects_enforce_defaults else omit), true) }}" - organization: "{{ __controller_project_item.organization.name | default(__controller_project_item.organization | default(( '' if controller_configuration_projects_enforce_defaults else omit))) }}" + scm_clean: "{{ __controller_project_item.scm_clean | default((false if controller_configuration_projects_enforce_defaults else omit)) }}" + scm_delete_on_update: "{{ __controller_project_item.scm_delete_on_update | default((false if controller_configuration_projects_enforce_defaults else omit)) }}" + scm_track_submodules: "{{ __controller_project_item.scm_track_submodules | default((false if controller_configuration_projects_enforce_defaults else omit)) }}" + scm_update_on_launch: "{{ __controller_project_item.scm_update_on_launch | default((false if controller_configuration_projects_enforce_defaults else omit)) }}" + scm_update_cache_timeout: "{{ __controller_project_item.scm_update_cache_timeout | default((0 if controller_configuration_projects_enforce_defaults else omit), true) }}" + allow_override: "{{ __controller_project_item.allow_override | default((false if controller_configuration_projects_enforce_defaults else omit)) }}" + timeout: "{{ __controller_project_item.job_timeout | default(__controller_project_item.timeout | default((0 if controller_configuration_projects_enforce_defaults else omit), true)) }}" + custom_virtualenv: "{{ __controller_project_item.custom_virtualenv | default(('' if controller_configuration_projects_enforce_defaults else omit), true) }}" + organization: "{{ __controller_project_item.organization.name | default(__controller_project_item.organization | default(('' if controller_configuration_projects_enforce_defaults else omit))) }}" state: "{{ __controller_project_item.state | default(controller_state | default('present')) }}" - wait: "{{ __controller_project_item.wait | default(( true if controller_configuration_projects_enforce_defaults else omit)) }}" - update_project: "{{ __controller_project_item.update_project | default(( false if controller_configuration_projects_enforce_defaults else omit)) }}" + wait: "{{ __controller_project_item.wait | default((true if controller_configuration_projects_enforce_defaults else omit)) }}" + update_project: "{{ __controller_project_item.update_project | default((false if controller_configuration_projects_enforce_defaults else omit)) }}" interval: "{{ __controller_project_item.interval | default(controller_configuration_projects_async_delay) }}" - notification_templates_started: "{{ (__controller_project_item.related.notification_templates_started | map(attribute='name') | list if __controller_project_item.related.notification_templates_started is defined) | default(__controller_project_item.notification_templates_started) | default(( [] if controller_configuration_projects_enforce_defaults else omit), true) }}" - notification_templates_success: "{{ (__controller_project_item.related.notification_templates_success | map(attribute='name') | list if __controller_project_item.related.notification_templates_success is defined) | default(__controller_project_item.notification_templates_success) | default(( [] if controller_configuration_projects_enforce_defaults else omit), true) }}" - notification_templates_error: "{{ (__controller_project_item.related.notification_templates_error | map(attribute='name') | list if __controller_project_item.related.notification_templates_error is defined) | default(__controller_project_item.notification_templates_error) | default(( [] if controller_configuration_projects_enforce_defaults else omit), true) }}" + notification_templates_started: "{{ (__controller_project_item.related.notification_templates_started | map(attribute='name') | list if __controller_project_item.related.notification_templates_started is defined) | default(__controller_project_item.notification_templates_started) | default(([] if controller_configuration_projects_enforce_defaults else omit), true) }}" + notification_templates_success: "{{ (__controller_project_item.related.notification_templates_success | map(attribute='name') | list if __controller_project_item.related.notification_templates_success is defined) | default(__controller_project_item.notification_templates_success) | default(([] if controller_configuration_projects_enforce_defaults else omit), true) }}" + notification_templates_error: "{{ (__controller_project_item.related.notification_templates_error | map(attribute='name') | list if __controller_project_item.related.notification_templates_error is defined) | default(__controller_project_item.notification_templates_error) | default(([] if controller_configuration_projects_enforce_defaults else omit), true) }}" # Role Standard Options controller_username: "{{ controller_username | default(omit, true) }}" @@ -41,15 +41,17 @@ loop: "{{ projects if projects is defined else controller_projects }}" loop_control: loop_var: __controller_project_item + label: "{{ __operation.verb }} Project {{ __controller_project_item.name }}" no_log: "{{ controller_configuration_projects_secure_logging }}" async: 1000 poll: 0 register: __projects_job_async changed_when: not __projects_job_async.changed vars: + __operation: "{{ operation_translate[__controller_project_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' -- name: "Configure Controller Projects | Wait for finish the projects creation" +- name: "Managing Projects | Wait for finish the projects management" ansible.builtin.async_status: jid: "{{ __projects_job_async_results_item.ansible_job_id }}" register: __projects_job_async_result @@ -59,8 +61,10 @@ loop: "{{ __projects_job_async.results }}" loop_control: loop_var: __projects_job_async_results_item + label: "{{ __operation.verb }} Project {{ __projects_job_async_results_item.__controller_project_item.name }} | Wait for finish the project {{ __operation.action }}" when: __projects_job_async_results_item.ansible_job_id is defined no_log: "{{ controller_configuration_projects_secure_logging }}" vars: + __operation: "{{ operation_translate[__projects_job_async_results_item.__controller_project_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' ... diff --git a/roles/roles/README.md b/roles/roles/README.md index 296f2abff..786daec6e 100644 --- a/roles/roles/README.md +++ b/roles/roles/README.md @@ -2,7 +2,7 @@ ## Description -An Ansible Role to create RBAC Entries on Ansible Controller. +An Ansible Role to create/update/remove RBAC Entries on Ansible Controller. ## Requirements diff --git a/roles/roles/meta/main.yml b/roles/roles/meta/main.yml index 9028cd25c..10e09fc7c 100644 --- a/roles/roles/meta/main.yml +++ b/roles/roles/meta/main.yml @@ -66,7 +66,8 @@ collections: - ansible.controller - awx.awx -dependencies: [] -# List your role dependencies here, one per line. Be sure to remove the '[]' above, -# if you add dependencies to this list. +dependencies: + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. + - role: global_vars ... diff --git a/roles/roles/tasks/main.yml b/roles/roles/tasks/main.yml index 278b814a4..c52142d04 100644 --- a/roles/roles/tasks/main.yml +++ b/roles/roles/tasks/main.yml @@ -1,27 +1,27 @@ --- -- name: Create Role Based Access Entry on Controller +- name: "Managing Role Based Access Entries on Controller" role: user: "{{ __controller_role_item.0.user | default(__controller_role_item.user) | default(omit, true) }}" - users: "{{ __controller_role_item.0.users | default(__controller_role_item.users) | default(( [] if controller_configuration_role_enforce_defaults else omit), true) }}" + users: "{{ __controller_role_item.0.users | default(__controller_role_item.users) | default(([] if controller_configuration_role_enforce_defaults else omit), true) }}" team: "{{ __controller_role_item.0.team | default(__controller_role_item.team) | default(omit, true) }}" - teams: "{{ __controller_role_item.0.teams | default(__controller_role_item.teams) | default(( [] if controller_configuration_role_enforce_defaults else omit), true) }}" + teams: "{{ __controller_role_item.0.teams | default(__controller_role_item.teams) | default(([] if controller_configuration_role_enforce_defaults else omit), true) }}" role: "{{ __controller_role_item.1 | default(__controller_role_item.role) | mandatory }}" target_team: "{{ __controller_role_item.0.target_team | default(__controller_role_item.target_team) | default(omit, true) }}" - target_teams: "{{ __controller_role_item.0.target_teams | default(__controller_role_item.target_teams) | default(( [] if controller_configuration_role_enforce_defaults else omit), true) }}" + target_teams: "{{ __controller_role_item.0.target_teams | default(__controller_role_item.target_teams) | default(([] if controller_configuration_role_enforce_defaults else omit), true) }}" inventory: "{{ __controller_role_item.0.inventory | default(__controller_role_item.inventory) | default(omit, true) }}" - inventories: "{{ __controller_role_item.0.inventories | default(__controller_role_item.inventories) | default(( [] if controller_configuration_role_enforce_defaults else omit), true) }}" + inventories: "{{ __controller_role_item.0.inventories | default(__controller_role_item.inventories) | default(([] if controller_configuration_role_enforce_defaults else omit), true) }}" job_template: "{{ __controller_role_item.0.job_template | default(__controller_role_item.job_template) | default(omit, true) }}" - job_templates: "{{ __controller_role_item.0.job_templates | default(__controller_role_item.job_templates) | default(( [] if controller_configuration_role_enforce_defaults else omit), true) }}" + job_templates: "{{ __controller_role_item.0.job_templates | default(__controller_role_item.job_templates) | default(([] if controller_configuration_role_enforce_defaults else omit), true) }}" workflow: "{{ __controller_role_item.0.workflow | default(__controller_role_item.workflow) | default(omit, true) }}" - workflows: "{{ __controller_role_item.0.workflows | default(__controller_role_item.workflows) | default(( [] if controller_configuration_role_enforce_defaults else omit), true) }}" + workflows: "{{ __controller_role_item.0.workflows | default(__controller_role_item.workflows) | default(([] if controller_configuration_role_enforce_defaults else omit), true) }}" credential: "{{ __controller_role_item.0.credential | default(__controller_role_item.credential) | default(omit, true) }}" - credentials: "{{ __controller_role_item.0.credentials | default(__controller_role_item.credentials) | default(( [] if controller_configuration_role_enforce_defaults else omit), true) }}" + credentials: "{{ __controller_role_item.0.credentials | default(__controller_role_item.credentials) | default(([] if controller_configuration_role_enforce_defaults else omit), true) }}" organization: "{{ __controller_role_item.0.organization | default(__controller_role_item.organization) | default(omit, true) }}" - organizations: "{{ __controller_role_item.0.organizations | default(__controller_role_item.organizations) | default(( [] if controller_configuration_role_enforce_defaults else omit), true) }}" + organizations: "{{ __controller_role_item.0.organizations | default(__controller_role_item.organizations) | default(([] if controller_configuration_role_enforce_defaults else omit), true) }}" lookup_organization: "{{ __controller_role_item.0.lookup_organization | default(__controller_role_item.lookup_organization) | default(omit, true) }}" project: "{{ __controller_role_item.0.project | default(__controller_role_item.project) | default(omit, true) }}" - projects: "{{ __controller_role_item.0.projects | default(__controller_role_item.projects) | default(( [] if controller_configuration_role_enforce_defaults else omit), true) }}" - instance_groups: "{{ __controller_role_item.0.instance_groups | default(__controller_role_item.instance_groups) | default(( [] if controller_configuration_role_enforce_defaults else omit), true) }}" + projects: "{{ __controller_role_item.0.projects | default(__controller_role_item.projects) | default(([] if controller_configuration_role_enforce_defaults else omit), true) }}" + instance_groups: "{{ __controller_role_item.0.instance_groups | default(__controller_role_item.instance_groups) | default(([] if controller_configuration_role_enforce_defaults else omit), true) }}" state: "{{ __controller_role_item.0.state | default(__controller_role_item.state) | default(controller_state | default('present')) }}" # Role Standard Options @@ -32,18 +32,20 @@ controller_host: "{{ controller_hostname | default(omit, true) }}" controller_config_file: "{{ controller_config_file | default(omit, true) }}" validate_certs: "{{ controller_validate_certs | default(omit) }}" - loop: "{{ ( controller_roles | subelements(['roles'], skip_missing=true)) + controller_roles | selectattr('roles', 'undefined') }}" + loop: "{{ (controller_roles | subelements(['roles'], skip_missing=true)) + controller_roles | selectattr('roles', 'undefined') }}" loop_control: loop_var: __controller_role_item + label: "{{ __operation.verb }} Role Based Access Entry on Controller {{ __controller_role_item.1 | default(__controller_role_item.role) }}" no_log: "{{ controller_configuration_role_secure_logging }}" async: 1000 poll: 0 register: __controller_role_job_async changed_when: not __controller_role_job_async.changed vars: + __operation: "{{ operation_translate[__controller_role_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' -- name: "Configure Roles | Wait for finish the Roles creation" +- name: "Managing Roles | Wait for finish the Roles management" ansible.builtin.async_status: jid: "{{ __controller_role_job_async_results_item.ansible_job_id }}" register: __controller_role_job_async_result @@ -53,8 +55,10 @@ loop: "{{ __controller_role_job_async.results }}" loop_control: loop_var: __controller_role_job_async_results_item + label: "{{ __operation.verb }} Role {{ __controller_role_job_async_results_item.__controller_role_item.1 | default(__controller_role_job_async_results_item.__controller_role_item.role) }} | Wait for finish the Roles {{ __operation.action }}" when: __controller_role_job_async_results_item.ansible_job_id is defined no_log: "{{ controller_configuration_role_secure_logging }}" vars: + __operation: "{{ operation_translate[__controller_role_job_async_results_item.__controller_role_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' ... diff --git a/roles/schedules/README.md b/roles/schedules/README.md index 2bebff6b6..9d5df9d64 100644 --- a/roles/schedules/README.md +++ b/roles/schedules/README.md @@ -2,7 +2,7 @@ ## Description -An Ansible Role to create Schedules on Ansible Controller. +An Ansible Role to create/update/remove Schedules on Ansible Controller. ## Requirements diff --git a/roles/schedules/meta/main.yml b/roles/schedules/meta/main.yml index 5f4cdc3cd..8950f55ec 100644 --- a/roles/schedules/meta/main.yml +++ b/roles/schedules/meta/main.yml @@ -40,7 +40,8 @@ collections: - ansible.controller - awx.awx -dependencies: [] -# List your role dependencies here, one per line. Be sure to remove the '[]' above, -# if you add dependencies to this list. +dependencies: + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. + - role: global_vars ... diff --git a/roles/schedules/tasks/main.yml b/roles/schedules/tasks/main.yml index 72a534285..1a869acb8 100644 --- a/roles/schedules/tasks/main.yml +++ b/roles/schedules/tasks/main.yml @@ -1,29 +1,29 @@ --- -- name: Add Controller Schedule +- name: "Managing Controller Schedules" schedule: name: "{{ __controller_schedule_item.name | mandatory }}" new_name: "{{ __controller_schedule_item.new_name | default(omit, true) }}" - description: "{{ __controller_schedule_item.description | default(( '' if controller_configuration_schedules_enforce_defaults else omit), true) }}" + description: "{{ __controller_schedule_item.description | default(('' if controller_configuration_schedules_enforce_defaults else omit), true) }}" rrule: "{{ __controller_schedule_item.rrule | default(omit, true) }}" - extra_data: "{{ __controller_schedule_item.extra_data | default(( {} if controller_configuration_schedules_enforce_defaults else omit), true) }}" - inventory: "{{ __controller_schedule_item.inventory | default(( '' if controller_configuration_schedules_enforce_defaults else omit), true) }}" + extra_data: "{{ __controller_schedule_item.extra_data | default(({} if controller_configuration_schedules_enforce_defaults else omit), true) }}" + inventory: "{{ __controller_schedule_item.inventory | default(('' if controller_configuration_schedules_enforce_defaults else omit), true) }}" credentials: "{{ __controller_schedule_item.credentials | default(omit, true) }}" - scm_branch: "{{ __controller_schedule_item.scm_branch | default(( '' if controller_configuration_schedules_enforce_defaults else omit), true) }}" - execution_environment: "{{ __controller_schedule_item.execution_environment.name | default(__controller_schedule_item.execution_environment | default(( '' if controller_configuration_schedules_enforce_defaults else omit), true)) }}" + scm_branch: "{{ __controller_schedule_item.scm_branch | default(('' if controller_configuration_schedules_enforce_defaults else omit), true) }}" + execution_environment: "{{ __controller_schedule_item.execution_environment.name | default(__controller_schedule_item.execution_environment | default(('' if controller_configuration_schedules_enforce_defaults else omit), true)) }}" forks: "{{ __controller_schedule_item.forks | default(omit, true) }}" instance_groups: "{{ __controller_schedule_item.instance_groups | default(omit, true) }}" - job_slice_count: "{{ __controller_schedule_item.job_slice_count | default(( 1 if controller_configuration_schedules_enforce_defaults else omit), true) }}" - labels: "{{ (__controller_schedule_item.related.labels | map(attribute='name') | list if __controller_schedule_item.related.labels is defined) | default(__controller_schedule_item.labels) | default(( [] if controller_configuration_schedules_enforce_defaults else omit), true) }}" + job_slice_count: "{{ __controller_schedule_item.job_slice_count | default((1 if controller_configuration_schedules_enforce_defaults else omit), true) }}" + labels: "{{ (__controller_schedule_item.related.labels | map(attribute='name') | list if __controller_schedule_item.related.labels is defined) | default(__controller_schedule_item.labels) | default(([] if controller_configuration_schedules_enforce_defaults else omit), true) }}" timeout: "{{ __controller_schedule_item.timeout | default(omit, true) }}" job_type: "{{ __controller_schedule_item.job_type | default(omit, true) }}" - job_tags: "{{ __controller_schedule_item.job_tags | default(( '' if controller_configuration_schedules_enforce_defaults else omit), true) }}" - skip_tags: "{{ __controller_schedule_item.skip_tags | default(( '' if controller_configuration_schedules_enforce_defaults else omit), true) }}" + job_tags: "{{ __controller_schedule_item.job_tags | default(('' if controller_configuration_schedules_enforce_defaults else omit), true) }}" + skip_tags: "{{ __controller_schedule_item.skip_tags | default(('' if controller_configuration_schedules_enforce_defaults else omit), true) }}" limit: "{{ __controller_schedule_item.limit | default(omit, true) }}" - diff_mode: "{{ __controller_schedule_item.diff_mode | default(( false if controller_configuration_schedules_enforce_defaults else omit)) }}" + diff_mode: "{{ __controller_schedule_item.diff_mode | default((false if controller_configuration_schedules_enforce_defaults else omit)) }}" verbosity: "{{ __controller_schedule_item.verbosity | default(omit, true) }}" - organization: "{{ __controller_schedule_item.organization | default(( '' if controller_configuration_schedules_enforce_defaults else omit), true) }}" + organization: "{{ __controller_schedule_item.organization | default(('' if controller_configuration_schedules_enforce_defaults else omit), true) }}" unified_job_template: "{{ __controller_schedule_item.unified_job_template | default(omit, true) }}" - enabled: "{{ __controller_schedule_item.enabled | default(( true if controller_configuration_schedules_enforce_defaults else omit)) }}" + enabled: "{{ __controller_schedule_item.enabled | default((true if controller_configuration_schedules_enforce_defaults else omit)) }}" state: "{{ __controller_schedule_item.state | default(controller_state | default('present')) }}" # Role Standard Options @@ -37,15 +37,17 @@ loop: "{{ schedules if schedules is defined else controller_schedules }}" loop_control: loop_var: "__controller_schedule_item" + label: "{{ __operation.verb }} Controller Schedule {{ __controller_schedule_item.name }}" no_log: "{{ controller_configuration_schedules_secure_logging }}" async: 1000 poll: 0 register: __controller_schedule_job_async changed_when: not __controller_schedule_job_async.changed vars: + __operation: "{{ operation_translate[__controller_schedule_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' -- name: "Configure Schedules | Wait for finish the Schedules creation" +- name: "Managing Schedules | Wait for finish the Schedules management" ansible.builtin.async_status: jid: "{{ __controller_schedule_job_async_results_item.ansible_job_id }}" register: __controller_schedule_job_async_result @@ -55,8 +57,10 @@ loop: "{{ __controller_schedule_job_async.results }}" loop_control: loop_var: __controller_schedule_job_async_results_item + label: "{{ __operation.verb }} Schedule {{ __controller_schedule_job_async_results_item.__controller_schedule_item.name }} | Wait for finish the Schedules {{ __operation.action }}" when: __controller_schedule_job_async_results_item.ansible_job_id is defined no_log: "{{ controller_configuration_schedules_secure_logging }}" vars: + __operation: "{{ operation_translate[__controller_schedule_job_async_results_item.__controller_schedule_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' ... diff --git a/roles/teams/README.md b/roles/teams/README.md index 2b891d700..3b575426c 100644 --- a/roles/teams/README.md +++ b/roles/teams/README.md @@ -2,7 +2,7 @@ ## Description -An Ansible Role to create Teams on Ansible Controller. +An Ansible Role to create/update/remove Teams on Ansible Controller. ## Requirements diff --git a/roles/teams/meta/main.yml b/roles/teams/meta/main.yml index 5f9dc5b7e..dd09b4a32 100644 --- a/roles/teams/meta/main.yml +++ b/roles/teams/meta/main.yml @@ -68,7 +68,8 @@ collections: - ansible.controller - awx.awx -dependencies: [] -# List your role dependencies here, one per line. Be sure to remove the '[]' above, -# if you add dependencies to this list. +dependencies: + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. + - role: global_vars ... diff --git a/roles/teams/tasks/main.yml b/roles/teams/tasks/main.yml index f128471bb..4e199d77a 100644 --- a/roles/teams/tasks/main.yml +++ b/roles/teams/tasks/main.yml @@ -1,9 +1,9 @@ --- -- name: Create Ansible Controller Team +- name: "Managing Ansible Controller Teams" team: name: "{{ __controller_team_item.name | mandatory }}" new_name: "{{ __controller_team_item.new_name | default(omit, true) }}" - description: "{{ __controller_team_item.description | default(( '' if controller_configuration_teams_enforce_defaults else omit), true) }}" + description: "{{ __controller_team_item.description | default(('' if controller_configuration_teams_enforce_defaults else omit), true) }}" organization: "{{ __controller_team_item.organization.name | default(__controller_team_item.organization) | mandatory }}" state: "{{ __controller_team_item.state | default(controller_state | default('present')) }}" @@ -18,15 +18,17 @@ loop: "{{ teams if teams is defined else controller_teams }}" loop_control: loop_var: __controller_team_item + label: "{{ __operation.verb }} Ansible Controller Team {{ __controller_team_item.name }}" no_log: "{{ controller_configuration_teams_secure_logging }}" async: 1000 poll: 0 register: __controller_team_job_async changed_when: not __controller_team_job_async.changed vars: + __operation: "{{ operation_translate[__controller_team_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' -- name: "Configure Teams | Wait for finish the Teams creation" +- name: "Managing Teams | Wait for finish the Teams management" ansible.builtin.async_status: jid: "{{ __controller_team_job_async_results_item.ansible_job_id }}" register: __controller_team_job_async_result @@ -36,8 +38,10 @@ loop: "{{ __controller_team_job_async.results }}" loop_control: loop_var: __controller_team_job_async_results_item + label: "{{ __operation.verb }} Teams | Wait for finish the Teams {{ __operation.action }}" when: __controller_team_job_async_results_item.ansible_job_id is defined no_log: "{{ controller_configuration_teams_secure_logging }}" vars: + __operation: "{{ operation_translate[__controller_team_job_asycn_results_item.__controller_team_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' ... diff --git a/roles/users/README.md b/roles/users/README.md index bc149fd7f..5ef0258a4 100644 --- a/roles/users/README.md +++ b/roles/users/README.md @@ -2,7 +2,7 @@ ## Description -An Ansible Role to add users to on Ansible Controller. +An Ansible Role to add/update/remove users to on Ansible Controller. ## Requirements diff --git a/roles/users/meta/main.yml b/roles/users/meta/main.yml index 53efaeade..2217124a4 100644 --- a/roles/users/meta/main.yml +++ b/roles/users/meta/main.yml @@ -40,7 +40,8 @@ collections: - ansible.controller - awx.awx -dependencies: [] -# List your role dependencies here, one per line. Be sure to remove the '[]' above, -# if you add dependencies to this list. +dependencies: + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. + - role: global_vars ... diff --git a/roles/users/tasks/main.yml b/roles/users/tasks/main.yml index 9856407fa..ef376e864 100644 --- a/roles/users/tasks/main.yml +++ b/roles/users/tasks/main.yml @@ -1,7 +1,7 @@ --- -# The user module is also an ansible.builtin module, but due to supporting both the awx.awx and automation.controller collections +# The user module is also an ansible.builtin module, but due to supporting both the awx.awx and automation.Controller collections # the FQCN cannot be used here. -- name: Add controller user # noqa fqcn[action-core] +- name: "Managing Controller Users" # noqa fqcn[action-core] user: username: "{{ __controller_user_accounts_item.user | default(__controller_user_accounts_item.username) | mandatory }}" new_username: "{{ __controller_user_accounts_item.new_username | default(omit, true) }}" @@ -10,9 +10,9 @@ email: "{{ __controller_user_accounts_item.email | default(omit, true) }}" first_name: "{{ __controller_user_accounts_item.firstname | default(__controller_user_accounts_item.first_name | default(omit, true)) }}" last_name: "{{ __controller_user_accounts_item.lastname | default(__controller_user_accounts_item.last_name | default(omit, true)) }}" - is_superuser: "{{ __controller_user_accounts_item.is_superuser | default(__controller_user_accounts_item.superuser | default(( false if controller_configuration_users_enforce_defaults else omit))) }}" - is_system_auditor: "{{ __controller_user_accounts_item.is_auditor | default(__controller_user_accounts_item.is_system_auditor | default(( false if controller_configuration_users_enforce_defaults else omit))) }}" - update_secrets: "{{ __controller_user_accounts_item.update_secrets | default(( false if controller_configuration_users_enforce_defaults else omit)) }}" + is_superuser: "{{ __controller_user_accounts_item.is_superuser | default(__controller_user_accounts_item.superuser | default((false if controller_configuration_users_enforce_defaults else omit))) }}" + is_system_auditor: "{{ __controller_user_accounts_item.is_auditor | default(__controller_user_accounts_item.is_system_auditor | default((false if controller_configuration_users_enforce_defaults else omit))) }}" + update_secrets: "{{ __controller_user_accounts_item.update_secrets | default((false if controller_configuration_users_enforce_defaults else omit)) }}" organization: "{{ __controller_user_accounts_item.organization | default(omit) }}" state: "{{ __controller_user_accounts_item.state | default(controller_state | default(omit, true)) }}" @@ -27,15 +27,17 @@ loop: "{{ users if users is defined else controller_user_accounts }}" loop_control: loop_var: __controller_user_accounts_item + label: "{{ __operation.verb }} Controller User {{ __controller_user_accounts_item.user | default(__controller_user_accounts_item.username) }}" no_log: "{{ controller_configuration_users_secure_logging }}" async: 1000 poll: 0 register: __controller_user_accounts_job_async changed_when: not __controller_user_accounts_job_async.changed vars: + __operation: "{{ operation_translate[__controller_user_accounts_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' -- name: "Configure Users | Wait for finish the Users creation" +- name: "Managing Users | Wait for finish the Users management" ansible.builtin.async_status: jid: "{{ __controller_user_accounts_job_async_results_item.ansible_job_id }}" register: __controller_user_accounts_job_async_result @@ -45,8 +47,10 @@ loop: "{{ __controller_user_accounts_job_async.results }}" loop_control: loop_var: __controller_user_accounts_job_async_results_item + label: "{{ __operation.verb }} User {{ __controller_user_accounts_job_async_results_item.__controller_user_accounts_item.user | default(__controller_user_accounts_job_async_results_item.__controller_user_accounts_item.username) }} | Wait for finish the Users {{ __operation.action }}" when: __controller_user_accounts_job_async_results_item.ansible_job_id is defined no_log: "{{ controller_configuration_users_secure_logging }}" vars: + __operation: "{{ operation_translate[__controller_user_accounts_job_async_results_item.__controller_user_accounts_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' ... diff --git a/roles/workflow_job_templates/README.md b/roles/workflow_job_templates/README.md index 52692219b..b557d592b 100644 --- a/roles/workflow_job_templates/README.md +++ b/roles/workflow_job_templates/README.md @@ -2,7 +2,7 @@ ## Description -An Ansible Role to create Workflow Job Templates on Ansible Controller. +An Ansible Role to create/update/remove Workflow Job Templates on Ansible Controller. ## Requirements diff --git a/roles/workflow_job_templates/meta/main.yml b/roles/workflow_job_templates/meta/main.yml index 563c01781..7e1f66594 100644 --- a/roles/workflow_job_templates/meta/main.yml +++ b/roles/workflow_job_templates/meta/main.yml @@ -41,7 +41,8 @@ collections: - ansible.controller - awx.awx -dependencies: [] -# List your role dependencies here, one per line. Be sure to remove the '[]' above, -# if you add dependencies to this list. +dependencies: + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. + - role: global_vars ... diff --git a/roles/workflow_job_templates/tasks/add_workflows_schema.yml b/roles/workflow_job_templates/tasks/add_workflows_schema.yml index 5f83a9159..f7a010a94 100644 --- a/roles/workflow_job_templates/tasks/add_workflows_schema.yml +++ b/roles/workflow_job_templates/tasks/add_workflows_schema.yml @@ -1,6 +1,6 @@ --- # Creating Workflow Node -- name: Create the Workflow Node +- name: Create the Workflow Nodes workflow_job_template_node: identifier: "{{ __workflow_loop_node_item.identifier | mandatory }}" # internal identification ID extra_data: "{{ __workflow_loop_node_item.extra_data | default(omit, true) }}" @@ -47,7 +47,7 @@ vars: ansible_async_dir: '{{ controller_configuration_async_dir }}' -- name: "Manage Workflows | Wait for finish the workflow creation" +- name: "Create the Workflow Nodes | Wait for finish the Workflow Nodes creation" ansible.builtin.async_status: jid: "{{ __workflows_node_async_results_item.ansible_job_id }}" register: __workflows_node_async_result diff --git a/roles/workflow_job_templates/tasks/main.yml b/roles/workflow_job_templates/tasks/main.yml index 266eaaab7..d0ab05f6c 100644 --- a/roles/workflow_job_templates/tasks/main.yml +++ b/roles/workflow_job_templates/tasks/main.yml @@ -1,38 +1,37 @@ --- -# Create Workflow -- name: Manage Workflows +- name: "Managing Workflows" workflow_job_template: name: "{{ __workflow_loop_item.name | mandatory }}" new_name: "{{ __workflow_loop_item.new_name | default(omit, true) }}" copy_from: "{{ __workflow_loop_item.copy_from | default(omit, true) }}" - description: "{{ __workflow_loop_item.description | default(( '' if controller_configuration_workflows_enforce_defaults else omit), true) }}" - extra_vars: "{{ __workflow_loop_item.extra_vars | default(( {} if controller_configuration_workflows_enforce_defaults else omit), true) }}" - allow_simultaneous: "{{ __workflow_loop_item.allow_simultaneous | default(( false if controller_configuration_workflows_enforce_defaults else omit)) }}" - organization: "{{ __workflow_loop_item.organization.name | default(__workflow_loop_item.organization | default(( '' if controller_configuration_workflows_enforce_defaults else omit), true)) }}" - ask_variables_on_launch: "{{ __workflow_loop_item.ask_variables_on_launch | default(( false if controller_configuration_workflows_enforce_defaults else omit)) }}" - inventory: "{{ __workflow_loop_item.inventory.name | default(__workflow_loop_item.inventory | default(( '' if controller_configuration_workflows_enforce_defaults else omit), true)) }}" - limit: "{{ __workflow_loop_item.limit | default(( 0 if controller_configuration_workflows_enforce_defaults else omit), true) }}" - labels: "{{ (__workflow_loop_item.related.labels | map(attribute='name') | list if __workflow_loop_item.related.labels is defined) | default(__workflow_loop_item.labels) | default(( [] if controller_configuration_workflows_enforce_defaults else omit), true) }}" - scm_branch: "{{ __workflow_loop_item.scm_branch | default(( '' if controller_configuration_workflows_enforce_defaults else omit), true) }}" - ask_inventory_on_launch: "{{ __workflow_loop_item.ask_inventory_on_launch | default(( false if controller_configuration_workflows_enforce_defaults else omit)) }}" - ask_scm_branch_on_launch: "{{ __workflow_loop_item.ask_scm_branch_on_launch | default(( false if controller_configuration_workflows_enforce_defaults else omit)) }}" - ask_limit_on_launch: "{{ __workflow_loop_item.ask_limit_on_launch | default(( false if controller_configuration_workflows_enforce_defaults else omit)) }}" + description: "{{ __workflow_loop_item.description | default(('' if controller_configuration_workflows_enforce_defaults else omit), true) }}" + extra_vars: "{{ __workflow_loop_item.extra_vars | default(({} if controller_configuration_workflows_enforce_defaults else omit), true) }}" + allow_simultaneous: "{{ __workflow_loop_item.allow_simultaneous | default((false if controller_configuration_workflows_enforce_defaults else omit)) }}" + organization: "{{ __workflow_loop_item.organization.name | default(__workflow_loop_item.organization | default(('' if controller_configuration_workflows_enforce_defaults else omit), true)) }}" + ask_variables_on_launch: "{{ __workflow_loop_item.ask_variables_on_launch | default((false if controller_configuration_workflows_enforce_defaults else omit)) }}" + inventory: "{{ __workflow_loop_item.inventory.name | default(__workflow_loop_item.inventory | default(('' if controller_configuration_workflows_enforce_defaults else omit), true)) }}" + limit: "{{ __workflow_loop_item.limit | default((0 if controller_configuration_workflows_enforce_defaults else omit), true) }}" + labels: "{{ (__workflow_loop_item.related.labels | map(attribute='name') | list if __workflow_loop_item.related.labels is defined) | default(__workflow_loop_item.labels) | default(([] if controller_configuration_workflows_enforce_defaults else omit), true) }}" + scm_branch: "{{ __workflow_loop_item.scm_branch | default(('' if controller_configuration_workflows_enforce_defaults else omit), true) }}" + ask_inventory_on_launch: "{{ __workflow_loop_item.ask_inventory_on_launch | default((false if controller_configuration_workflows_enforce_defaults else omit)) }}" + ask_scm_branch_on_launch: "{{ __workflow_loop_item.ask_scm_branch_on_launch | default((false if controller_configuration_workflows_enforce_defaults else omit)) }}" + ask_limit_on_launch: "{{ __workflow_loop_item.ask_limit_on_launch | default((false if controller_configuration_workflows_enforce_defaults else omit)) }}" webhook_service: "{{ __workflow_loop_item.webhook_service | default(omit, true) }}" webhook_credential: "{{ __workflow_loop_item.webhook_credential.name | default(__workflow_loop_item.webhook_credential | default(omit, true)) }}" - survey_enabled: "{{ __workflow_loop_item.survey_enabled | default(( false if controller_configuration_workflows_enforce_defaults else omit)) }}" - survey_spec: "{{ __workflow_loop_item.related.survey_spec | default(__workflow_loop_item.survey_spec | default(__workflow_loop_item.survey | default(( {} if controller_configuration_workflows_enforce_defaults else omit), true))) }}" - job_tags: "{{ __workflow_loop_item.job_tags | default(( '' if controller_configuration_workflows_enforce_defaults else omit), true) }}" - skip_tags: "{{ __workflow_loop_item.skip_tags | default(( '' if controller_configuration_workflows_enforce_defaults else omit), true) }}" - ask_tags_on_launch: "{{ __workflow_loop_item.ask_tags | default(__workflow_loop_item.ask_tags_on_launch | default(( false if controller_configuration_workflows_enforce_defaults else omit))) }}" - ask_labels_on_launch: "{{ __workflow_loop_item.ask_labels_on_launch | default(( false if controller_configuration_workflows_enforce_defaults else omit)) }}" - ask_skip_tags_on_launch: "{{ __workflow_loop_item.ask_skip_tags | default(__workflow_loop_item.ask_skip_tags_on_launch | default(( false if controller_configuration_workflows_enforce_defaults else omit))) }}" - workflow_nodes: "{{ __workflow_loop_item.related.workflow_nodes | default(__workflow_loop_item.workflow_nodes | default(( [] if controller_configuration_workflows_enforce_defaults else omit), true)) }}" - destroy_current_nodes: "{{ __workflow_loop_item.destroy_current_nodes | default(__workflow_loop_item.destroy_current_schema | default(( false if controller_configuration_workflows_enforce_defaults else omit))) }}" + survey_enabled: "{{ __workflow_loop_item.survey_enabled | default((false if controller_configuration_workflows_enforce_defaults else omit)) }}" + survey_spec: "{{ __workflow_loop_item.related.survey_spec | default(__workflow_loop_item.survey_spec | default(__workflow_loop_item.survey | default(({} if controller_configuration_workflows_enforce_defaults else omit), true))) }}" + job_tags: "{{ __workflow_loop_item.job_tags | default(('' if controller_configuration_workflows_enforce_defaults else omit), true) }}" + skip_tags: "{{ __workflow_loop_item.skip_tags | default(('' if controller_configuration_workflows_enforce_defaults else omit), true) }}" + ask_tags_on_launch: "{{ __workflow_loop_item.ask_tags | default(__workflow_loop_item.ask_tags_on_launch | default((false if controller_configuration_workflows_enforce_defaults else omit))) }}" + ask_labels_on_launch: "{{ __workflow_loop_item.ask_labels_on_launch | default((false if controller_configuration_workflows_enforce_defaults else omit)) }}" + ask_skip_tags_on_launch: "{{ __workflow_loop_item.ask_skip_tags | default(__workflow_loop_item.ask_skip_tags_on_launch | default((false if controller_configuration_workflows_enforce_defaults else omit))) }}" + workflow_nodes: "{{ __workflow_loop_item.related.workflow_nodes | default(__workflow_loop_item.workflow_nodes | default(([] if controller_configuration_workflows_enforce_defaults else omit), true)) }}" + destroy_current_nodes: "{{ __workflow_loop_item.destroy_current_nodes | default(__workflow_loop_item.destroy_current_schema | default((false if controller_configuration_workflows_enforce_defaults else omit))) }}" state: "{{ __workflow_loop_item.state | default(controller_state | default('present')) }}" - notification_templates_started: "{{ (__workflow_loop_item.related.notification_templates_started | map(attribute='name') | list if __workflow_loop_item.related.notification_templates_started is defined) | default(__workflow_loop_item.notification_templates_started) | default(( [] if controller_configuration_workflows_enforce_defaults else omit), true) }}" - notification_templates_success: "{{ (__workflow_loop_item.related.notification_templates_success | map(attribute='name') | list if __workflow_loop_item.related.notification_templates_success is defined) | default(__workflow_loop_item.notification_templates_success) | default(( [] if controller_configuration_workflows_enforce_defaults else omit), true) }}" - notification_templates_error: "{{ (__workflow_loop_item.related.notification_templates_error | map(attribute='name') | list if __workflow_loop_item.related.notification_templates_error is defined) | default(__workflow_loop_item.notification_templates_error) | default(( [] if controller_configuration_workflows_enforce_defaults else omit), true) }}" - notification_templates_approvals: "{{ (__workflow_loop_item.related.notification_templates_approvals | map(attribute='name') | list if __workflow_loop_item.related.notification_templates_approvals is defined) | default(__workflow_loop_item.notification_templates_approvals) | default(( [] if controller_configuration_workflows_enforce_defaults else omit), true) }}" + notification_templates_started: "{{ (__workflow_loop_item.related.notification_templates_started | map(attribute='name') | list if __workflow_loop_item.related.notification_templates_started is defined) | default(__workflow_loop_item.notification_templates_started) | default(([] if controller_configuration_workflows_enforce_defaults else omit), true) }}" + notification_templates_success: "{{ (__workflow_loop_item.related.notification_templates_success | map(attribute='name') | list if __workflow_loop_item.related.notification_templates_success is defined) | default(__workflow_loop_item.notification_templates_success) | default(([] if controller_configuration_workflows_enforce_defaults else omit), true) }}" + notification_templates_error: "{{ (__workflow_loop_item.related.notification_templates_error | map(attribute='name') | list if __workflow_loop_item.related.notification_templates_error is defined) | default(__workflow_loop_item.notification_templates_error) | default(([] if controller_configuration_workflows_enforce_defaults else omit), true) }}" + notification_templates_approvals: "{{ (__workflow_loop_item.related.notification_templates_approvals | map(attribute='name') | list if __workflow_loop_item.related.notification_templates_approvals is defined) | default(__workflow_loop_item.notification_templates_approvals) | default(([] if controller_configuration_workflows_enforce_defaults else omit), true) }}" # Role Standard Options controller_username: "{{ controller_username | default(omit, true) }}" @@ -45,15 +44,17 @@ loop: "{{ workflow_job_templates if workflow_job_templates is defined else controller_workflows }}" loop_control: loop_var: __workflow_loop_item + label: "{{ __operation.verb }} Workflow {{ __workflow_loop_item.name }}" no_log: "{{ workflow_job_templates_secure_logging }}" async: 1000 poll: 0 register: __workflows_job_async changed_when: not __workflows_job_async.changed vars: + __operation: "{{ operation_translate[__workflow_loop_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' -- name: "Manage Workflows | Wait for finish the workflow creation" +- name: "Managing Workflows | Wait for finish the workflow management" ansible.builtin.async_status: jid: "{{ __workflows_job_async_results_item.ansible_job_id }}" register: __workflows_job_async_result @@ -63,15 +64,17 @@ loop: "{{ __workflows_job_async.results }}" loop_control: loop_var: __workflows_job_async_results_item + label: "{{ __operation.verb }} Workflow {{ __workflows_job_async_results_item.__workflow_loop_item.name }} | Wait for finish the workflow {{ __operation.action }}" when: __workflows_job_async_results_item.ansible_job_id is defined no_log: "{{ workflow_job_templates_secure_logging }}" vars: + __operation: "{{ operation_translate[__workflows_job_async_results_item.__workflow_loop_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' # Create links between workflow node - name: Loop over nodes in schema to add to workflow templates ansible.builtin.include_tasks: "add_workflows_schema.yml" - loop: "{{ controller_workflows | default( workflow_job_templates ) }}" + loop: "{{ controller_workflows | default(workflow_job_templates) }}" loop_control: loop_var: __workflow_loop_item when: diff --git a/tests/configure_controller.yml b/tests/configure_controller.yml index 31d52fdbc..281b48fd8 100644 --- a/tests/configure_controller.yml +++ b/tests/configure_controller.yml @@ -170,7 +170,7 @@ controller_password: "{{ controller_password }}" controller_host: "{{ controller_hostname }}" validate_certs: "{{ controller_validate_certs }}" - ignore_errors: true ## noqa ignore-errors + ignore_errors: true # noqa ignore-errors - name: Get the organization ID ansible.builtin.set_fact: diff --git a/tests/templated_role_example/defaults/main.yml b/tests/templated_role_example/defaults/main.yml index 4ea251aa9..345082a5e 100644 --- a/tests/templated_role_example/defaults/main.yml +++ b/tests/templated_role_example/defaults/main.yml @@ -1,5 +1,5 @@ --- -controller_configuration_*******_secure_logging: "{{controller_configuration_secure_logging | default('false')}}" +controller_configuration_*******_secure_logging: "{{controller_configuration_secure_logging | default('false') }}" controller_configuration_***********_async_retries: "{{ controller_configuration_async_retries | default(30) }}" controller_configuration_***********_async_delay: "{{ controller_configuration_async_delay | default(1) }}" controller_configuration_async_dir: null