Skip to content

Commit

Permalink
Added role to host global vars to all other roles. Updated tasks titt…
Browse files Browse the repository at this point in the history
…les to solve issue707 (#716)
  • Loading branch information
ivarmu committed Nov 1, 2023
1 parent 1da69ba commit f45b00f
Show file tree
Hide file tree
Showing 76 changed files with 535 additions and 319 deletions.
2 changes: 2 additions & 0 deletions .ansible-lint-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
plugins/lookup/controller_object_diff.py yaml[document-end]
plugins/modules/controller_export_diff.py yaml[document-end]
2 changes: 1 addition & 1 deletion EXPORT_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ awx export --conf.host https://localhost --conf.username admin --conf.password *

- name: Export projects to file
ansible.builtin.copy:
content: "{{ export_results | to_nice_yaml( width=50, explicit_start=True, explicit_end=True) }}"
content: "{{ export_results | to_nice_yaml(width=50, explicit_start=True, explicit_end=True) }}"
dest: projects.yaml
...
```
Expand Down
3 changes: 1 addition & 2 deletions plugins/lookup/controller_object_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,13 @@
set_fact:
project_difference: "{{ query('infra.controller_configuration.controller_object_diff',
api_list=controller_api_results, compare_list=differential_item.differential_test_items,
with_present=true, set_absent=true ) }}"
with_present=true, set_absent=true) }}"
- name: Add Projects
include_role:
name: infra.controller_configuration.projects
vars:
controller_projects: "{{ project_difference }}"
"""

RETURN = """
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/controller_export_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
scm_url: https://github.com/ansible/ansible-examples.git
description: ansible-examples
organization:
name: Satellite
name: Satellite
credential: gitlab-personal-access-token for satqe_auto_droid
wait: false
controller_host: https://controller
Expand Down
2 changes: 1 addition & 1 deletion roles/applications/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Description

An Ansible Role to create Applications on Ansible Controller.
An Ansible Role to create/update/remove Applications on Ansible Controller.

## Requirements

Expand Down
7 changes: 4 additions & 3 deletions roles/applications/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ collections:
- ansible.controller
- awx.awx

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: global_vars
...
8 changes: 6 additions & 2 deletions roles/applications/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# Create Controller applications
- name: Add Controller Applications
- name: "Managing Controller Applications"
application:
name: "{{ __application_item.name | mandatory }}"
new_name: "{{ __application_item.new_name | default(omit, true) }}"
Expand All @@ -23,15 +23,17 @@
loop: "{{ applications if applications is defined else controller_applications }}"
loop_control:
loop_var: "__application_item"
label: "{{ __operation.verb }} Controller Application {{ __application_item.name }}"
no_log: "{{ controller_configuration_applications_secure_logging }}"
async: 1000
poll: 0
register: __applications_job_async
changed_when: not __applications_job_async.changed
vars:
__operation: "{{ operation_translate[__application_item.state | default(controller_state) | default('present')] }}"
ansible_async_dir: '{{ controller_configuration_async_dir }}'

- name: "Create Applications | Wait for finish the Applications creation"
- name: "Managing Controller Applications | Wait for finish the Application management"
ansible.builtin.async_status:
jid: "{{ __applications_job_async_results_item.ansible_job_id }}"
register: __applications_job_async_result
Expand All @@ -41,8 +43,10 @@
loop: "{{ __applications_job_async.results }}"
loop_control:
loop_var: __applications_job_async_results_item
label: "{{ __operation.verb }} Controller Application {{ __applications_job_async_results_item.__application_item.name }} | Wait for finish the Application {{ __operation.action }}"
when: __applications_job_async_results_item.ansible_job_id is defined
no_log: "{{ controller_configuration_applications_secure_logging }}"
vars:
__operation: "{{ operation_translate[__applications_job_async_results_item.__application_item.state | default(controller_state) | default('present')] }}"
ansible_async_dir: '{{ controller_configuration_async_dir }}'
...
2 changes: 1 addition & 1 deletion roles/credential_input_sources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Description

An Ansible Role to create credential input sources on Ansible Controller, the below example is for CyberArk as an input source, change accordingly to match your input source type.
An Ansible Role to create/update/remove credential input sources on Ansible Controller, the below example is for CyberArk as an input source, change accordingly to match your input source type.

## Requirements

Expand Down
7 changes: 4 additions & 3 deletions roles/credential_input_sources/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ collections:
- ansible.controller
- awx.awx

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: global_vars
...
8 changes: 6 additions & 2 deletions roles/credential_input_sources/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Add Controller Credential Input Sources
- name: "Managing Controller Credential Input Sources"
credential_input_source:
target_credential: "{{ __cred_input_src_item.target_credential | mandatory }}"
input_field_name: "{{ __cred_input_src_item.input_field_name | mandatory }}"
Expand All @@ -19,15 +19,17 @@
loop: "{{ controller_credential_input_sources }}"
loop_control:
loop_var: "__cred_input_src_item"
label: "{{ __operation.verb }} Controller Credential Input Source for Credential {{ __cred_input_src_item.target_credential }}"
no_log: "{{ controller_configuration_credential_input_sources_secure_logging }}"
async: 1000
poll: 0
register: __credential_input_sources_job_async
changed_when: not __credential_input_sources_job_async.changed
vars:
__operation: "{{ operation_translate[__cred_input_src_item.state | default(controller_state) | default('present')] }}"
ansible_async_dir: '{{ controller_configuration_async_dir }}'

- name: "Create Controller Credential Input Sources | Wait for finish the Controller Credential Input Sources creation"
- name: "Managing Controller Credential Input Sources | Wait for finish the Controller Credential Input Sources management"
ansible.builtin.async_status:
jid: "{{ __credential_input_sources_job_async_results_item.ansible_job_id }}"
register: __credential_input_sources_job_async_result
Expand All @@ -37,8 +39,10 @@
loop: "{{ __credential_input_sources_job_async.results }}"
loop_control:
loop_var: __credential_input_sources_job_async_results_item
label: "{{ __operation.verb }} Controller Credential Input Source for Credential {{ __credential_input_sources_job_async_results_item.__cred_input_src_item.target_credential }}"
when: __credential_input_sources_job_async_results_item.ansible_job_id is defined
no_log: "{{ controller_configuration_credential_input_sources_secure_logging }}"
vars:
__operation: "{{ operation_translate[__credential_input_sources_job_async_results_item.__cred_input_src_item.state | default(controller_state) | default('present')] }}"
ansible_async_dir: '{{ controller_configuration_async_dir }}'
...
2 changes: 1 addition & 1 deletion roles/credential_types/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Description

An Ansible Role to create Credential Types on Ansible Controller.
An Ansible Role to create/update/remove Credential Types on Ansible Controller.

## Requirements

Expand Down
7 changes: 4 additions & 3 deletions roles/credential_types/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ collections:
- ansible.controller
- awx.awx

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: global_vars
...
8 changes: 6 additions & 2 deletions roles/credential_types/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Add Credential Types
- name: "Managing Credential Types"
credential_type:
name: "{{ __controller_credential_type_item.name | mandatory }}"
new_name: "{{ __controller_credential_type_item.new_name | default(omit, true) }}"
Expand All @@ -20,15 +20,17 @@
loop: "{{ credential_types if credential_types is defined else controller_credential_types }}"
loop_control:
loop_var: __controller_credential_type_item
label: "{{ __operation.verb }} Credential Type {{ __controller_credential_type_item.name }}"
no_log: "{{ controller_configuration_credential_types_secure_logging }}"
async: 1000
poll: 0
register: __credentialtypes_job_async
changed_when: not __credentialtypes_job_async.changed
vars:
__operation: "{{ operation_translate[__controller_credential_type_item.state | default(controller_state) | default('present')] }}"
ansible_async_dir: '{{ controller_configuration_async_dir }}'

- name: "Configure Controller Credential Types | Wait for finish the credential types creation"
- name: "Managing Controller Credential Types | Wait for finish the credential types management"
ansible.builtin.async_status:
jid: "{{ __credentialtypes_job_async_result_item.ansible_job_id }}"
register: __credentialtypes_job_async_result
Expand All @@ -38,8 +40,10 @@
loop: "{{ __credentialtypes_job_async.results }}"
loop_control:
loop_var: __credentialtypes_job_async_result_item
label: "{{ __operation.verb }} Controller Credential Type {{ __credentialtypes_job_async_result_item }} | Wait for finish the credential type {{ __operation.action }}"
when: __credentialtypes_job_async_result_item.ansible_job_id is defined
no_log: "{{ controller_configuration_credential_types_secure_logging }}"
vars:
__operation: "{{ operation_translate[__credentialtypes_job_async_result_item.__controller_credential_type_item.state | default(controller_state) | default('present')] }}"
ansible_async_dir: '{{ controller_configuration_async_dir }}'
...
2 changes: 1 addition & 1 deletion roles/credentials/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Description

An Ansible Role to create Credentials on Ansible Controller.
An Ansible Role to create/update/remove Credentials on Ansible Controller.

## Requirements

Expand Down
7 changes: 4 additions & 3 deletions roles/credentials/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ collections:
- ansible.controller
- awx.awx

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: global_vars
...
12 changes: 7 additions & 5 deletions roles/credentials/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
- name: Add Credentials
- name: "Managing Credentials"
credential:
name: "{{ __controller_credentials_item.name | mandatory }}"
new_name: "{{ __controller_credentials_item.new_name | default(omit, true) }}"
copy_from: "{{ __controller_credentials_item.copy_from | default(omit, true) }}"
description: "{{ __controller_credentials_item.description | default(('' if controller_configuration_credentials_enforce_defaults else omit), true) }}"
organization: "{{ __controller_credentials_item.organization.name | default(__controller_credentials_item.organization | default(('' if controller_configuration_credentials_enforce_defaults else omit), true)) }}"
credential_type: "{{ __controller_credentials_item.credential_type.name | default(__controller_credentials_item.credential_type | mandatory ) }}"
credential_type: "{{ __controller_credentials_item.credential_type.name | default(__controller_credentials_item.credential_type | mandatory) }}"
inputs: "{{ __controller_credentials_item.inputs | default(({} if controller_configuration_credentials_enforce_defaults else omit), true) }}"
user: "{{ __controller_credentials_item.user.username | default(__controller_credentials_item.user | default(('' if controller_configuration_credentials_enforce_defaults else omit), true)) }}"
team: "{{ __controller_credentials_item.team.name | default(__controller_credentials_item.team | default(('' if controller_configuration_credentials_enforce_defaults else omit), true)) }}"
Expand All @@ -23,16 +23,17 @@
loop: "{{ credentials if credentials is defined else controller_credentials }}"
loop_control:
loop_var: __controller_credentials_item
label: "{{ __controller_credentials_item.name | mandatory }}"
label: "{{ __operation.verb }} Credential {{ __controller_credentials_item.name }}"
no_log: "{{ controller_configuration_credentials_secure_logging }}"
async: 1000
poll: 0
register: __credentials_job_async
changed_when: not __credentials_job_async.changed
vars:
__operation: "{{ operation_translate[__controller_credentials_item.state | default(controller_state) | default('present')] }}"
ansible_async_dir: '{{ controller_configuration_async_dir }}'

- name: "Configure Controller Credentials | Wait for finish the credential creation"
- name: "Managing Controller Credentials | Wait for finish the credential management"
ansible.builtin.async_status:
jid: "{{ __credentials_job_async_results_item.ansible_job_id }}"
register: __credentials_job_async_result
Expand All @@ -42,9 +43,10 @@
loop: "{{ __credentials_job_async.results }}"
loop_control:
loop_var: __credentials_job_async_results_item
label: "{{ __credentials_job_async_results_item.__controller_credentials_item.name }}"
label: "{{ __operation.verb }} Credential {{ __credentials_job_async_results_item.__controller_credentials_item.name }} | Wait for finish the credential {{ __operation.action }}"
when: __credentials_job_async_results_item.ansible_job_id is defined
no_log: "{{ controller_configuration_credentials_secure_logging }}"
vars:
__operation: "{{ operation_translate[__controller_credentials_item.state | default(controller_state) | default('present')] }}"
ansible_async_dir: '{{ controller_configuration_async_dir }}'
...
2 changes: 1 addition & 1 deletion roles/dispatch/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: "Run infra.controller_configuration.{{ __role.role }}"
- name: "Run the following infra.controller_configuration roles: {{ controller_configuration_dispatcher_roles | map(attribute='role') | join(', ') }}"
ansible.builtin.include_role:
name: "{{ __role.role }}"
apply:
Expand Down
2 changes: 1 addition & 1 deletion roles/execution_environments/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Description

An Ansible Role to create execution_environments on Ansible Controller.
An Ansible Role to create/update/remove execution_environments on Ansible Controller.

## Requirements

Expand Down
7 changes: 4 additions & 3 deletions roles/execution_environments/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ collections:
- ansible.controller
- awx.awx

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: global_vars
...
16 changes: 10 additions & 6 deletions roles/execution_environments/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
# Create Controller Execution Environments
- name: Add Controller Execution Environments
- name: "Managing Controller Execution Environments"
execution_environment:
name: "{{ __execution_environments_item.name | mandatory }}"
new_name: "{{ __execution_environments_item.new_name | default(omit, true) }}"
description: "{{ __execution_environments_item.description | default(( '' if controller_configuration_execution_environments_enforce_defaults else omit), true) }}"
description: "{{ __execution_environments_item.description | default(('' if controller_configuration_execution_environments_enforce_defaults else omit), true) }}"
image: "{{ __execution_environments_item.image | mandatory }}"
organization: "{{ __execution_environments_item.organization.name | default(__execution_environments_item.organization | default(( '' if controller_configuration_execution_environments_enforce_defaults else omit), true)) }}"
credential: "{{ __execution_environments_item.credential | default(( '' if controller_configuration_execution_environments_enforce_defaults else omit), true) }}"
pull: "{{ __execution_environments_item.pull | default(( 'missing' if controller_configuration_execution_environments_enforce_defaults else omit), true) }}"
organization: "{{ __execution_environments_item.organization.name | default(__execution_environments_item.organization | default(('' if controller_configuration_execution_environments_enforce_defaults else omit), true)) }}"
credential: "{{ __execution_environments_item.credential | default(('' if controller_configuration_execution_environments_enforce_defaults else omit), true) }}"
pull: "{{ __execution_environments_item.pull | default(('missing' if controller_configuration_execution_environments_enforce_defaults else omit), true) }}"
state: "{{ __execution_environments_item.state | default(controller_state | default('present')) }}"

# Role specific options
Expand All @@ -22,16 +22,18 @@
loop: "{{ execution_environments if execution_environments is defined else controller_execution_environments }}"
loop_control:
loop_var: "__execution_environments_item"
label: "{{ __operation.verb }} Controller Execution Environment {{ __execution_environments_item }}"
no_log: "{{ controller_configuration_execution_environments_secure_logging }}"
when: controller_execution_environments is defined
async: 1000
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: "Create Controller Execution Environments | Wait for finish the Controller Execution Environments creation"
- name: "Managing Controller Execution Environments | Wait for finish the Controller Execution Environments management"
ansible.builtin.async_status:
jid: "{{ __execution_environments_job_async_results_item.ansible_job_id }}"
register: __execution_environments_job_async_result
Expand All @@ -41,8 +43,10 @@
loop: "{{ __execution_environments_job_async.results }}"
loop_control:
loop_var: __execution_environments_job_async_results_item
label: "{{ __operation.verb }} Controller Execution Environment {{ __execution_environments_job_async_results_item.__execution_environments_item.name }} | Wait for finish the Controller Execution Environment {{ __operation.action }}"
when: __execution_environments_job_async_results_item.ansible_job_id is defined
no_log: "{{ controller_configuration_execution_environments_secure_logging }}"
vars:
__operation: "{{ operation_translate[__execution_environments_job_async_results_item.__execution_environments_item.state | default(controller_state) | default('present')] }}"
ansible_async_dir: '{{ controller_configuration_async_dir }}'
...
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ controller_notifications:
{% elif (value | lower) is match('true') or (value | lower) is match('false') %}
{{ key }}: {{ value | bool }}
{% else %}
{{ key }}: {{ '!unsafe ' if ( value | regex_search('{{')) }}"{{ value | replace('\n','\\n') | replace('"', '\\"') }}"
{{ key }}: {{ '!unsafe ' if (value | regex_search('{{')) }}"{{ value | replace('\n','\\n') | replace('"', '\\"') }}"
{% endif %}
{% endfor %}
{% if current_notification_templates_asset_value.messages is defined and current_notification_templates_asset_value.messages %}
Expand Down
Loading

0 comments on commit f45b00f

Please sign in to comment.