commit | author | age
|
1e2288
|
1 |
--- |
JR |
2 |
- name: Remove repo directory |
|
3 |
file: |
|
4 |
path: /tmp/do417 |
|
5 |
state: absent |
|
6 |
|
|
7 |
- name: Get ssh key for Github |
|
8 |
copy: |
|
9 |
src: "{{ github_ssh_key }}" |
|
10 |
dest: /tmp/github_ssh_key |
|
11 |
mode: 0400 |
|
12 |
owner: "{{ ansible_user }}" |
|
13 |
|
|
14 |
- name: Get lab source code |
|
15 |
git: |
|
16 |
clone: yes |
|
17 |
force: yes |
|
18 |
dest: "/tmp/do417" |
|
19 |
repo: "git@github.com:RedHatTraining/do417.git" |
|
20 |
key_file: /tmp/github_ssh_key |
|
21 |
accept_hostkey: true |
|
22 |
|
|
23 |
- name: Remove ssh key for Github |
|
24 |
file: |
|
25 |
path: /tmp/github_ssh_key |
|
26 |
state: absent |
|
27 |
|
|
28 |
- name: Remove .git directory |
|
29 |
file: |
|
30 |
path: /tmp/do417/.git |
|
31 |
state: absent |
|
32 |
|
|
33 |
- name: Determining material directories |
|
34 |
command: find /tmp/do417/classroom/infrastructure/playbooks/files/src -maxdepth 1 -mindepth 1 -type d -printf '%f\n' |
|
35 |
register: repos_name |
|
36 |
|
|
37 |
- name: Wait for Tower to be reachable |
|
38 |
wait_for: |
|
39 |
port: 443 |
|
40 |
delay: 5 |
|
41 |
|
|
42 |
- name: Retrieve default organization ID |
|
43 |
uri: |
409b6f
|
44 |
url: "https://tower.{{zone_internal_dns}}/api/v2/organizations/?name=Default" |
1e2288
|
45 |
method: GET |
JR |
46 |
user: admin |
|
47 |
password: "{{ tower_admin_password }}" |
|
48 |
body: "" |
|
49 |
body_format: json |
|
50 |
validate_certs: False |
|
51 |
force_basic_auth: yes |
|
52 |
status_code: |
|
53 |
- 200 |
|
54 |
register: organization_id |
|
55 |
|
|
56 |
- name: Retrieve default inventory ID |
|
57 |
uri: |
409b6f
|
58 |
url: "https://tower.{{zone_internal_dns}}/api/v2/inventories/?name=Default+inventory" |
1e2288
|
59 |
method: GET |
JR |
60 |
user: admin |
|
61 |
password: "{{ tower_admin_password }}" |
|
62 |
body: "" |
|
63 |
body_format: json |
|
64 |
validate_certs: False |
|
65 |
force_basic_auth: yes |
|
66 |
status_code: |
|
67 |
- 200 |
|
68 |
register: inventory_id |
|
69 |
|
|
70 |
- name: Create GitLab credentials |
|
71 |
uri: |
409b6f
|
72 |
url: "https://tower.{{zone_internal_dns}}/api/v2/credentials/" |
1e2288
|
73 |
method: POST |
JR |
74 |
user: admin |
|
75 |
password: "{{ tower_admin_password }}" |
|
76 |
body: "{{ lookup('template','gitlab-creds.json.j2') }}" |
|
77 |
body_format: json |
|
78 |
validate_certs: False |
|
79 |
force_basic_auth: yes |
|
80 |
status_code: |
|
81 |
- 200 |
|
82 |
- 201 |
|
83 |
- 400 |
|
84 |
register: response |
|
85 |
changed_when: response.status == 201 |
|
86 |
|
|
87 |
- name: Retrieve credentials ID |
|
88 |
uri: |
409b6f
|
89 |
url: "https://tower.{{zone_internal_dns}}/api/v2/credentials/?name=GitLab" |
1e2288
|
90 |
method: GET |
JR |
91 |
user: admin |
|
92 |
password: "{{ tower_admin_password }}" |
|
93 |
body: "" |
|
94 |
body_format: json |
|
95 |
validate_certs: False |
|
96 |
force_basic_auth: yes |
|
97 |
status_code: |
|
98 |
- 200 |
|
99 |
register: gitlab_credentials_id |
|
100 |
|
|
101 |
- name: Create DevOps credentials |
|
102 |
uri: |
409b6f
|
103 |
url: "https://tower.{{zone_internal_dns}}/api/v2/credentials/" |
1e2288
|
104 |
method: POST |
JR |
105 |
user: admin |
|
106 |
password: "{{ tower_admin_password }}" |
|
107 |
body: "{{ lookup('template','devops-creds.json.j2') }}" |
|
108 |
body_format: json |
|
109 |
validate_certs: False |
|
110 |
force_basic_auth: yes |
|
111 |
status_code: |
|
112 |
- 200 |
|
113 |
- 201 |
|
114 |
- 400 |
|
115 |
register: response |
|
116 |
changed_when: response.status == 201 |
|
117 |
|
|
118 |
- name: Retrieve credentials ID |
|
119 |
uri: |
409b6f
|
120 |
url: "https://tower.{{zone_internal_dns}}/api/v2/credentials/?name=DevOps" |
1e2288
|
121 |
method: GET |
JR |
122 |
user: admin |
|
123 |
password: "{{ tower_admin_password }}" |
|
124 |
body: "" |
|
125 |
body_format: json |
|
126 |
validate_certs: False |
|
127 |
force_basic_auth: yes |
|
128 |
status_code: |
|
129 |
- 200 |
|
130 |
register: devops_credentials_id |
|
131 |
|
|
132 |
- name: Create Tower credentials |
|
133 |
uri: |
409b6f
|
134 |
url: "https://tower.{{zone_internal_dns}}/api/v2/credentials/" |
1e2288
|
135 |
method: POST |
JR |
136 |
user: admin |
|
137 |
password: "{{ tower_admin_password }}" |
|
138 |
body: "{{ lookup('template','tower-creds.json.j2') }}" |
|
139 |
body_format: json |
|
140 |
validate_certs: False |
|
141 |
force_basic_auth: yes |
|
142 |
status_code: |
|
143 |
- 200 |
|
144 |
- 201 |
|
145 |
- 400 |
|
146 |
register: response |
|
147 |
changed_when: response.status == 201 |
|
148 |
|
|
149 |
- name: Create Git projects |
|
150 |
uri: |
409b6f
|
151 |
url: "https://tower.{{zone_internal_dns}}/api/v2/projects/" |
1e2288
|
152 |
method: POST |
JR |
153 |
user: admin |
|
154 |
password: "{{ tower_admin_password }}" |
|
155 |
body: |
|
156 |
name: "{{ item }} repository" |
|
157 |
description: "{{ item }} project" |
|
158 |
local_path: "" |
|
159 |
scm_type: "git" |
|
160 |
scm_url: "https://gitlab.{{ dns_domain_name }}/student/{{ item }}.git" |
|
161 |
scm_branch: "master" |
|
162 |
scm_clean: false |
|
163 |
scm_delete_on_update: false |
|
164 |
credential: "{{ gitlab_credentials_id.json.results[0].id }}" |
|
165 |
timeout: 0 |
|
166 |
organization: "{{ organization_id.json.results[0].id }}" |
|
167 |
scm_update_on_launch: true |
|
168 |
scm_update_cache_timeout: 0 |
|
169 |
body_format: json |
|
170 |
validate_certs: False |
|
171 |
force_basic_auth: yes |
|
172 |
status_code: |
|
173 |
- 200 |
|
174 |
- 201 |
|
175 |
- 400 |
|
176 |
register: response |
|
177 |
changed_when: response.status == 201 |
|
178 |
with_items: "{{ repos_name.stdout_lines }}" |
|
179 |
|
|
180 |
- name: Retrieve projects ID |
|
181 |
uri: |
409b6f
|
182 |
url: "https://tower.{{zone_internal_dns}}/api/v2/projects/?name={{ item }}+repository" |
1e2288
|
183 |
method: GET |
JR |
184 |
user: admin |
|
185 |
password: "{{ tower_admin_password }}" |
|
186 |
body: "" |
|
187 |
body_format: json |
|
188 |
validate_certs: False |
|
189 |
force_basic_auth: yes |
|
190 |
status_code: |
|
191 |
- 200 |
|
192 |
with_items: "{{ repos_name.stdout_lines }}" |
|
193 |
register: projects_id |
|
194 |
|
|
195 |
- name: Create job templates |
|
196 |
uri: |
409b6f
|
197 |
url: "https://tower.{{zone_internal_dns}}/api/v2/job_templates/" |
1e2288
|
198 |
method: POST |
JR |
199 |
user: admin |
|
200 |
password: "{{ tower_admin_password }}" |
|
201 |
body: |
|
202 |
name: "Run {{ item.json.results[0].description }}" |
|
203 |
description: Use this job template to run your playbooks |
|
204 |
job_type: run |
|
205 |
inventory: "{{ inventory_id.json.results[0].id }}" |
|
206 |
project: "{{ item.json.results[0].id }}" |
|
207 |
playbook: dummy.yml |
|
208 |
forks: 0 |
|
209 |
verbosity: 0 |
|
210 |
force_handlers: false |
|
211 |
timeout: 0 |
|
212 |
use_fact_cache: false |
|
213 |
ask_diff_mode_on_launch: false |
|
214 |
ask_variables_on_launch: false |
|
215 |
ask_limit_on_launch: false |
|
216 |
ask_tags_on_launch: false |
|
217 |
ask_skip_tags_on_launch: false |
|
218 |
ask_job_type_on_launch: false |
|
219 |
ask_verbosity_on_launch: false |
|
220 |
ask_inventory_on_launch: false |
|
221 |
ask_credential_on_launch: false |
|
222 |
survey_enabled: true |
|
223 |
become_enabled: false |
|
224 |
diff_mode: false |
|
225 |
allow_simultaneous: false |
|
226 |
custom_virtualenv: |
|
227 |
job_slice_count: 1 |
|
228 |
credential: "{{ devops_credentials_id.json.results[0].id }}" |
|
229 |
vault_credential: |
|
230 |
body_format: json |
|
231 |
validate_certs: False |
|
232 |
force_basic_auth: yes |
|
233 |
status_code: |
|
234 |
- 200 |
|
235 |
- 201 |
|
236 |
- 400 |
|
237 |
register: response |
|
238 |
changed_when: response.status == 201 |
|
239 |
with_items: "{{ projects_id.results }}" |