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

Error handling for controller objects #1018

Open
wants to merge 34 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0065a6e
feat: error handling for job templates
Dec 17, 2024
936bc43
feat: error handling for projects
Dec 17, 2024
c29cea0
feat: error handling for workflows
Dec 17, 2024
3403830
feat: error handling for applications
Dec 17, 2024
29f619a
feat: error handling for bulk host create
Dec 17, 2024
bad6f1b
feat: error handling for credential_input_sources
Dec 17, 2024
00e8fec
feat: error handling for credential_type
Dec 17, 2024
ce1a147
feat: error handling for credentials
Dec 17, 2024
9f484e9
feat: error handling for execution environment
Dec 17, 2024
037d715
fix: wrong variable
Dec 17, 2024
45e5a28
feat: error handling for host group
Dec 17, 2024
df911e6
feat: error handling for host
Dec 17, 2024
6009eac
fix: task name
Dec 17, 2024
51d4141
feat: error handling for instance groups
Dec 17, 2024
facf2f6
feat: error handling for instances
Dec 17, 2024
44ec144
feat: error handling for inventories
Dec 17, 2024
b746c2e
feat: error handling for inventory source update
Dec 17, 2024
b18af57
feat: error handling for inventory sources
Dec 17, 2024
1012527
feat: error handling for notification templates
Dec 17, 2024
4f07a25
feat: error handling for organization
Dec 17, 2024
c44ac85
feat: error handling for project updates
Dec 17, 2024
9437f28
feat: error handling for roles
Dec 17, 2024
85d475b
feat: error handling for schedules
Dec 17, 2024
206d5e6
feat: error handling for teams
Dec 17, 2024
5f5ce0b
feat: error handling for users
Dec 17, 2024
39b9502
feat: error handling for labels
Dec 17, 2024
6bb1c49
misc: minor linting
Dec 17, 2024
81dd38f
misc: update readmes
Dec 17, 2024
6564695
misc: add default for response if does not exist
Dec 17, 2024
87923c8
misc: tweak error list
Dec 18, 2024
33d1db7
misc: tweaks and polish the code
Dec 18, 2024
7c3ae7e
fix: missing changelog
Dec 18, 2024
a8c9a9d
fix: typos
Dec 18, 2024
a7272ce
fix: typo in changelog
Dec 18, 2024
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
3 changes: 3 additions & 0 deletions changelogs/fragments/controller_objects.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- Add the ability to collect error logs while importing the object, instead of failing on the first error.
1 change: 1 addition & 0 deletions roles/controller_applications/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Currently:
|`aap_token`|""|no|Controller Admin User's token on the Ansible Automation Platform Server. This should be stored in an Ansible Vault at or elsewhere and called from a parent playbook. Either username / password or oauthtoken need to be specified.||
|`aap_request_timeout`|`10`|no|Specify the timeout in seconds Ansible should use in requests to the Ansible Automation Platform host.||
|`aap_applications`|`see below`|yes|Data structure describing your applications, described below. Alias: applications ||
|`collect_logs`|`false`|no|Specify whether it collects logs for all failed tasks related to application creation, modification, or deletion, instead of failing on the first error.||

### Enforcing defaults

Expand Down
1 change: 1 addition & 0 deletions roles/controller_applications/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ controller_configuration_applications_async_delay: "{{ aap_configuration_async_d
controller_configuration_applications_loop_delay: "{{ aap_configuration_loop_delay | default(0) }}"
aap_configuration_async_dir:
controller_configuration_applications_enforce_defaults: "{{ aap_configuration_enforce_defaults | default(false) }}"
collect_logs: false
...
31 changes: 31 additions & 0 deletions roles/controller_applications/tasks/async_application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
- name: async_application | An async_application block
block:
- name: async_application | Managing Controller Applications | Wait for finish the applications management
ansible.builtin.async_status:
jid: "{{ __applications_job_async_results_item.ansible_job_id }}"
register: __applications_job_async_result
until: __applications_job_async_result.finished
retries: "{{ controller_configuration_applications_async_retries }}"
delay: "{{ controller_configuration_applications_async_delay }}"
rescue:
- name: async_application | Load error details
ansible.builtin.include_vars:
file: "{{ __applications_job_async_result.results_file }}"
name: __error_data

- name: async_application | Show error and stop execution
when: not collect_logs
ansible.builtin.fail:
msg: "error: {{ __error_data['msg'] }}, response: {{ __error_data['response'] | default ('N/A') }}"

- name: async_application | Building list of not processed applications
ansible.builtin.set_fact:
__applications_error_list: "{{ __applications_error_list | default([]) + [
{
'name': __error_data['invocation']['module_args']['name'] | default(''),
'error': __error_data['msg'] | default('')
}
]
}}"
...
7 changes: 1 addition & 6 deletions roles/controller_applications/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@
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 }}"
register: __applications_job_async_result
until: __applications_job_async_result.finished
retries: "{{ controller_configuration_applications_async_retries }}"
delay: "{{ controller_configuration_applications_async_delay }}"
ansible.builtin.include_tasks: async_application.yml
loop: "{{ __applications_job_async.results }}"
loop_control:
loop_var: __applications_job_async_results_item
Expand Down
1 change: 1 addition & 0 deletions roles/controller_bulk_host_create/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Currently:
|`controller_oauthtoken`|""|no|Controller Admin User's token on the Ansible Controller Server. This should be stored in an Ansible Vault at or elsewhere and called from a parent playbook. Either username / password or oauthtoken need to be specified.||
|`controller_request_timeout`|`10`|no|Specify the timeout in seconds Ansible should use in requests to the Ansible Automation Platform host.||
|`controller_configuration_bulk_hosts_secure_logging`|`see below`|yes|Data structure describing your organization or organizations Described below.||
|`collect_logs`|`false`|no|Specify whether it collects logs for all failed tasks related to bulk host creation instead of failing on the first error.||

### Secure Logging Variables

Expand Down
1 change: 1 addition & 0 deletions roles/controller_bulk_host_create/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ controller_configuration_bulk_hosts_async_retries: "{{ aap_configuration_async_r
controller_configuration_bulk_hosts_async_delay: "{{ aap_configuration_async_delay | default(1) }}"
controller_configuration_bulk_hosts_loop_delay: "{{ aap_configuration_loop_delay | default(0) }}"
aap_configuration_async_dir:
collect_logs: false
...
31 changes: 31 additions & 0 deletions roles/controller_bulk_host_create/tasks/async_bulk_host.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
- name: async_bulk_host | An async_bulk_host block
block:
- name: async_bulk_host | Configure bulk_hosts | Wait for finish the bulk_hosts management
ansible.builtin.async_status:
jid: "{{ __controller_bulk_hosts_job_async_results_item.ansible_job_id }}"
register: __controller_bulk_hosts_job_async_result
until: __controller_bulk_hosts_job_async_result.finished
retries: "{{ controller_configuration_bulk_hosts_async_retries }}"
delay: "{{ controller_configuration_bulk_hosts_async_delay }}"
rescue:
- name: async_bulk_host | Load error details
ansible.builtin.include_vars:
file: "{{ __controller_bulk_hosts_job_async_result.results_file }}"
name: __error_data

- name: async_bulk_host | Show error and stop execution
when: not collect_logs
ansible.builtin.fail:
msg: "error: {{ __error_data['msg'] }}, response: {{ __error_data['response'] | default ('N/A') }}"

- name: async_bulk_host | Building list of not processed bulk_hosts
ansible.builtin.set_fact:
__bulk_hosts_error_list: "{{ __bulk_hosts_error_list | default([]) + [
{
'hosts': __error_data['invocation']['module_args']['hosts'] | default(''),
'error': __error_data['msg'] | default('')
}
]
}}"
...
7 changes: 1 addition & 6 deletions roles/controller_bulk_host_create/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@
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 }}"
register: __controller_bulk_hosts_job_async_result
until: __controller_bulk_hosts_job_async_result.finished
retries: "{{ controller_configuration_bulk_hosts_async_retries }}"
delay: "{{ controller_configuration_bulk_hosts_async_delay }}"
ansible.builtin.include_tasks: async_bulk_host.yml
loop: "{{ __controller_bulk_hosts_job_async.results }}"
loop_control:
loop_var: __controller_bulk_hosts_job_async_results_item
Expand Down
1 change: 1 addition & 0 deletions roles/controller_credential_input_sources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Currently:
|`aap_token`|""|no|Controller Admin User's token on the Ansible Automation Platform Server. This should be stored in an Ansible Vault at or elsewhere and called from a parent playbook. Either username / password or oauthtoken need to be specified.||
|`aap_request_timeout`|`10`|no|Specify the timeout in seconds Ansible should use in requests to the Ansible Automation Platform host.||
|`controller_credential_input_sources`|`see below`|yes|Data structure describing your credential input sources Described below.||
|`collect_logs`|`false`|no|Specify whether it collects logs for all failed tasks related to credential input sources creation, modification, or deletion, instead of failing on the first error.||

### Enforcing defaults

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ controller_configuration_credential_input_sources_async_delay: "{{ aap_configura
controller_configuration_credential_input_sources_loop_delay: "{{ aap_configuration_loop_delay | default(0) }}"
aap_configuration_async_dir:
controller_configuration_credential_input_sources_enforce_defaults: "{{ aap_configuration_enforce_defaults | default(false) }}"
collect_logs: false
...
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
- name: async_credential_input | An async_credential_input block
block:
- name: async_credential_input | Managing Credential Input Sources | Wait for finish the bulk_hosts management
ansible.builtin.async_status:
jid: "{{ __credential_input_sources_job_async_results_item.ansible_job_id }}"
register: __credential_input_sources_job_async_result
until: __credential_input_sources_job_async_result.finished
retries: "{{ controller_configuration_credential_input_sources_async_retries }}"
delay: "{{ controller_configuration_credential_input_sources_async_delay }}"
rescue:
- name: async_credential_input | Load error details
ansible.builtin.include_vars:
file: "{{ __credential_input_sources_job_async_result.results_file }}"
name: __error_data

- name: async_credential_input | Show error and stop execution
when: not collect_logs
ansible.builtin.fail:
msg: "error: {{ __error_data['msg'] }}, response: {{ __error_data['response'] | default ('N/A') }}"

- name: async_credential_input | Building list of not processed bulk_hosts
ansible.builtin.set_fact:
__credential_inputs_error_list: "{{ __credential_inputs_error_list | default([]) + [
{
'input_field_name': __error_data['invocation']['module_args']['input_field_name'] | default(''),
'error': __error_data['msg'] | default('')
}
]
}}"
...
7 changes: 1 addition & 6 deletions roles/controller_credential_input_sources/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@
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 }}"
register: __credential_input_sources_job_async_result
until: __credential_input_sources_job_async_result.finished
retries: "{{ controller_configuration_credential_input_sources_async_retries }}"
delay: "{{ controller_configuration_credential_input_sources_async_delay }}"
ansible.builtin.include_tasks: async_credential_input.yml
loop: "{{ __credential_input_sources_job_async.results }}"
loop_control:
loop_var: __credential_input_sources_job_async_results_item
Expand Down
1 change: 1 addition & 0 deletions roles/controller_credential_types/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Currently:
|`aap_token`|""|no|Controller Admin User's token on the Ansible Automation Platform Server. This should be stored in an Ansible Vault at or elsewhere and called from a parent playbook. Either username / password or oauthtoken need to be specified.||
|`aap_request_timeout`|`10`|no|Specify the timeout in seconds Ansible should use in requests to the Ansible Automation Platform host.||
|`controller_credential_types`|`see below`|yes|Data structure describing your credential types Described below. Alias: credential_types ||
|`collect_logs`|`false`|no|Specify whether it collects logs for all failed tasks related to credential type creation, modification, or deletion, instead of failing on the first error.||

### Enforcing defaults

Expand Down
1 change: 1 addition & 0 deletions roles/controller_credential_types/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ controller_configuration_credential_types_async_delay: "{{ aap_configuration_asy
controller_configuration_credential_types_loop_delay: "{{ aap_configuration_loop_delay | default(0) }}"
aap_configuration_async_dir:
controller_configuration_credential_types_enforce_defaults: "{{ aap_configuration_enforce_defaults | default(false) }}"
collect_logs: false
...
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
- name: async_credential_type | An async_credential_type block
block:
- name: async_credential_type | 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
until: __credentialtypes_job_async_result.finished
retries: "{{ controller_configuration_credential_types_async_retries }}"
delay: "{{ controller_configuration_credential_types_async_delay }}"
rescue:
- name: async_credential_type | Load error details
ansible.builtin.include_vars:
file: "{{ __credentialtypes_job_async_result.results_file }}"
name: __error_data

- name: async_credential_type | Show error and stop execution
when: not collect_logs
ansible.builtin.fail:
msg: "error: {{ __error_data['msg'] }}, response: {{ __error_data['response'] | default ('N/A') }}"

- name: async_credential_type | Building list of not processed credential_types
ansible.builtin.set_fact:
__credentialtypes_error_list: "{{ __credentialtypes_error_list | default([]) + [
{
'name': __error_data['invocation']['module_args']['name'] | default(''),
'error': __error_data['msg'] | default('')
}
]
}}"
...
7 changes: 1 addition & 6 deletions roles/controller_credential_types/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@
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 }}"
register: __credentialtypes_job_async_result
until: __credentialtypes_job_async_result.finished
retries: "{{ controller_configuration_credential_types_async_retries }}"
delay: "{{ controller_configuration_credential_types_async_delay }}"
ansible.builtin.include_tasks: async_credential_type.yml
loop: "{{ __credentialtypes_job_async.results }}"
loop_control:
loop_var: __credentialtypes_job_async_result_item
Expand Down
1 change: 1 addition & 0 deletions roles/controller_credentials/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ controller_configuration_credentials_async_delay: "{{ aap_configuration_async_de
controller_configuration_credentials_loop_delay: "{{ aap_configuration_loop_delay | default(0) }}"
aap_configuration_async_dir:
controller_configuration_credentials_enforce_defaults: "{{ aap_configuration_enforce_defaults | default(false) }}"
collect_logs: false
...
31 changes: 31 additions & 0 deletions roles/controller_credentials/tasks/async_credential.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
- name: async_credential | An async_credential block
block:
- name: async_credential | Managing Controller Credentials | Wait for finish the credentials management
ansible.builtin.async_status:
jid: "{{ __credentials_job_async_results_item.ansible_job_id }}"
register: __credentials_job_async_result
until: __credentials_job_async_result.finished
retries: "{{ controller_configuration_credentials_async_retries }}"
delay: "{{ controller_configuration_credentials_async_delay }}"
rescue:
- name: async_credential | Load error details
ansible.builtin.include_vars:
file: "{{ __credentials_job_async_result.results_file }}"
name: __error_data

- name: async_credential | Show error and stop execution
when: not collect_logs
ansible.builtin.fail:
msg: "error: {{ __error_data['msg'] }}, response: {{ __error_data['response'] | default ('N/A') }}"

- name: async_credential | Building list of not processed credentials
ansible.builtin.set_fact:
__credentials_error_list: "{{ __credentials_error_list | default([]) + [
{
'name': __error_data['invocation']['module_args']['name'] | default(''),
'error': __error_data['msg'] | default('')
}
]
}}"
...
7 changes: 1 addition & 6 deletions roles/controller_credentials/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@
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 }}"
register: __credentials_job_async_result
until: __credentials_job_async_result.finished
retries: "{{ controller_configuration_credentials_async_retries }}"
delay: "{{ controller_configuration_credentials_async_delay }}"
ansible.builtin.include_tasks: async_credential.yml
loop: "{{ __credentials_job_async.results }}"
loop_control:
loop_var: __credentials_job_async_results_item
Expand Down
1 change: 1 addition & 0 deletions roles/controller_execution_environments/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Currently:
|`aap_token`|""|no|Controller Admin User's token on the Ansible Automation Platform Server. This should be stored in an Ansible Vault at or elsewhere and called from a parent playbook. Either username / password or oauthtoken need to be specified.||
|`aap_request_timeout`|`10`|no|Specify the timeout in seconds Ansible should use in requests to the Ansible Automation Platform host.||
|`controller_execution_environments`|`see below`|yes|Data structure describing your organization or organizations Described below. Alias: execution_environments ||
|`collect_logs`|`false`|no|Specify whether it collects logs for all failed tasks related to execution envirionment creation, modification, or deletion, instead of failing on the first error.||

### Enforcing defaults

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ controller_configuration_execution_environments_async_delay: "{{ aap_configurati
controller_configuration_execution_environments_loop_delay: "{{ aap_configuration_loop_delay | default(0) }}"
aap_configuration_async_dir:
controller_configuration_execution_environments_enforce_defaults: "{{ aap_configuration_enforce_defaults | default(false) }}"
collect_logs: false
...
Loading
Loading