-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcasc_ctrl_cd_webhook_trigger.yml
69 lines (66 loc) · 3.36 KB
/
casc_ctrl_cd_webhook_trigger.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
---
- hosts: all
connection: local
gather_facts: false
tasks:
- name: "Get the modified files over the dirs from all the received commits"
set_fact:
__env: "{{ awx_webhook_payload.ref.split('/')[2] if awx_webhook_payload.ref.split('/')[1] == 'heads' else awx_webhook_payload.project.default_branch }}"
__casc_gitlab_scm_branch: "{{ awx_webhook_payload.ref.split('/')[2] }}"
__list_of_dirs: "{{ ((awx_webhook_payload.commits | map(attribute='added') | list) +
(awx_webhook_payload.commits | map(attribute='modified') | list) +
(awx_webhook_payload.commits | map(attribute='removed') | list))
| flatten }}"
- set_fact:
regexpression: "/([^/]*)/env/(common|{{ __env }})/controller_(.*).d/"
- name: "Get the Organization and the tags to run the CasC"
set_fact:
org_dirs_dict: "{{ (org_dirs_dict | default({})) | combine({input_var[0]: (((org_dirs_dict[input_var[0]] | default([])) + [input_var[1]] + ( ['projects','schedules'] if awx_webhook_payload.ref.split('/')[1] == 'tags' else [''] ) ) | unique | reject('match', '^$') ) }) }}"
#org_dirs_dict: "{{ (org_dirs_dict | default({})) | combine({input_var[0]: (((org_dirs_dict[input_var[0]] | default([])) + ( ['all'] if awx_webhook_payload.ref.split('/')[1] == 'tags' else ['all'])) | unique | reject('match', '^$'))})}}"
vars:
input_var: "{{ input_var_item | regex_search(regexpression, '\\1', '\\3') }}"
loop: "{{ __list_of_dirs }}"
loop_control:
loop_var: input_var_item
when: input_var | type_debug is match('list')
- name: Configure Controller Job Launch | Launch launch_jobs Drop Diff (Delete)
include_role:
name: infra.controller_configuration.job_launch
vars:
controller_launch_jobs:
- name: "{{ __drop_diff_org_tags_item.key }} JT_CasC_Ctrl_Drop_Diff"
scm_branch: "{{ __casc_gitlab_scm_branch }}"
extra_vars:
orgs: "{{ __drop_diff_org_tags_item.key }}"
dir_orgs_vars: 'orgs_vars'
ansible_python_interpreter: "/usr/bin/python3"
env: "{{ __env }}"
casc_gitlab_scm_branch: "{{ __casc_gitlab_scm_branch }}"
tags: "{{ __drop_diff_org_tags_item.value }}"
wait: true
verbosity: 0
with_dict: "{{ org_dirs_dict }}"
loop_control:
loop_var: __drop_diff_org_tags_item
when: org_dirs_dict is defined
- name: Configure Controller Job Launch | Launch launch_jobs creation
include_role:
name: infra.controller_configuration.job_launch
vars:
controller_launch_jobs:
- name: "{{ __config_controller_org_tags_item.key }} JT_CasC_Ctrl_Config"
scm_branch: "{{ __casc_gitlab_scm_branch }}"
extra_vars:
orgs: "{{ __config_controller_org_tags_item.key }}"
dir_orgs_vars: 'orgs_vars'
ansible_python_interpreter: "/usr/bin/python3"
env: "{{ __env }}"
casc_gitlab_scm_branch: "{{ __casc_gitlab_scm_branch }}"
tags: "{{ __config_controller_org_tags_item.value }}"
wait: true
verbosity: 0
with_dict: "{{ org_dirs_dict }}"
loop_control:
loop_var: __config_controller_org_tags_item
when: org_dirs_dict is defined
...