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
  • Loading branch information
ivarmu committed Oct 20, 2023
1 parent 9176050 commit 9287745
Show file tree
Hide file tree
Showing 65 changed files with 235 additions and 81 deletions.
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
3 changes: 2 additions & 1 deletion 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: []
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,

Check failure on line 45 in roles/applications/meta/main.yml

View workflow job for this annotation

GitHub Actions / pre-commit_and_sanity / pre-commit / pre-commit

yaml[comments-indentation]

Comment not indented like content
# if you add dependencies to this list.
- global_vars
...
6 changes: 4 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: "{{ __operation.verb }} Controller Applications"

Check failure on line 3 in roles/applications/tasks/main.yml

View workflow job for this annotation

GitHub Actions / pre-commit_and_sanity / pre-commit / pre-commit

name[template]

Jinja templates should only be at the end of 'name'
application:
name: "{{ __application_item.name | mandatory }}"
new_name: "{{ __application_item.new_name | default(omit, true) }}"
Expand Down Expand Up @@ -29,9 +29,10 @@
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: "{{ __operation.verb }} Applications | Wait for finish the Applications {{ __operation.action }}"

Check failure on line 35 in roles/applications/tasks/main.yml

View workflow job for this annotation

GitHub Actions / pre-commit_and_sanity / pre-commit / pre-commit

name[template]

Jinja templates should only be at the end of 'name'
ansible.builtin.async_status:
jid: "{{ __applications_job_async_results_item.ansible_job_id }}"
register: __applications_job_async_result
Expand All @@ -44,5 +45,6 @@
when: __applications_job_async_results_item.ansible_job_id is defined
no_log: "{{ controller_configuration_applications_secure_logging }}"
vars:
__operation: "{{ operation_translate[__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
3 changes: 2 additions & 1 deletion 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: []
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,

Check failure on line 49 in roles/credential_input_sources/meta/main.yml

View workflow job for this annotation

GitHub Actions / pre-commit_and_sanity / pre-commit / pre-commit

yaml[comments-indentation]

Comment not indented like content
# if you add dependencies to this list.
- global_vars
...
6 changes: 4 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: "{{ __operation.verb }} Controller Credential Input Sources"

Check failure on line 2 in roles/credential_input_sources/tasks/main.yml

View workflow job for this annotation

GitHub Actions / pre-commit_and_sanity / pre-commit / pre-commit

name[template]

Jinja templates should only be at the end of 'name'
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 @@ -25,9 +25,10 @@
register: __credential_input_sources_job_async
changed_when: not __credential_input_sources_job_async.changed
vars:
__operation: "{{ operation_translate[__application_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: "{{ __operation.verb }} Controller Credential Input Sources | Wait for finish the Controller Credential Input Sources {{ __operation.action }}"

Check failure on line 31 in roles/credential_input_sources/tasks/main.yml

View workflow job for this annotation

GitHub Actions / pre-commit_and_sanity / pre-commit / pre-commit

name[template]

Jinja templates should only be at the end of 'name'
ansible.builtin.async_status:
jid: "{{ __credential_input_sources_job_async_results_item.ansible_job_id }}"
register: __credential_input_sources_job_async_result
Expand All @@ -40,5 +41,6 @@
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[__application_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
3 changes: 2 additions & 1 deletion 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: []
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,

Check failure on line 44 in roles/credential_types/meta/main.yml

View workflow job for this annotation

GitHub Actions / pre-commit_and_sanity / pre-commit / pre-commit

yaml[comments-indentation]

Comment not indented like content
# if you add dependencies to this list.
- global_vars
...
6 changes: 4 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: "{{ __operation.verb }} Credential Types"
credential_type:
name: "{{ __controller_credential_type_item.name | mandatory }}"
new_name: "{{ __controller_credential_type_item.new_name | default(omit, true) }}"
Expand All @@ -26,9 +26,10 @@
register: __credentialtypes_job_async
changed_when: not __credentialtypes_job_async.changed
vars:
__operation: "{{ operation_translate[__application_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: "{{ __operation.verb }} Controller Credential Types | Wait for finish the credential types {{ __operation.action }}"
ansible.builtin.async_status:
jid: "{{ __credentialtypes_job_async_result_item.ansible_job_id }}"
register: __credentialtypes_job_async_result
Expand All @@ -41,5 +42,6 @@
when: __credentialtypes_job_async_result_item.ansible_job_id is defined
no_log: "{{ controller_configuration_credential_types_secure_logging }}"
vars:
__operation: "{{ operation_translate[__application_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
3 changes: 2 additions & 1 deletion 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: []
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- global_vars
...
6 changes: 4 additions & 2 deletions roles/credentials/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Add Credentials
- name: "{{ __operation.verb }} Credentials"
credential:
name: "{{ __controller_credentials_item.name | mandatory }}"

Check warning on line 4 in roles/credentials/tasks/main.yml

View workflow job for this annotation

GitHub Actions / pre-commit_and_sanity / pre-commit / pre-commit

jinja[spacing]

Jinja2 spacing could be improved: {{ __controller_credentials_item.credential_type.name | default(__controller_credentials_item.credential_type | mandatory ) }} -> {{ __controller_credentials_item.credential_type.name | default(__controller_credentials_item.credential_type | mandatory) }}
new_name: "{{ __controller_credentials_item.new_name | default(omit, true) }}"
Expand Down Expand Up @@ -30,9 +30,10 @@
register: __credentials_job_async
changed_when: not __credentials_job_async.changed
vars:
__operation: "{{ operation_translate[__application_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: "{{ __operation.verb }} Controller Credentials | Wait for finish the credential {{ __operation.action }}"
ansible.builtin.async_status:
jid: "{{ __credentials_job_async_results_item.ansible_job_id }}"
register: __credentials_job_async_result
Expand All @@ -46,5 +47,6 @@
when: __credentials_job_async_results_item.ansible_job_id is defined
no_log: "{{ controller_configuration_credentials_secure_logging }}"
vars:
__operation: "{{ operation_translate[__application_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
3 changes: 2 additions & 1 deletion 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: []
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- global_vars
...
6 changes: 4 additions & 2 deletions roles/execution_environments/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# Create Controller Execution Environments
- name: Add Controller Execution Environments
- name: "{{ __operation.verb }} Controller Execution Environments"
execution_environment:
name: "{{ __execution_environments_item.name | mandatory }}"

Check warning on line 5 in roles/execution_environments/tasks/main.yml

View workflow job for this annotation

GitHub Actions / pre-commit_and_sanity / pre-commit / pre-commit

jinja[spacing]

Jinja2 spacing could be improved: {{ __execution_environments_item.credential | default(( '' if controller_configuration_execution_environments_enforce_defaults else omit), true) }} -> {{ __execution_environments_item.credential | default(('' if controller_configuration_execution_environments_enforce_defaults else omit), true) }}

Check warning on line 5 in roles/execution_environments/tasks/main.yml

View workflow job for this annotation

GitHub Actions / pre-commit_and_sanity / pre-commit / pre-commit

jinja[spacing]

Jinja2 spacing could be improved: {{ __execution_environments_item.description | default(( '' if controller_configuration_execution_environments_enforce_defaults else omit), true) }} -> {{ __execution_environments_item.description | default(('' if controller_configuration_execution_environments_enforce_defaults else omit), true) }}

Check warning on line 5 in roles/execution_environments/tasks/main.yml

View workflow job for this annotation

GitHub Actions / pre-commit_and_sanity / pre-commit / pre-commit

jinja[spacing]

Jinja2 spacing could be improved: {{ __execution_environments_item.organization.name | default(__execution_environments_item.organization | default(( '' if controller_configuration_execution_environments_enforce_defaults else omit), true)) }} -> {{ __execution_environments_item.organization.name | default(__execution_environments_item.organization | default(('' if controller_configuration_execution_environments_enforce_defaults else omit), true)) }}

Check warning on line 5 in roles/execution_environments/tasks/main.yml

View workflow job for this annotation

GitHub Actions / pre-commit_and_sanity / pre-commit / pre-commit

jinja[spacing]

Jinja2 spacing could be improved: {{ __execution_environments_item.pull | default(( 'missing' if controller_configuration_execution_environments_enforce_defaults else omit), true) }} -> {{ __execution_environments_item.pull | default(('missing' if controller_configuration_execution_environments_enforce_defaults else omit), true) }}
new_name: "{{ __execution_environments_item.new_name | default(omit, true) }}"
Expand Down Expand Up @@ -29,9 +29,10 @@
register: __execution_environments_job_async
changed_when: not __execution_environments_job_async.changed
vars:
__operation: "{{ operation_translate[__application_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: "{{ __operation.verb }} Controller Execution Environments | Wait for finish the Controller Execution Environments {{ __operation.action }}"
ansible.builtin.async_status:
jid: "{{ __execution_environments_job_async_results_item.ansible_job_id }}"
register: __execution_environments_job_async_result
Expand All @@ -44,5 +45,6 @@
when: __execution_environments_job_async_results_item.ansible_job_id is defined
no_log: "{{ controller_configuration_execution_environments_secure_logging }}"
vars:
__operation: "{{ operation_translate[__application_item.state | default(controller_state) | default('present')] }}"
ansible_async_dir: '{{ controller_configuration_async_dir }}'
...
22 changes: 22 additions & 0 deletions roles/global_vars/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# controller_configuration.global_vars

## Description

An ansible role to define global variables that will be available to all of the
roles in the collection, if they are configured as follows:

# tail -4 meta/main.yml

dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- global_vars

## Provided Variables

This is currently providing the following variables:

|Variable Name|Default Value|Required|Description|
|:---|:---|:---:|:---|
|`operation_translate`|<pre lang=yaml>operation_translate:<br> present:<br> verb: "Create/Update"<br> action: "creation"<br> absent:<br> verb: "Remove"<br> action: "deletion"</pre>|Yes|Provides translation from object states to human interpretation.|

9 changes: 9 additions & 0 deletions roles/global_vars/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
# defaults file for global_vars
operation_translate:
present:
verb: "Create/Update"
action: "creation"
absent:
verb: "Remove"
action: "deletion"
52 changes: 52 additions & 0 deletions roles/global_vars/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
galaxy_info:
author: your name
description: your role description
company: your company (optional)

# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker

# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: license (GPL-2.0-or-later, MIT, etc)

min_ansible_version: 2.1

# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:

#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99

galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
2 changes: 2 additions & 0 deletions roles/global_vars/vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
# vars file for global_vars
2 changes: 1 addition & 1 deletion roles/groups/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Description

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

## Requirements

Expand Down
3 changes: 2 additions & 1 deletion roles/groups/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: []
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- global_vars
...
6 changes: 4 additions & 2 deletions roles/groups/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# The group module is also an ansible.builtin module, but due to supporting both the awx.awx and automation.controller collections
# the FQCN cannot be used here.
- name: Add controller group # noqa fqcn[action-core]
- name: "{{ __operation.verb }} controller group" # noqa fqcn[action-core]
group:
name: "{{ controller_groups_item.name | mandatory }}"

Check warning on line 6 in roles/groups/tasks/main.yml

View workflow job for this annotation

GitHub Actions / pre-commit_and_sanity / pre-commit / pre-commit

jinja[spacing]

Jinja2 spacing could be improved: {{ controller_groups_item.children | default(( [] if controller_configuration_groups_enforce_defaults else omit), true) }} -> {{ controller_groups_item.children | default(([] if controller_configuration_groups_enforce_defaults else omit), true) }}

Check warning on line 6 in roles/groups/tasks/main.yml

View workflow job for this annotation

GitHub Actions / pre-commit_and_sanity / pre-commit / pre-commit

jinja[spacing]

Jinja2 spacing could be improved: {{ controller_groups_item.description | default(( '' if controller_configuration_groups_enforce_defaults else omit), true) }} -> {{ controller_groups_item.description | default(('' if controller_configuration_groups_enforce_defaults else omit), true) }}

Check warning on line 6 in roles/groups/tasks/main.yml

View workflow job for this annotation

GitHub Actions / pre-commit_and_sanity / pre-commit / pre-commit

jinja[spacing]

Jinja2 spacing could be improved: {{ controller_groups_item.hosts | default(( [] if controller_configuration_groups_enforce_defaults else omit), true) }} -> {{ controller_groups_item.hosts | default(([] if controller_configuration_groups_enforce_defaults else omit), true) }}

Check warning on line 6 in roles/groups/tasks/main.yml

View workflow job for this annotation

GitHub Actions / pre-commit_and_sanity / pre-commit / pre-commit

jinja[spacing]

Jinja2 spacing could be improved: {{ controller_groups_item.preserve_existing_children | default(( false if controller_configuration_groups_enforce_defaults else omit)) }} -> {{ controller_groups_item.preserve_existing_children | default((false if controller_configuration_groups_enforce_defaults else omit)) }}

Check warning on line 6 in roles/groups/tasks/main.yml

View workflow job for this annotation

GitHub Actions / pre-commit_and_sanity / pre-commit / pre-commit

jinja[spacing]

Jinja2 spacing could be improved: {{ controller_groups_item.preserve_existing_hosts | default(( false if controller_configuration_groups_enforce_defaults else omit)) }} -> {{ controller_groups_item.preserve_existing_hosts | default((false if controller_configuration_groups_enforce_defaults else omit)) }}
new_name: "{{ controller_groups_item.new_name | default(omit, true) }}"
Expand Down Expand Up @@ -31,9 +31,10 @@
register: __group_job_async
changed_when: not __group_job_async.changed
vars:
__operation: "{{ operation_translate[__application_item.state | default(controller_state) | default('present')] }}"
ansible_async_dir: '{{ controller_configuration_async_dir }}'

- name: "Create Controller Group | Wait for finish the Controller Group creation"
- name: "{{ __operation.verb }} Controller Group | Wait for finish the Controller Group {{ __operation.action }}"
ansible.builtin.async_status:
jid: "{{ __group_job_async_results_item.ansible_job_id }}"
register: __group_job_async_result
Expand All @@ -46,5 +47,6 @@
when: __group_job_async_results_item.ansible_job_id is defined
no_log: "{{ controller_configuration_group_secure_logging }}"
vars:
__operation: "{{ operation_translate[__application_item.state | default(controller_state) | default('present')] }}"
ansible_async_dir: '{{ controller_configuration_async_dir }}'
...
2 changes: 1 addition & 1 deletion roles/hosts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Description

An Ansible Role to add hosts on Ansible Controller.
An Ansible Role to add/update/remove hosts on Ansible Controller.

## Requirements

Expand Down
3 changes: 2 additions & 1 deletion roles/hosts/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: []
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- global_vars
...
Loading

0 comments on commit 9287745

Please sign in to comment.