Skip to content

Commit 0361553

Browse files
update options on multiple roles
1 parent 7b81c7e commit 0361553

File tree

29 files changed

+402
-39
lines changed

29 files changed

+402
-39
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ Adding the ability to use direct output from the awx export command in the roles
160160
We welcome community contributions to this collection. If you find problems, please open an issue or create a PR against the [Controller Configuration collection repository](https://github.com/redhat-cop/controller_configuration).
161161
More information about contributing can be found in our [Contribution Guidelines.](https://github.com/redhat-cop/controller_configuration/blob/devel/.github/CONTRIBUTING.md)
162162

163+
## Code of Conduct
164+
165+
This collection follows the Ansible project's
166+
[Code of Conduct](https://docs.ansible.com/ansible/devel/community/code_of_conduct.html).
167+
Please read and familiarize yourself with this document.
168+
163169
## Licensing
164170

165171
GNU General Public License v3.0 or later.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
minor_changes:
3+
- Update options on inventories, job templates, liscence, projects, schedules, and workflow_job_templates roles to match latest awx.awx release
4+
5+
major_changes:
6+
- Added instance role to add instances using the new awx.awx.instance module.
7+
...

examples/configs/instances.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
controller_instances:
3+
- hostname: my-instance.prod.example.com
4+
capacity_adjustment: 0.4
5+
...

examples/configs/inventories.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ controller_inventories:
1616
- name: RHVM-02
1717
organization: Satellite
1818
description: created by Ansible Playbook - for RHVM-02
19+
prevent_instance_group_fallback: true
1920
- name: Test Inventory - Smart
2021
organization: Default
2122
description: created by Ansible Playbook

examples/configs/schedule.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,12 @@ controller_schedules:
88
description: Another demonstration
99
unified_job_template: Demo Job Template
1010
rrule: "DTSTART:20200101T000000Z RRULE:FREQ=HOURLY;INTERVAL=3"
11+
execution_environment: My EE
12+
forks: 2
13+
instance_groups:
14+
- test_instance_group
15+
labels:
16+
- differential
17+
- differential2
18+
timeout: 165
1119
...

examples/configs/templates.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ controller_templates:
1616
verbosity: 2
1717
extra_vars:
1818
target_hosts: infra-ansible-tower-01.example.com
19+
ask_execution_environment_on_launch: true
20+
ask_forks_on_launch: true
21+
ask_instance_groups_on_launch: true
22+
ask_job_slice_count_on_launch: true
23+
ask_labels_on_launch: true
24+
ask_timeout_on_launch: true
25+
prevent_instance_group_fallback: true
1926
- name: Demo Job Template
2027
project: Test Project
2128
job_type: run
@@ -26,6 +33,14 @@ controller_templates:
2633
verbosity: 0
2734
inventory: localhost
2835
execution_environment: "My EE"
36+
ask_inventory_on_launch: true
37+
ask_execution_environment_on_launch: true
38+
ask_forks_on_launch: true
39+
ask_instance_groups_on_launch: true
40+
ask_job_slice_count_on_launch: true
41+
ask_labels_on_launch: true
42+
ask_timeout_on_launch: true
43+
prevent_instance_group_fallback: true
2944
survey_spec:
3045
name: ''
3146
description: ''

examples/configs/workflows.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ controller_workflows:
99
inventory:
1010
state: present
1111
limit:
12+
job_tags:
13+
- stuff
14+
- stuff2
15+
skip_tags:
16+
- stuff3
17+
ask_labels_on_launch: true
18+
ask_skip_tags_on_launch: true
1219
labels:
1320
- Prod
1421
scm_branch:
@@ -26,6 +33,13 @@ controller_workflows:
2633
- all_parents_must_converge: false
2734
identifier: node201
2835
unified_job_template: test-template-1
36+
forks: 2
37+
instance_groups:
38+
- test_instance_group
39+
labels:
40+
- differential
41+
- differential2
42+
timeout: 165
2943
notification_templates_started: []
3044
notification_templates_success: []
3145
notification_templates_error: []

roles/dispatch/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ controller_configuration_dispatcher_roles:
1515
- {role: inventory_source_update, var: controller_inventory_sources, tags: inventory_sources}
1616
- {role: execution_environments, var: controller_execution_environments, tags: execution_environments}
1717
- {role: applications, var: controller_applications, tags: applications}
18+
- {role: instances, var: controller_instances, tags: instances}
1819
- {role: instance_groups, var: controller_instance_groups, tags: instance_groups}
1920
- {role: project_update, var: controller_projects, tags: projects}
2021
- {role: hosts, var: controller_hosts, tags: hosts}

roles/instances/README.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# controller_configuration.instances
2+
3+
## Description
4+
5+
An Ansible Role to create instances on Ansible Controller.
6+
7+
## Requirements
8+
9+
ansible-galaxy collection install -r tests/collections/requirements.yml to be installed
10+
Currently:
11+
awx.awx
12+
or
13+
ansible.controller
14+
15+
## Variables
16+
17+
### Authentication
18+
19+
|Variable Name|Default Value|Required|Description|Example|
20+
|:---|:---:|:---:|:---|:---|
21+
|`controller_state`|"present"|no|The state all objects will take unless overridden by object default|'absent'|
22+
|`controller_hostname`|""|yes|URL to the Ansible Controller Server.|127.0.0.1|
23+
|`controller_validate_certs`|`True`|no|Whether or not to validate the Ansible Controller Server's SSL certificate.||
24+
|`controller_username`|""|no|Admin User on the Ansible Controller Server. Either username / password or oauthtoken need to be specified.||
25+
|`controller_password`|""|no|Controller Admin User's password on the Ansible Controller Server. This should be stored in an Ansible Vault at vars/controller-secrets.yml or elsewhere and called from a parent playbook. Either username / password or oauthtoken need to be specified.||
26+
|`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.|||
27+
|`controller_instances`|`see below`|yes|Data structure describing your instances Described below.||
28+
29+
### Secure Logging Variables
30+
31+
The following Variables compliment each other.
32+
If Both variables are not set, secure logging defaults to false.
33+
The role defaults to False as normally the add instances task does not include sensitive information.
34+
controller_configuration_instances_secure_logging defaults to the value of controller_configuration_secure_logging if it is not explicitly called. This allows for secure logging to be toggled for the entire suite of controller configuration roles with a single variable, or for the user to selectively use it.
35+
36+
|Variable Name|Default Value|Required|Description|
37+
|:---:|:---:|:---:|:---:|
38+
|`controller_configuration_instances_secure_logging`|`False`|no|Whether or not to include the sensitive instance groups role tasks in the log. Set this value to `True` if you will be providing your sensitive values from elsewhere.|
39+
|`controller_configuration_secure_logging`|`False`|no|This variable enables secure logging as well, but is shared across multiple roles, see above.|
40+
41+
### Asynchronous Retry Variables
42+
43+
The following Variables set asynchronous retries for the role.
44+
If neither of the retries or delay or retries are set, they will default to their respective defaults.
45+
This allows for all items to be created, then checked that the task finishes successfully.
46+
This also speeds up the overall role.
47+
48+
|Variable Name|Default Value|Required|Description|
49+
|:---:|:---:|:---:|:---:|
50+
|`controller_configuration_async_retries`|30|no|This variable sets the number of retries to attempt for the role globally.|
51+
|`controller_configuration_instances_async_retries`|`{{ controller_configuration_async_retries }}`|no|This variable sets the number of retries to attempt for the role.|
52+
|`controller_configuration_async_delay`|1|no|This sets the delay between retries for the role globally.|
53+
|`controller_configuration_instances_async_delay`|`controller_configuration_async_delay`|no|This sets the delay between retries for the role.|
54+
55+
## Data Structure
56+
57+
### Instance Group Variables
58+
59+
|Variable Name|Default Value|Required|Type|Description|
60+
|:---:|:---:|:---:|:---:|:---:|
61+
|`hostname`|""|yes|str|Hostname of this instance.|
62+
|`capacity_adjustment`|""|float|no|Capacity adjustment between 0 and 1. |
63+
|`enabled`|False|no|bool|If true, the instance will be enabled and used.|
64+
|`managed_by_policy`|False|no|bool|If true, will be managed by instance group policy.|
65+
|`node_type`|""|no|str|Role that this node plays in the mesh. Most likely Execution. Current options are 'execution'.|
66+
|`node_state`|""|no|str|Indicates the current life cycle stage of this instance. Current options are 'installed' and 'deprovisioning'.|
67+
|`listener_port`|""|no|int|Port that Receptor will listen for incoming connections on.|
68+
69+
### Standard Project Data Structure
70+
71+
#### Yaml Example
72+
73+
```yaml
74+
---
75+
controller_instances:
76+
- hostname: my-instance.prod.example.com
77+
capacity_adjustment: 0.4
78+
listener_port: 31337
79+
```
80+
81+
## Playbook Examples
82+
83+
### Standard Role Usage
84+
85+
```yaml
86+
---
87+
- name: Playbook to configure ansible controller post installation
88+
hosts: localhost
89+
connection: local
90+
# Define following vars here, or in controller_configs/controller_auth.yml
91+
# controller_hostname: ansible-controller-web-svc-test-project.example.com
92+
# controller_username: admin
93+
# controller_password: changeme
94+
pre_tasks:
95+
- name: Include vars from controller_configs directory
96+
include_vars:
97+
dir: ./yaml
98+
ignore_files: [controller_config.yml.template]
99+
extensions: ["yml"]
100+
roles:
101+
- {role: redhat_cop.controller_configuration.instances, when: controller_instances is defined}
102+
```
103+
104+
## License
105+
106+
[MIT](LICENSE)
107+
108+
## Author
109+
110+
[Sean Sullivan](https://github.com/sean-m-sullivan)

roles/instances/defaults/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
controller_instances: []
3+
controller_configuration_instances_secure_logging: "{{ controller_configuration_secure_logging | default('false') }}"
4+
controller_configuration_instances_async_retries: "{{ controller_configuration_async_retries | default(30) }}"
5+
controller_configuration_instances_async_delay: "{{ controller_configuration_async_delay | default(1) }}"
6+
...

roles/instances/meta/main.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
galaxy_info:
3+
role_name: instances
4+
author: Sean Sullivan
5+
description: "An Ansible Role to create instances in Ansible Controller."
6+
company: "Red Hat"
7+
8+
# If the issue tracker for your role is not on github, uncomment the
9+
# next line and provide a value
10+
# issue_tracker_url: http://example.com/issue/tracker
11+
license: "MIT"
12+
13+
min_ansible_version: "2.8"
14+
15+
# Optionally specify the branch Galaxy will use when accessing the GitHub
16+
# repo for this role. During role install, if no tags are available,
17+
# Galaxy will use this branch. During import Galaxy will access files on
18+
# this branch. If Travis integration is configured, only notifications for this
19+
# branch will be accepted. Otherwise, in all cases, the repo's default branch
20+
# (usually master) will be used.
21+
22+
# github_branch:
23+
24+
#
25+
# platforms is a list of platforms, and each platform has a name and a list of versions.
26+
#
27+
platforms:
28+
- name: "EL"
29+
versions:
30+
- "all"
31+
32+
galaxy_tags:
33+
- "controller"
34+
- "aap"
35+
- "awx"
36+
- instance
37+
- instances
38+
39+
collections:
40+
- ansible.controller
41+
- awx.awx
42+
43+
dependencies: []
44+
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
45+
# if you add dependencies to this list.
46+
...

roles/instances/tasks/main.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
# Add Controller Instances
3+
- name: Add Controller Instance
4+
instance:
5+
hostname: "{{ __controller_instance_item.hostname | mandatory }}"
6+
capacity_adjustment: "{{ __controller_instance_item.capacity_adjustment | default(omit, true) }}"
7+
enabled: "{{ __controller_instance_item.enabled | default(omit, true) }}"
8+
managed_by_policy: "{{ __controller_instance_item.managed_by_policy | default(omit, true) }}"
9+
node_type: "{{ __controller_instance_item.node_type | default('execution') }}"
10+
node_state: "{{ __controller_instance_item.node_state | default('installed') }}"
11+
listener_port: "{{ __controller_instance_item.listener_port | default(omit, true) }}"
12+
13+
# Role Standard Options
14+
controller_username: "{{ controller_username | default(omit, true) }}"
15+
controller_password: "{{ controller_password | default(omit, true) }}"
16+
controller_oauthtoken: "{{ controller_oauthtoken | default(omit, true) }}"
17+
controller_host: "{{ controller_hostname | default(omit, true) }}"
18+
controller_config_file: "{{ controller_config_file | default(omit, true) }}"
19+
validate_certs: "{{ controller_validate_certs | default(omit) }}"
20+
loop: "{{ controller_instances }}"
21+
loop_control:
22+
loop_var: __controller_instance_item
23+
no_log: "{{ controller_configuration_instances_secure_logging }}"
24+
when: controller_instances is defined
25+
async: 1000
26+
poll: 0
27+
register: __instance_job_async
28+
changed_when: not __instance_job_async.changed
29+
vars:
30+
ansible_async_dir: '/tmp/.ansible_async'
31+
32+
- name: "Configure Controller instances | Wait for finish the instance creation"
33+
ansible.builtin.async_status:
34+
jid: "{{ __instance_job_async_results_item.ansible_job_id }}"
35+
register: __instance_job_async_result
36+
until: __instance_job_async_result.finished
37+
retries: "{{ controller_configuration_instances_async_retries }}"
38+
delay: "{{ controller_configuration_instances_async_delay }}"
39+
loop: "{{ __instance_job_async.results }}"
40+
loop_control:
41+
loop_var: __instance_job_async_results_item
42+
when: __instance_job_async_results_item.ansible_job_id is defined
43+
no_log: "{{ controller_configuration_instances_secure_logging }}"
44+
vars:
45+
ansible_async_dir: '/tmp/.ansible_async'
46+
...
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
controller_instances:
3+
- hostname: my-instance.prod.example.com
4+
capacity_adjustment: 0.4
5+
listener_port: 31337
6+
...

roles/instances/tests/test.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
- name: Add Instances on Controller
3+
hosts: localhost
4+
connection: local
5+
gather_facts: false
6+
vars:
7+
controller_validate_certs: false
8+
controller_hostname: controller.example.com
9+
controller_username: admin
10+
controller_password: changeme
11+
12+
collections:
13+
- awx.awx
14+
15+
pre_tasks:
16+
- name: Include vars from controller_configs directory
17+
include_vars:
18+
dir: ./configs
19+
extensions: ["yml"]
20+
21+
roles:
22+
- {role: ../.., when: controller_instances is defined}
23+
...

roles/inventories/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ The role will strip the double space between the curly bracket in order to provi
8686
|`variables`|`False`|no|Variables for the inventory.|
8787
|`kind`|`False`|no|The kind of inventory. Currently choices are '' and 'smart'|
8888
|`host_filter`|`False`|no|The host filter field, useful only when 'kind=smart'|
89+
|`prevent_instance_group_fallback`|`False`|no|Prevent falling back to instance groups set on the organization|
8990
|`state`|`present`|no|Desired state of the resource.|
9091

9192
### Standard Inventory Data Structure

roles/inventories/tasks/main.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
---
22
- name: Create inventory
33
inventory:
4-
name: "{{ __controller_inventory_item.name | mandatory }}"
5-
copy_from: "{{ __controller_inventory_item.copy_from | default(omit, true) }}"
6-
description: "{{ __controller_inventory_item.description | default(omit, true) }}"
7-
organization: "{{ __controller_inventory_item.organization.name | default(__controller_inventory_item.organization) | mandatory }}"
8-
instance_groups: "{{ __controller_inventory_item.instance_groups | default(omit, true) }}"
9-
variables: "{{ __controller_inventory_item.variables | default(omit, true) | regex_replace('[ ]{2,}', '') }}"
10-
kind: "{{ __controller_inventory_item.kind | default(omit, true) }}"
11-
host_filter: "{{ __controller_inventory_item.host_filter | default(omit, true) }}"
12-
state: "{{ __controller_inventory_item.state | default(controller_state | default('present')) }}"
4+
name: "{{ __controller_inventory_item.name | mandatory }}"
5+
copy_from: "{{ __controller_inventory_item.copy_from | default(omit, true) }}"
6+
description: "{{ __controller_inventory_item.description | default(omit, true) }}"
7+
organization: "{{ __controller_inventory_item.organization.name | default(__controller_inventory_item.organization) | mandatory }}"
8+
instance_groups: "{{ __controller_inventory_item.instance_groups | default(omit, true) }}"
9+
variables: "{{ __controller_inventory_item.variables | default(omit, true) | regex_replace('[ ]{2,}', '') }}"
10+
kind: "{{ __controller_inventory_item.kind | default(omit, true) }}"
11+
host_filter: "{{ __controller_inventory_item.host_filter | default(omit, true) }}"
12+
prevent_instance_group_fallback: "{{ __controller_inventory_item.prevent_instance_group_fallback | default(omit, true) }}"
13+
state: "{{ __controller_inventory_item.state | default(controller_state | default('present')) }}"
1314

1415
# Role Standard Options
1516
controller_config_file: "{{ controller_config_file | default(omit, true) }}"

0 commit comments

Comments
 (0)