Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: improve checkmode outputs #715

Merged
merged 3 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions roles/applications/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@
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
vars:
__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 }}"
Expand All @@ -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')] }}"
Expand Down
9 changes: 7 additions & 2 deletions roles/bulk_host_create/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand All @@ -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 }}'
Expand Down
1 change: 1 addition & 0 deletions roles/bulk_job_launch/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
loop: "{{ controller_bulk_launch_jobs }}"
loop_control:
loop_var: "__bulk_job_launch_item"
label: "{{ (__bulk_job_launch_item.organization | default('<no_org>')) }}/{{ __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
Expand Down
9 changes: 7 additions & 2 deletions roles/credential_input_sources/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@
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
vars:
__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 }}"
Expand All @@ -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')] }}"
Expand Down
9 changes: 7 additions & 2 deletions roles/credential_types/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,19 @@
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
vars:
__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 }}"
Expand All @@ -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')] }}"
Expand Down
9 changes: 7 additions & 2 deletions roles/credentials/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@
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
vars:
__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 }}"
Expand All @@ -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')] }}"
Expand Down
5 changes: 5 additions & 0 deletions roles/dispatch/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
...
9 changes: 7 additions & 2 deletions roles/execution_environments/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@
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
vars:
__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 }}"
Expand All @@ -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')] }}"
Expand Down
2 changes: 1 addition & 1 deletion roles/filetree_create/templates/current_users.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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
...
9 changes: 7 additions & 2 deletions roles/groups/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,19 @@
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
vars:
__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 }}"
Expand All @@ -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')] }}"
Expand Down
9 changes: 7 additions & 2 deletions roles/hosts/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,19 @@
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
vars:
__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 }}"
Expand All @@ -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')] }}"
Expand Down
9 changes: 7 additions & 2 deletions roles/instance_groups/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,19 @@
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
vars:
__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 }}"
Expand All @@ -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')] }}"
Expand Down
10 changes: 8 additions & 2 deletions roles/instances/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand All @@ -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 }}'
Expand Down
9 changes: 7 additions & 2 deletions roles/inventories/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,19 @@
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
vars:
__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 }}"
Expand All @@ -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')] }}"
Expand Down
Loading
Loading