-
Notifications
You must be signed in to change notification settings - Fork 0
/
hpsa_usecases.yml
95 lines (89 loc) · 3.6 KB
/
hpsa_usecases.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
---
- name: Construct inventories and job / workflow templates for HPSA
hosts: localhost
gather_facts: true
become: false
pre_tasks:
- name: Include vars to for getting token and loop over sites
ansible.builtin.include_vars:
dir: vars/
extensions:
- 'yml'
- 'yaml'
- 'json'
- name: Get AAP token
ansible.controller.token:
controller_host: "{{ aaphost }}"
controller_password: "{{ aappass }}"
controller_username: "{{ aapuser }}"
scope: 'write'
validate_certs: true
register: aaptoken
- name: Create random number to ensure all inventories and templates are unique to the job.
ansible.builtin.set_fact:
unique_job_number: "{{ ansible_date_time['year'] }}_\
{{ ansible_date_time['month'] }}_\
{{ ansible_date_time['day'] }}_\
{{ ansible_date_time['hour'] }}_\
{{ ansible_date_time['minute'] }}_\
{{ ansible_date_time['second'] }}"
tasks:
- name: Include role to generate inventories
ansible.builtin.include_role:
name: texasroadracing.inventories.construct_inventories
- name: Create job templates
block:
- name: Create Job Templates to run against Constructed Inventories
ansible.controller.job_template:
controller_host: "{{ aaphost }}"
controller_oauthtoken: "{{ aaptoken['ansible_facts']['controller_token']['token'] }}"
allow_simultaneous: true
ask_variables_on_launch: true
credentials: 'RHEL User'
inventory: "{{ site }} Constructed Inventory {{ unique_job_number }}"
job_type: 'run'
name: "{{ site}} Job Template {{ unique_job_number }}"
organization: 'Texas Roadracing'
project: 'Constructed Inventory and Instance Group Demo'
playbook: 'run_cmd.yml'
loop: "{{ locations }}"
loop_control:
loop_var: site
- name: Create workflow templates
block:
- name: Create Workflow for Constructed Inventories
ansible.controller.workflow_job_template:
controller_host: "{{ aaphost }}"
controller_oauthtoken: "{{ aaptoken['ansible_facts']['controller_token']['token'] }}"
allow_simultaneous: true
ask_variables_on_launch: true
name: "Multi-site Automation Workflow {{ unique_job_number }}"
organization: 'Texas Roadracing'
workflow_nodes:
- extra_data:
run_cmd: 'df -h'
identifier: "{{ site }}_001"
inventory: "{{ site }} Constructed Inventory {{ unique_job_number }}"
related:
always_nodes: []
failure_nodes: []
success_nodes: []
unified_job_template:
name: "{{ site}} Job Template {{ unique_job_number }}"
organization:
name: 'Texas Roadracing'
type: 'job_template'
loop: "{{ locations }}"
loop_control:
loop_var: site
- name: Launch workflows
block:
- name: Launch job in AAP against Constructed Inventories using remote instance groups
ansible.controller.workflow_launch:
controller_host: "{{ aaphost }}"
controller_oauthtoken: "{{ aaptoken['ansible_facts']['controller_token']['token'] }}"
extra_vars:
run_cmd: 'df -h'
wait: false
workflow_template: "Multi-site Automation Workflow {{ unique_job_number }}"
...