From f9ec9c739b8d6723346892fba00a58d71c12a131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Aragon=C3=A9s=20Muniesa?= <26822043+ivarmu@users.noreply.github.com> Date: Thu, 2 Nov 2023 10:49:08 +0100 Subject: [PATCH 1/2] Added exportation from api/v2/constructed_inventories endpoint. (#712) * Added exportation from api/v2/constructed_inventories endpoint. Added exportation for the smart inventories * add changelog fragment * remove commented lines * minor typo fix --- ..._create_export_constructed_inventories.yml | 2 + roles/filetree_create/tasks/all.yml | 3 ++ .../tasks/constructed_inventory.yml | 41 +++++++++++++++++++ roles/filetree_create/tasks/inventory.yml | 9 ++-- .../templates/current_inventories.j2 | 20 ++++++++- roles/inventories/tasks/main.yml | 2 +- 6 files changed, 70 insertions(+), 7 deletions(-) create mode 100644 changelogs/fragments/filetree_create_export_constructed_inventories.yml create mode 100644 roles/filetree_create/tasks/constructed_inventory.yml diff --git a/changelogs/fragments/filetree_create_export_constructed_inventories.yml b/changelogs/fragments/filetree_create_export_constructed_inventories.yml new file mode 100644 index 000000000..ca538f982 --- /dev/null +++ b/changelogs/fragments/filetree_create_export_constructed_inventories.yml @@ -0,0 +1,2 @@ +minor_changes: + - filetree_create - Add the constructed inventory exportation fields from the API endpoint `api/v2/constructed_inventories` diff --git a/roles/filetree_create/tasks/all.yml b/roles/filetree_create/tasks/all.yml index d00f00e67..b3059bd6d 100644 --- a/roles/filetree_create/tasks/all.yml +++ b/roles/filetree_create/tasks/all.yml @@ -30,6 +30,9 @@ - name: "Export Inventories and related Groups and Hosts" ansible.builtin.include_tasks: "inventory.yml" when: "'inventory' in input_tag or 'all' in input_tag" + - name: "Export Constructed Inventories" + ansible.builtin.include_tasks: "constructed_inventory.yml" + when: "'inventory' in input_tag or 'all' in input_tag" - name: "Export Credentials" ansible.builtin.include_tasks: "credentials.yml" when: "'credentials' in input_tag or 'all' in input_tag" diff --git a/roles/filetree_create/tasks/constructed_inventory.yml b/roles/filetree_create/tasks/constructed_inventory.yml new file mode 100644 index 000000000..1b35fa374 --- /dev/null +++ b/roles/filetree_create/tasks/constructed_inventory.yml @@ -0,0 +1,41 @@ +--- +- name: "Get the inventories from the API" + ansible.builtin.set_fact: + constructed_inventory_lookvar: "{{ query(controller_api_plugin, 'api/v2/constructed_inventories/', + query_params=(query_params | combine({'organization': organization_id})) if organization_id is defined else query_params, + host=controller_hostname, oauth_token=controller_oauthtoken, verify_ssl=controller_validate_certs, + return_all=true, max_objects=query_controller_api_max_objects) + }}" + vars: + query_params: + order_by: 'organization,id' + no_log: "{{ controller_configuration_filetree_create_secure_logging }}" + +- name: "Create the /inventories output directory for inventories in {{ output_path }}" + ansible.builtin.file: + path: "{{ __path }}" + state: directory + mode: '0755' + vars: + inventory_organization: "{{ needed_path.summary_fields.organization.name | default('ORGANIZATIONLESS') }}" + inventory_name: "{{ needed_path.name | regex_replace('/', '_') }}" + __path: "{{ output_path }}/{{ inventory_organization | regex_replace('/', '_') }}/inventories/{{ inventory_name | regex_replace('/', '_') }}" + loop: "{{ constructed_inventory_lookvar }}" + loop_control: + loop_var: needed_path + label: "{{ __path }}" + +- name: "Add current constructed_inventories to the /inventories output yaml file in {{ output_path }}" + ansible.builtin.template: + src: "templates/current_inventories.j2" + dest: "{{ __dest }}" + mode: '0644' + vars: + inventory_organization: "{{ current_inventories_asset_value.summary_fields.organization.name | default('ORGANIZATIONLESS') }}" + inventory_name: "{{ current_inventories_asset_value.name | regex_replace('/', '_') }}" + __dest: "{{ output_path }}/{{ inventory_organization | regex_replace('/', '_') }}/inventories/{{ inventory_name | regex_replace('/', '_') }}/{{ current_inventories_asset_value.id }}_{{ inventory_name | regex_replace('/', '_') }}.yaml" + loop: "{{ constructed_inventory_lookvar }}" + loop_control: + loop_var: current_inventories_asset_value + label: "{{ __dest }}" +... diff --git a/roles/filetree_create/tasks/inventory.yml b/roles/filetree_create/tasks/inventory.yml index de03c090b..93f5e0d86 100644 --- a/roles/filetree_create/tasks/inventory.yml +++ b/roles/filetree_create/tasks/inventory.yml @@ -8,7 +8,7 @@ }}" vars: query_params: - not__kind: 'smart' + not__kind: 'constructed' order_by: 'organization,id' no_log: "{{ controller_configuration_filetree_create_secure_logging }}" @@ -76,14 +76,15 @@ - name: "Set the inventory's groups" ansible.builtin.include_tasks: "groups.yml" + when: current_inventory_groups.total_groups > 0 vars: inventory_organization: "{{ current_inventory_groups.summary_fields.organization.name | default('ORGANIZATIONLESS') }}" inventory_name: "{{ current_inventory_groups.name | regex_replace('/', '_') }}" groups_output_path: "{{ output_path }}/{{ inventory_organization | regex_replace('/', '_') }}/inventories/{{ inventory_name | regex_replace('/', '_') }}" current_groups_asset_value: "{{ query(controller_api_plugin, current_inventory_groups.related.groups, - host=controller_hostname, oauth_token=controller_oauthtoken, verify_ssl=controller_validate_certs, - return_all=true, max_objects=query_controller_api_max_objects) - if not current_inventory_groups.has_inventory_sources else [] + host=controller_hostname, oauth_token=controller_oauthtoken, verify_ssl=controller_validate_certs, + return_all=true, max_objects=query_controller_api_max_objects) + if (not current_inventory_groups.has_inventory_sources or current_inventory_groups.kind is match('smart')) else [] }}" loop: "{{ inventory_lookvar }}" loop_control: diff --git a/roles/filetree_create/templates/current_inventories.j2 b/roles/filetree_create/templates/current_inventories.j2 index fadc76324..e82330541 100644 --- a/roles/filetree_create/templates/current_inventories.j2 +++ b/roles/filetree_create/templates/current_inventories.j2 @@ -3,13 +3,29 @@ controller_inventories: - name: "{{ current_inventories_asset_value.name }}" description: "{{ current_inventories_asset_value.description }}" organization: "{{ inventory_organization }}" -{% if current_inventories_asset_value.host_filter %} +{% if current_inventories_asset_value.host_filter is defined %} host_filter: "{{ current_inventories_asset_value.host_filter }}" {% endif %} {% if current_inventories_asset_value.kind %} kind: "{{ current_inventories_asset_value.kind }}" {% endif %} -{% if current_inventories_asset_value.variables and current_inventories_asset_value.variables != '---' and current_inventories_asset_value.variables != '' %} +{% if current_inventories_asset_value.prevent_instance_group_fallback is defined %} + prevent_instance_group_fallback: {{ current_inventories_asset_value.prevent_instance_group_fallback }} +{% endif %} +{% if current_inventories_asset_value.source_vars is defined %} + source_vars: + {{ current_inventories_asset_value.source_vars | from_yaml | to_nice_yaml(indent=2) | indent(width=6, first=False) | replace("'{{", "!unsafe \'{{") }} +{% endif %} +{% if current_inventories_asset_value.update_cache_timeout is defined %} + update_cache_timeout: {{ current_inventories_asset_value.update_cache_timeout }} +{% endif %} +{% if current_inventories_asset_value.limit is defined %} + limit: "{{ current_inventories_asset_value.limit }}" +{% endif %} +{% if current_inventories_asset_value.verbosity is defined %} + verbosity: {{ current_inventories_asset_value.verbosity }} +{% endif %} +{% if current_inventories_asset_value.variables is defined and current_inventories_asset_value.variables != '---' and current_inventories_asset_value.variables != '' %} variables: {{ current_inventories_asset_value.variables | from_yaml | to_nice_yaml(indent=2) | indent(width=6, first=False) | replace("'{{", "!unsafe \'{{") }} {%- endif %} diff --git a/roles/inventories/tasks/main.yml b/roles/inventories/tasks/main.yml index e3b9f88c8..7fe54b44d 100644 --- a/roles/inventories/tasks/main.yml +++ b/roles/inventories/tasks/main.yml @@ -45,7 +45,7 @@ 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 }}" + label: "{{ __operation.verb }} Controller inventory {{ __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: From a20e97c31ab762017bb355ca1bd9a86b9f708331 Mon Sep 17 00:00:00 2001 From: Bob van Bokkem Date: Thu, 2 Nov 2023 13:00:35 +0100 Subject: [PATCH 2/2] Feature: improve checkmode outputs (#715) * Add tweaks for better checkmode readability * [squash] add trigger * [squash] remove trigger --- roles/applications/tasks/main.yml | 9 ++++++-- roles/bulk_host_create/tasks/main.yml | 9 ++++++-- roles/bulk_job_launch/tasks/main.yml | 1 + roles/credential_input_sources/tasks/main.yml | 9 ++++++-- roles/credential_types/tasks/main.yml | 9 ++++++-- roles/credentials/tasks/main.yml | 9 ++++++-- roles/dispatch/tasks/main.yml | 5 +++++ roles/execution_environments/tasks/main.yml | 9 ++++++-- .../templates/current_users.j2 | 2 +- roles/groups/tasks/main.yml | 9 ++++++-- roles/hosts/tasks/main.yml | 9 ++++++-- roles/instance_groups/tasks/main.yml | 9 ++++++-- roles/instances/tasks/main.yml | 10 +++++++-- roles/inventories/tasks/main.yml | 9 ++++++-- roles/inventory_source_update/tasks/main.yml | 14 ++++++++---- roles/inventory_sources/tasks/main.yml | 9 ++++++-- roles/job_launch/tasks/main.yml | 1 + roles/job_templates/tasks/main.yml | 9 ++++++-- roles/labels/tasks/main.yml | 9 ++++++-- roles/notification_templates/tasks/main.yml | 9 ++++++-- roles/organizations/tasks/main.yml | 9 ++++++-- roles/project_update/tasks/main.yml | 10 +++++++-- roles/projects/tasks/main.yml | 9 ++++++-- roles/roles/tasks/main.yml | 9 ++++++-- roles/schedules/tasks/main.yml | 9 ++++++-- roles/settings/tasks/main.yml | 10 +++++++-- roles/teams/tasks/main.yml | 9 ++++++-- roles/users/tasks/main.yml | 9 ++++++-- .../tasks/add_workflows_schema.yml | 22 ++++++++++++++----- roles/workflow_job_templates/tasks/main.yml | 9 ++++++-- roles/workflow_launch/tasks/main.yml | 3 ++- 31 files changed, 208 insertions(+), 59 deletions(-) diff --git a/roles/applications/tasks/main.yml b/roles/applications/tasks/main.yml index ad046c9f8..5f5eb7a0f 100644 --- a/roles/applications/tasks/main.yml +++ b/roles/applications/tasks/main.yml @@ -25,7 +25,7 @@ loop_var: "__application_item" label: "{{ __operation.verb }} Controller Application {{ __application_item.name }}" no_log: "{{ controller_configuration_applications_secure_logging }}" - async: 1000 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __applications_job_async changed_when: not __applications_job_async.changed @@ -33,6 +33,11 @@ __operation: "{{ operation_translate[__application_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __applications_job_async.failed is defined and __applications_job_async.failed + - name: "Managing Controller Applications | Wait for finish the Application management" ansible.builtin.async_status: jid: "{{ __applications_job_async_results_item.ansible_job_id }}" @@ -44,7 +49,7 @@ 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 + when: not ansible_check_mode and __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')] }}" diff --git a/roles/bulk_host_create/tasks/main.yml b/roles/bulk_host_create/tasks/main.yml index bc85adb99..412476df8 100644 --- a/roles/bulk_host_create/tasks/main.yml +++ b/roles/bulk_host_create/tasks/main.yml @@ -17,13 +17,18 @@ loop_control: loop_var: __controller_bulk_hosts_item no_log: "{{ controller_configuration_bulk_hosts_secure_logging }}" - async: 1000 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __controller_bulk_hosts_job_async changed_when: not __controller_bulk_hosts_job_async.changed vars: ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __controller_bulk_hosts_job_async.failed is defined and __controller_bulk_hosts_job_async.failed + - name: "Configure bulk_hosts | Wait for finish the bulk_hosts creation" ansible.builtin.async_status: jid: "{{ __controller_bulk_hosts_job_async_results_item.ansible_job_id }}" @@ -34,7 +39,7 @@ loop: "{{ __controller_bulk_hosts_job_async.results }}" loop_control: loop_var: __controller_bulk_hosts_job_async_results_item - when: __controller_bulk_hosts_job_async_results_item.ansible_job_id is defined + when: not ansible_check_mode and __controller_bulk_hosts_job_async_results_item.ansible_job_id is defined no_log: "{{ controller_configuration_bulk_hosts_secure_logging }}" vars: ansible_async_dir: '{{ controller_configuration_async_dir }}' diff --git a/roles/bulk_job_launch/tasks/main.yml b/roles/bulk_job_launch/tasks/main.yml index a3446b567..3fb6237af 100644 --- a/roles/bulk_job_launch/tasks/main.yml +++ b/roles/bulk_job_launch/tasks/main.yml @@ -26,6 +26,7 @@ loop: "{{ controller_bulk_launch_jobs }}" loop_control: loop_var: "__bulk_job_launch_item" + label: "{{ (__bulk_job_launch_item.organization | default('')) }}/{{ __bulk_job_launch_item.name }}" no_log: "{{ controller_configuration_bulk_job_launch_secure_logging }}" register: bulk_launched_controller_jobs when: controller_bulk_launch_jobs is defined diff --git a/roles/credential_input_sources/tasks/main.yml b/roles/credential_input_sources/tasks/main.yml index 854718ade..462bd7f97 100644 --- a/roles/credential_input_sources/tasks/main.yml +++ b/roles/credential_input_sources/tasks/main.yml @@ -21,7 +21,7 @@ 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 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __credential_input_sources_job_async changed_when: not __credential_input_sources_job_async.changed @@ -29,6 +29,11 @@ __operation: "{{ operation_translate[__cred_input_src_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __credential_input_sources_job_async.failed is defined and __credential_input_sources_job_async.failed + - 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 }}" @@ -40,7 +45,7 @@ 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 + when: not ansible_check_mode and __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')] }}" diff --git a/roles/credential_types/tasks/main.yml b/roles/credential_types/tasks/main.yml index 9b09bab67..9b79ced2f 100644 --- a/roles/credential_types/tasks/main.yml +++ b/roles/credential_types/tasks/main.yml @@ -22,7 +22,7 @@ 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 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __credentialtypes_job_async changed_when: not __credentialtypes_job_async.changed @@ -30,6 +30,11 @@ __operation: "{{ operation_translate[__controller_credential_type_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __credentialtypes_job_async.failed is defined and __credentialtypes_job_async.failed + - 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 }}" @@ -41,7 +46,7 @@ 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 + when: not ansible_check_mode and __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')] }}" diff --git a/roles/credentials/tasks/main.yml b/roles/credentials/tasks/main.yml index 810c09a43..74e46d13e 100644 --- a/roles/credentials/tasks/main.yml +++ b/roles/credentials/tasks/main.yml @@ -25,7 +25,7 @@ loop_var: __controller_credentials_item label: "{{ __operation.verb }} Credential {{ __controller_credentials_item.name }}" no_log: "{{ controller_configuration_credentials_secure_logging }}" - async: 1000 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __credentials_job_async changed_when: not __credentials_job_async.changed @@ -33,6 +33,11 @@ __operation: "{{ operation_translate[__controller_credentials_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __credentials_job_async.failed is defined and __credentials_job_async.failed + - name: "Managing Controller Credentials | Wait for finish the credential management" ansible.builtin.async_status: jid: "{{ __credentials_job_async_results_item.ansible_job_id }}" @@ -44,7 +49,7 @@ loop_control: loop_var: __credentials_job_async_results_item 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 + when: not ansible_check_mode and __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')] }}" diff --git a/roles/dispatch/tasks/main.yml b/roles/dispatch/tasks/main.yml index 34a25fba0..4c661165c 100644 --- a/roles/dispatch/tasks/main.yml +++ b/roles/dispatch/tasks/main.yml @@ -12,4 +12,9 @@ vars: assign_galaxy_credentials_to_org: "{{ __role.assign_galaxy_credentials_to_org | default(false) }}" assign_default_ee_to_org: "{{ __role.assign_default_ee_to_org | default(false) }}" + +- name: "Fail the playbook if there were errors (check mode only)" + ansible.builtin.fail: + msg: "The execution has failed because of errors (probably due to missing dependencies caused by check mode)." + when: ansible_check_mode and error_flag is defined and error_flag ... diff --git a/roles/execution_environments/tasks/main.yml b/roles/execution_environments/tasks/main.yml index 85c509091..fe6dc1d50 100644 --- a/roles/execution_environments/tasks/main.yml +++ b/roles/execution_environments/tasks/main.yml @@ -25,7 +25,7 @@ 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 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __execution_environments_job_async changed_when: not __execution_environments_job_async.changed @@ -33,6 +33,11 @@ __operation: "{{ operation_translate[__execution_environments_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __execution_environments_job_async.failed is defined and __execution_environments_job_async.failed + - 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 }}" @@ -44,7 +49,7 @@ 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 + when: not ansible_check_mode and __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')] }}" diff --git a/roles/filetree_create/templates/current_users.j2 b/roles/filetree_create/templates/current_users.j2 index 89f64a148..fe98ce709 100644 --- a/roles/filetree_create/templates/current_users.j2 +++ b/roles/filetree_create/templates/current_users.j2 @@ -7,5 +7,5 @@ controller_user_accounts: last_name: "{{ current_users_asset_value.last_name }}" auditor: "{{ current_users_asset_value.is_system_auditor }}" superuser: "{{ current_users_asset_value.is_superuser }}" - update_secrets: False + update_secrets: false ... diff --git a/roles/groups/tasks/main.yml b/roles/groups/tasks/main.yml index 3a1a77e87..7848f0959 100644 --- a/roles/groups/tasks/main.yml +++ b/roles/groups/tasks/main.yml @@ -27,7 +27,7 @@ loop_var: __controller_groups_item label: "{{ __operation.verb }} Controller Group {{ __controller_groups_item.name }}" no_log: "{{ controller_configuration_group_secure_logging }}" - async: 1000 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __group_job_async changed_when: not __group_job_async.changed @@ -35,6 +35,11 @@ __operation: "{{ operation_translate[__controller_groups_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __group_job_async.failed is defined and __group_job_async.failed + - name: "Managing Controller Groups | Wait for finish the Controller Groups management" ansible.builtin.async_status: jid: "{{ __group_job_async_results_item.ansible_job_id }}" @@ -46,7 +51,7 @@ 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 + when: not ansible_check_mode and __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')] }}" diff --git a/roles/hosts/tasks/main.yml b/roles/hosts/tasks/main.yml index f0dae5d5c..146458c4f 100644 --- a/roles/hosts/tasks/main.yml +++ b/roles/hosts/tasks/main.yml @@ -22,7 +22,7 @@ loop_var: __controller_host_item label: "{{ __operation.verb }} Controller host {{ __controller_host_item.name }}" no_log: "{{ controller_configuration_hosts_secure_logging }}" - async: 1000 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __host_job_async changed_when: not __host_job_async.changed @@ -30,6 +30,11 @@ __operation: "{{ operation_translate[__controller_host_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __host_job_async.failed is defined and __host_job_async.failed + - name: "Managing Controller Hosts | Wait for finish the Hosts management" ansible.builtin.async_status: jid: "{{ __host_job_async_results_item.ansible_job_id }}" @@ -41,7 +46,7 @@ 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 + when: not ansible_check_mode and __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')] }}" diff --git a/roles/instance_groups/tasks/main.yml b/roles/instance_groups/tasks/main.yml index 6454ec12e..f3d489d13 100644 --- a/roles/instance_groups/tasks/main.yml +++ b/roles/instance_groups/tasks/main.yml @@ -28,7 +28,7 @@ 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 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __instance_groups_job_async changed_when: not __instance_groups_job_async.changed @@ -36,6 +36,11 @@ __operation: "{{ operation_translate[__controller_instance_group_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __instance_groups_job_async.failed is defined and __instance_groups_job_async.failed + - 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 }}" @@ -47,7 +52,7 @@ 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 + when: not ansible_check_mode and __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')] }}" diff --git a/roles/instances/tasks/main.yml b/roles/instances/tasks/main.yml index 6e50fcc54..c80428771 100644 --- a/roles/instances/tasks/main.yml +++ b/roles/instances/tasks/main.yml @@ -21,15 +21,21 @@ loop: "{{ controller_instances }}" loop_control: loop_var: __controller_instance_item + label: "{{ __controller_instance_item.hostname }}" no_log: "{{ controller_configuration_instances_secure_logging }}" when: controller_instances is defined - async: 1000 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __instance_job_async changed_when: not __instance_job_async.changed vars: ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __instance_job_async.failed is defined and __instance_job_async.failed + - name: "Configure Controller instances | Wait for finish the instance creation" ansible.builtin.async_status: jid: "{{ __instance_job_async_results_item.ansible_job_id }}" @@ -40,7 +46,7 @@ loop: "{{ __instance_job_async.results }}" loop_control: loop_var: __instance_job_async_results_item - when: __instance_job_async_results_item.ansible_job_id is defined + when: not ansible_check_mode and __instance_job_async_results_item.ansible_job_id is defined no_log: "{{ controller_configuration_instances_secure_logging }}" vars: ansible_async_dir: '{{ controller_configuration_async_dir }}' diff --git a/roles/inventories/tasks/main.yml b/roles/inventories/tasks/main.yml index 7fe54b44d..a9737351e 100644 --- a/roles/inventories/tasks/main.yml +++ b/roles/inventories/tasks/main.yml @@ -27,7 +27,7 @@ loop_var: __controller_inventory_item label: "{{ __operation.verb }} inventory {{ __controller_inventory_item.name }}" no_log: "{{ controller_configuration_inventories_secure_logging }}" - async: 1000 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __inventories_job_async changed_when: not __inventories_job_async.changed @@ -35,6 +35,11 @@ __operation: "{{ operation_translate[__controller_inventory_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __inventories_job_async.failed is defined and __inventories_job_async.failed + - name: "Managing Controller Inventories | Wait for finish the inventories management" ansible.builtin.async_status: jid: "{{ __inventories_job_async_result_item.ansible_job_id }}" @@ -46,7 +51,7 @@ loop_control: loop_var: __inventories_job_async_result_item label: "{{ __operation.verb }} Controller inventory {{ __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 + when: not ansible_check_mode and __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')] }}" diff --git a/roles/inventory_source_update/tasks/main.yml b/roles/inventory_source_update/tasks/main.yml index a2c824b56..d9ccb5ef6 100644 --- a/roles/inventory_source_update/tasks/main.yml +++ b/roles/inventory_source_update/tasks/main.yml @@ -2,8 +2,8 @@ # Update Inventory sources - name: Run Controller inventory source update inventory_source_update: - name: "{{ __inventory_source_update_item.name }}" - inventory: "{{ __inventory_source_update_item.inventory }}" + name: "{{ __inventory_source_update_item.name | mandatory }}" + inventory: "{{ __inventory_source_update_item.inventory | mandatory }}" organization: "{{ __inventory_source_update_item.organization | default(omit, true) }}" wait: "{{ __inventory_source_update_item.wait | default(omit) }}" interval: "{{ __inventory_source_update_item.interval | default(controller_configuration_inventory_source_update_async_delay) }}" @@ -20,17 +20,23 @@ loop: "{{ inventory_sources if inventory_sources is defined else controller_inventory_sources }}" loop_control: loop_var: "__inventory_source_update_item" + label: "{{ (__inventory_source_update_item.organization | default('')) }}/{{ __inventory_source_update_item.inventory }}/{{ __inventory_source_update_item.name }}" no_log: "{{ controller_configuration_inventory_source_update_secure_logging }}" when: - controller_inventory_sources is defined - __inventory_source_update_item.state | default('present') != "absent" - async: 1000 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __inventory_source_update_async changed_when: not __inventory_source_update_async.changed vars: ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __inventory_source_update_async.failed is defined and __inventory_source_update_async.failed + - name: "Controller inventory source update | Wait for finish of the inventory source update" ansible.builtin.async_status: jid: "{{ __inventory_source_update_async_results_item.ansible_job_id }}" @@ -41,7 +47,7 @@ loop: "{{ __inventory_source_update_async.results }}" loop_control: loop_var: __inventory_source_update_async_results_item - when: __inventory_source_update_async_results_item.ansible_job_id is defined + when: not ansible_check_mode and __inventory_source_update_async_results_item.ansible_job_id is defined no_log: "{{ controller_configuration_inventory_source_update_secure_logging }}" vars: ansible_async_dir: '{{ controller_configuration_async_dir }}' diff --git a/roles/inventory_sources/tasks/main.yml b/roles/inventory_sources/tasks/main.yml index 652e1053c..f057c1701 100644 --- a/roles/inventory_sources/tasks/main.yml +++ b/roles/inventory_sources/tasks/main.yml @@ -42,7 +42,7 @@ 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 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __inventory_source_job_async changed_when: not __inventory_source_job_async.changed @@ -50,6 +50,11 @@ __operation: "{{ operation_translate[__controller_source_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __inventory_source_job_async.failed is defined and __inventory_source_job_async.failed + - 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 }}" @@ -61,7 +66,7 @@ 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 + when: not ansible_check_mode and __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')] }}" diff --git a/roles/job_launch/tasks/main.yml b/roles/job_launch/tasks/main.yml index 0d5df39d4..d8e48afdf 100644 --- a/roles/job_launch/tasks/main.yml +++ b/roles/job_launch/tasks/main.yml @@ -36,6 +36,7 @@ loop: "{{ controller_launch_jobs }}" loop_control: loop_var: "__job_launch_item" + label: "{{ (__job_launch_item.organization | default('')) }}/{{ __job_launch_item.name }}" no_log: "{{ controller_configuration_job_launch_secure_logging }}" register: launched_controller_jobs when: controller_launch_jobs is defined diff --git a/roles/job_templates/tasks/main.yml b/roles/job_templates/tasks/main.yml index 1709ca32b..315c3ab73 100644 --- a/roles/job_templates/tasks/main.yml +++ b/roles/job_templates/tasks/main.yml @@ -70,7 +70,7 @@ 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 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __job_templates_job_async changed_when: not __job_templates_job_async.changed @@ -78,6 +78,11 @@ __operation: "{{ operation_translate[__controller_template_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __job_templates_job_async.failed is defined and __job_templates_job_async.failed + - 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 }}" @@ -89,7 +94,7 @@ 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 + when: not ansible_check_mode and __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')] }}" diff --git a/roles/labels/tasks/main.yml b/roles/labels/tasks/main.yml index e6adbc421..33485e2c6 100644 --- a/roles/labels/tasks/main.yml +++ b/roles/labels/tasks/main.yml @@ -19,7 +19,7 @@ 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 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __controller_label_job_async changed_when: not __controller_label_job_async.changed @@ -27,6 +27,11 @@ __operation: "{{ operation_translate[__controller_label_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __controller_label_job_async.failed is defined and __controller_label_job_async.failed + - name: "Managing Labels | Wait for finish the Labels management" ansible.builtin.async_status: jid: "{{ __controller_label_job_async_results_item.ansible_job_id }}" @@ -38,7 +43,7 @@ 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 + when: not ansible_check_mode and __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')] }}" diff --git a/roles/notification_templates/tasks/main.yml b/roles/notification_templates/tasks/main.yml index 259f4b9d3..e837964da 100644 --- a/roles/notification_templates/tasks/main.yml +++ b/roles/notification_templates/tasks/main.yml @@ -24,7 +24,7 @@ loop_var: __controller_notification_item label: "{{ __operation.verb }} Controller notification {{ __controller_notification_item.name }}" no_log: "{{ controller_configuration_notifications_secure_logging }}" - async: 1000 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __controller_notification_job_async changed_when: not __controller_notification_job_async.changed @@ -32,6 +32,11 @@ __operation: "{{ operation_translate[__controller_notification_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __controller_notification_job_async.failed is defined and __controller_notification_job_async.failed + - name: "Managing Notifications | Wait for finish the Notifications management" ansible.builtin.async_status: jid: "{{ __controller_notification_job_async_results_item.ansible_job_id }}" @@ -43,7 +48,7 @@ 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 + when: not ansible_check_mode and __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')] }}" diff --git a/roles/organizations/tasks/main.yml b/roles/organizations/tasks/main.yml index 7a08e9c07..c1e75215e 100644 --- a/roles/organizations/tasks/main.yml +++ b/roles/organizations/tasks/main.yml @@ -27,7 +27,7 @@ loop_var: __controller_organizations_item label: "{{ __operation.verb }} organization {{ __controller_organizations_item.name }}" no_log: "{{ controller_configuration_organizations_secure_logging }}" - async: 1000 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __organizations_job_async changed_when: not __organizations_job_async.changed @@ -35,6 +35,11 @@ __operation: "{{ operation_translate[__controller_organizations_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __organizations_job_async.failed is defined and __organizations_job_async.failed + - name: "Managing Controller Organizations | Wait for finish the Organizations management" ansible.builtin.async_status: jid: "{{ __organizations_job_async_results_item.ansible_job_id }}" @@ -46,7 +51,7 @@ 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 + when: not ansible_check_mode and __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')] }}" diff --git a/roles/project_update/tasks/main.yml b/roles/project_update/tasks/main.yml index ad1ccf02a..edbcb5f52 100644 --- a/roles/project_update/tasks/main.yml +++ b/roles/project_update/tasks/main.yml @@ -19,18 +19,24 @@ loop: "{{ projects if projects is defined else controller_projects }}" loop_control: loop_var: "__project_update_update_item" + label: "{{ (__project_update_update_item.organization | default('')) }}/{{ __project_update_update_item.name }}" no_log: "{{ controller_configuration_project_update_secure_logging }}" when: - controller_projects is defined - __project_update_update_item.update_project | default(true) - __project_update_update_item.state | default('present') != "absent" - async: 1000 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __project_update_job_async changed_when: not __project_update_job_async.changed vars: ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __project_update_job_async.failed is defined and __project_update_job_async.failed + - name: "Configure Controller Projects | Wait for finish the projects creation" ansible.builtin.async_status: jid: "{{ __project_update_job_async_results_item.ansible_job_id }}" @@ -41,7 +47,7 @@ loop: "{{ __project_update_job_async.results }}" loop_control: loop_var: __project_update_job_async_results_item - when: __project_update_job_async_results_item.ansible_job_id is defined + when: not ansible_check_mode and __project_update_job_async_results_item.ansible_job_id is defined no_log: "{{ controller_configuration_project_update_secure_logging }}" vars: ansible_async_dir: '{{ controller_configuration_async_dir }}' diff --git a/roles/projects/tasks/main.yml b/roles/projects/tasks/main.yml index 493783c15..a0de767ee 100644 --- a/roles/projects/tasks/main.yml +++ b/roles/projects/tasks/main.yml @@ -43,7 +43,7 @@ loop_var: __controller_project_item label: "{{ __operation.verb }} Project {{ __controller_project_item.name }}" no_log: "{{ controller_configuration_projects_secure_logging }}" - async: 1000 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __projects_job_async changed_when: not __projects_job_async.changed @@ -51,6 +51,11 @@ __operation: "{{ operation_translate[__controller_project_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __projects_job_async.failed is defined and __projects_job_async.failed + - name: "Managing Projects | Wait for finish the projects management" ansible.builtin.async_status: jid: "{{ __projects_job_async_results_item.ansible_job_id }}" @@ -62,7 +67,7 @@ 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 + when: not ansible_check_mode and __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')] }}" diff --git a/roles/roles/tasks/main.yml b/roles/roles/tasks/main.yml index c52142d04..b60e3883c 100644 --- a/roles/roles/tasks/main.yml +++ b/roles/roles/tasks/main.yml @@ -37,7 +37,7 @@ 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 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __controller_role_job_async changed_when: not __controller_role_job_async.changed @@ -45,6 +45,11 @@ __operation: "{{ operation_translate[__controller_role_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __controller_role_job_async.failed is defined and __controller_role_job_async.failed + - name: "Managing Roles | Wait for finish the Roles management" ansible.builtin.async_status: jid: "{{ __controller_role_job_async_results_item.ansible_job_id }}" @@ -56,7 +61,7 @@ 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 + when: not ansible_check_mode and __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')] }}" diff --git a/roles/schedules/tasks/main.yml b/roles/schedules/tasks/main.yml index 1a869acb8..d646e3fd2 100644 --- a/roles/schedules/tasks/main.yml +++ b/roles/schedules/tasks/main.yml @@ -39,7 +39,7 @@ loop_var: "__controller_schedule_item" label: "{{ __operation.verb }} Controller Schedule {{ __controller_schedule_item.name }}" no_log: "{{ controller_configuration_schedules_secure_logging }}" - async: 1000 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __controller_schedule_job_async changed_when: not __controller_schedule_job_async.changed @@ -47,6 +47,11 @@ __operation: "{{ operation_translate[__controller_schedule_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __controller_schedule_job_async.failed is defined and __controller_schedule_job_async.failed + - name: "Managing Schedules | Wait for finish the Schedules management" ansible.builtin.async_status: jid: "{{ __controller_schedule_job_async_results_item.ansible_job_id }}" @@ -58,7 +63,7 @@ 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 + when: not ansible_check_mode and __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')] }}" diff --git a/roles/settings/tasks/main.yml b/roles/settings/tasks/main.yml index 2ce4582a2..f693436bd 100644 --- a/roles/settings/tasks/main.yml +++ b/roles/settings/tasks/main.yml @@ -18,14 +18,20 @@ loop: "{{ controller_settings is mapping | ternary([controller_settings], controller_settings) }}" loop_control: loop_var: __controller_setting_item + label: "{{ __controller_setting_item.name | default(__controller_setting_item.settings) }}" no_log: "{{ controller_configuration_settings_secure_logging }}" - async: 1000 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __controller_setting_job_async changed_when: not __controller_setting_job_async.changed vars: ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __controller_setting_job_async.failed is defined and __controller_setting_job_async.failed + - name: "Configure Settings | Wait for finish the Settings creation" ansible.builtin.async_status: jid: "{{ __controller_setting_job_async_results_item.ansible_job_id }}" @@ -36,7 +42,7 @@ loop: "{{ __controller_setting_job_async.results }}" loop_control: loop_var: __controller_setting_job_async_results_item - when: __controller_setting_job_async_results_item.ansible_job_id is defined + when: not ansible_check_mode and __controller_setting_job_async_results_item.ansible_job_id is defined no_log: "{{ controller_configuration_settings_secure_logging }}" vars: ansible_async_dir: '{{ controller_configuration_async_dir }}' diff --git a/roles/teams/tasks/main.yml b/roles/teams/tasks/main.yml index 4e199d77a..ef917f07a 100644 --- a/roles/teams/tasks/main.yml +++ b/roles/teams/tasks/main.yml @@ -20,7 +20,7 @@ loop_var: __controller_team_item label: "{{ __operation.verb }} Ansible Controller Team {{ __controller_team_item.name }}" no_log: "{{ controller_configuration_teams_secure_logging }}" - async: 1000 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __controller_team_job_async changed_when: not __controller_team_job_async.changed @@ -28,6 +28,11 @@ __operation: "{{ operation_translate[__controller_team_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __controller_team_job_async.failed is defined and __controller_team_job_async.failed + - name: "Managing Teams | Wait for finish the Teams management" ansible.builtin.async_status: jid: "{{ __controller_team_job_async_results_item.ansible_job_id }}" @@ -39,7 +44,7 @@ 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 + when: not ansible_check_mode and __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')] }}" diff --git a/roles/users/tasks/main.yml b/roles/users/tasks/main.yml index ef376e864..360236e04 100644 --- a/roles/users/tasks/main.yml +++ b/roles/users/tasks/main.yml @@ -29,7 +29,7 @@ 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 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __controller_user_accounts_job_async changed_when: not __controller_user_accounts_job_async.changed @@ -37,6 +37,11 @@ __operation: "{{ operation_translate[__controller_user_accounts_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __controller_user_accounts_job_async.failed is defined and __controller_user_accounts_job_async.failed + - name: "Managing Users | Wait for finish the Users management" ansible.builtin.async_status: jid: "{{ __controller_user_accounts_job_async_results_item.ansible_job_id }}" @@ -48,7 +53,7 @@ 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 + when: not ansible_check_mode and __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')] }}" diff --git a/roles/workflow_job_templates/tasks/add_workflows_schema.yml b/roles/workflow_job_templates/tasks/add_workflows_schema.yml index f7a010a94..549b499ed 100644 --- a/roles/workflow_job_templates/tasks/add_workflows_schema.yml +++ b/roles/workflow_job_templates/tasks/add_workflows_schema.yml @@ -39,15 +39,21 @@ loop: "{{ __workflow_loop_item.simplified_workflow_nodes }}" loop_control: loop_var: __workflow_loop_node_item + label: "{{ __workflow_loop_item.name }}/{{ __workflow_loop_node_item.identifier }}" no_log: "{{ workflow_job_templates_secure_logging }}" - async: 1000 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __workflows_node_async changed_when: not __workflows_node_async.changed vars: ansible_async_dir: '{{ controller_configuration_async_dir }}' -- name: "Create the Workflow Nodes | Wait for finish the Workflow Nodes creation" +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __workflows_node_async.failed is defined and __workflows_node_async.failed + +- name: "Manage Workflows | Wait for finish the workflow creation" ansible.builtin.async_status: jid: "{{ __workflows_node_async_results_item.ansible_job_id }}" register: __workflows_node_async_result @@ -56,7 +62,7 @@ loop: "{{ __workflows_node_async.results }}" loop_control: loop_var: __workflows_node_async_results_item - when: __workflows_node_async_results_item.ansible_job_id is defined + when: not ansible_check_mode and __workflows_node_async_results_item.ansible_job_id is defined no_log: "{{ workflow_job_templates_secure_logging }}" vars: ansible_async_dir: '{{ controller_configuration_async_dir }}' @@ -81,17 +87,23 @@ loop: "{{ __workflow_loop_item.simplified_workflow_nodes }}" loop_control: loop_var: __workflow_loop_node_item + label: "{{ __workflow_loop_node_item.identifier }}" no_log: "{{ workflow_job_templates_secure_logging }}" # Execute only the nodes that define links to the following when: ((__workflow_loop_node_item.always_nodes is defined and __workflow_loop_node_item.always_nodes | length > 0) or (__workflow_loop_node_item.success_nodes is defined and __workflow_loop_node_item.success_nodes | length > 0) or (__workflow_loop_node_item.failure_nodes is defined and __workflow_loop_node_item.failure_nodes | length > 0)) - async: 1000 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __workflows_link_async vars: ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __workflows_link_async.failed is defined and __workflows_link_async.failed + - name: "Manage Workflows | Wait for finish the workflow creation" ansible.builtin.async_status: jid: "{{ __workflows_link_async_results_item.ansible_job_id }}" @@ -102,7 +114,7 @@ loop: "{{ __workflows_link_async.results }}" loop_control: loop_var: __workflows_link_async_results_item - when: __workflows_link_async_results_item.ansible_job_id is defined + when: not ansible_check_mode and __workflows_link_async_results_item.ansible_job_id is defined no_log: "{{ workflow_job_templates_secure_logging }}" vars: ansible_async_dir: '{{ controller_configuration_async_dir }}' diff --git a/roles/workflow_job_templates/tasks/main.yml b/roles/workflow_job_templates/tasks/main.yml index d0ab05f6c..fa659c47c 100644 --- a/roles/workflow_job_templates/tasks/main.yml +++ b/roles/workflow_job_templates/tasks/main.yml @@ -46,7 +46,7 @@ loop_var: __workflow_loop_item label: "{{ __operation.verb }} Workflow {{ __workflow_loop_item.name }}" no_log: "{{ workflow_job_templates_secure_logging }}" - async: 1000 + async: "{{ ansible_check_mode | ternary(0, 1000) }}" poll: 0 register: __workflows_job_async changed_when: not __workflows_job_async.changed @@ -54,6 +54,11 @@ __operation: "{{ operation_translate[__workflow_loop_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' +- name: "Flag for errors (check mode only)" + ansible.builtin.set_fact: + error_flag: true + when: ansible_check_mode and __workflows_job_async.failed is defined and __workflows_job_async.failed + - name: "Managing Workflows | Wait for finish the workflow management" ansible.builtin.async_status: jid: "{{ __workflows_job_async_results_item.ansible_job_id }}" @@ -65,7 +70,7 @@ 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 + when: not ansible_check_mode and __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')] }}" diff --git a/roles/workflow_launch/tasks/main.yml b/roles/workflow_launch/tasks/main.yml index 29e013928..d48e74e7c 100644 --- a/roles/workflow_launch/tasks/main.yml +++ b/roles/workflow_launch/tasks/main.yml @@ -2,7 +2,7 @@ # Launch Controller Workflow - name: Launch a Controller Workflow workflow_launch: - name: "{{ __workflow_launch_item.name }}" + name: "{{ __workflow_launch_item.name | mandatory }}" organization: "{{ __workflow_launch_item.organization | default(omit, true) }}" inventory: "{{ __workflow_launch_item.inventory | default(omit, true) }}" limit: "{{ __workflow_launch_item.limit | default(omit, true) }}" @@ -23,6 +23,7 @@ loop: "{{ controller_workflow_launch_jobs }}" loop_control: loop_var: "__workflow_launch_item" + label: "{{ (__workflow_launch_item.organization | default('')) }}/{{ __workflow_launch_item.name }}" no_log: "{{ controller_configuration_workflow_launch_secure_logging }}" register: launched_controller_workflows when: controller_workflow_launch_jobs is defined