-
Notifications
You must be signed in to change notification settings - Fork 31
/
configuration_push.yml
285 lines (233 loc) · 7.19 KB
/
configuration_push.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
---
- name: "RUN DATA DRIVEN PALO ALTO TERRAFORM AND ANSIBLE SOLUTION"
hosts: "localhost"
gather_facts: "no"
connection: "local"
vars_files:
- "{{ playbook_dir }}/provider.yml"
vars:
provider_dir: "{{ playbook_dir }}"
output_file: "{{ provider_dir }}/main.tf"
module_dir: "./modules/{{ cloud_provider |lower }}"
temp_key_dir: "{{ lookup('env', 'HOME')}}/paloalto/creds"
temp_key: "{{ temp_key_dir }}/tempkey"
go_path: "./library/panos_init_{{ go_os }}"
tasks:
- name: "SETUP CREDENTIALS & ENV FOR {{ cloud_provider| upper }}"
include_role:
name: "env_setup"
tags:
- 'always'
- 'tf'
- name: "RUN ROLE TO MANAGE VARS AND SCHEMA VALIDATION"
include_role:
name: "var_management"
tags:
- 'always'
- 'tf'
- name: "CREATING {{ cloud_provider }} TEMPLATE"
template:
src: "{{ cloud_provider }}-main.tf.j2"
dest: "{{ output_file }}"
tags:
- 'always'
- 'tf'
- name: "RUN FMT FOR {{ cloud_provider }}"
command: 'terraform fmt {{ output_file }}'
tags:
- 'tf'
- name: "EXECUTE TERRAFORM PLAN"
include_role:
name: "terraform"
tags:
- 'always'
- 'tf'
- name: "GET CREATED FIREWALLS FROM TERRAFORM OUTPUT"
command: 'terraform output -json firewalls_created'
register: firewalls_created
- name: "USE TERRAFORM OUTPUT STORE TEMP VALUES"
set_fact:
firewalls: "{{ firewalls_created.stdout |from_json }}"
# - name: "ANSIBLE IMPORT TFSTATE FOR DICTIONARY CREATION"
# set_fact:
# tfstate: "{{ lookup('file','{{ playbook_dir }}/terraform.tfstate') | from_json }}"
#
# - name: "USE TERRAFORM OUTPUT STORE AWS TUNNEL INFO"
# set_fact:
# simplified_tfstate_info: "{{ tfstate | my_magic_filter }}"
# - debug: var=simplified_tfstate_info
# when: cloud_provider == 'aws'
- name: "ADD HOSTS FROM TF OUTPUT TO FIREWALL GROUP"
add_host:
hostname: "{{ item.key }}"
ansible_host: "{{ item.value }}"
ansible_ssh_private_key: "{{ temp_key }}"
groups: "firewalls"
with_dict: "{{ firewalls['value'] }}"
tags:
- 'tf'
# - name: "USE TERRAFORM OUTPUT STORE AZURE TEMP VALUES"
# set_fact:
# private_address: "{{ private_address.stdout |from_json }}"
# when: cloud_provider == 'azure'
- name: "DEPLOY CONFIGURATIONS AND VALIDATE"
hosts: "firewalls"
connection: "local"
gather_facts: "no"
vars_files:
- "{{ playbook_dir }}/provider.yml"
vars:
temp_key_dir: "{{ lookup('env', 'HOME') }}/paloalto/creds"
temp_key: "{{ temp_key_dir }}/tempkey"
go_path: "./library/panos_init_{{ go_os }}"
tasks:
- name: "WAIT FOR HTTPS ACCESS"
wait_for:
host: "{{ ansible_host }}"
port: 443
timeout: 450
- name: "WAIT FOR MGMT AVAILABILITY"
pause:
seconds: "{{ cloud_unique[cloud_provider | lower]['timeout'] }}"
when: cloud_provider == 'azure'
- name: "CONFIGURE MGMT ACCESS"
include_role:
name: "pa_go"
when: cloud_provider == 'aws'
# - name: "CONFIGURE MGMT ACCESS"
# panos_admpwd:
# ip_address: "{{ ansible_host }}"
# key_filename: "{{ lookup('env', 'HOME') }}/paloalto/creds/tempkey"
# username: "{{ username }}"
# newpassword: "{{ password }}"
# when: cloud_provider == 'aws'
- name: "IMPORT IRON SKILLET WITH ROLE PALOALTONETWORKS AND ADD AGAIN ADMIN"
hosts: "firewalls"
connection: "local"
gather_facts: "no"
vars_files:
- "{{ playbook_dir }}/provider.yml"
roles:
- role: "PaloAltoNetworks.paloaltonetworks"
tasks:
# Import and load config file from URL
- name: Import IRON SKILLET
include_role:
name: 'iron_skillet'
tasks_from: '{{ cloud_provider }}.yml'
# # Create Firewall admin
# # Doesn't commit the candidate config
# - name: Create Firewall Admin
# panos_administrator:
# ip_address: "{{ ansible_host }}"
# username: "{{ username }}"
# password: "{{ password }}"
# admin_username: "{{ username }}"
# admin_password: "{{ password }}"
# state: "present"
# superuser: true
# commit: false
- name: "DEPLOY CONFIGURATIONS AND VALIDATE"
hosts: "firewalls"
connection: "local"
gather_facts: "no"
vars_files:
- "{{ playbook_dir }}/provider.yml"
vars:
temp_key_dir: "{{ lookup('env', 'HOME') }}/paloalto/creds"
temp_key: "{{ temp_key_dir }}/tempkey"
tasks:
- name: "DEPLOY ADMIN TASKS"
include_role:
name: "pa_admin"
tags:
- 'ansible'
# - name: "CONFIGURE MGMT ACCESS"
# panos_admpwd:
# ip_address: "{{ ansible_host }}"
# key_filename: "{{ lookup('env', 'HOME') }}/paloalto/creds/tempkey"
# username: "{{ username }}"
# newpassword: "{{ password }}"
# when: cloud_provider == 'aws'
- name: "DEPLOY ADMIN TASKS"
include_role:
name: "pa_admin"
tags:
- 'ansible'
- name: "PUSH ANY ZONE OR NETWORK CONFIGURATIONS"
include_role:
name: "pa_network"
tags:
- 'ansible'
- name: "PUSH ANY OBJECTS"
include_role:
name: "pa_object"
tags:
- 'ansible'
- name: "PUSH SECURITY RULES"
include_role:
name: "pa_srule"
tags:
- 'ansible'
- name: "PERFORM OPERATIONAL VALIDATION"
include_role:
name: "pa_validate"
- name: "Create Static routes"
include_role:
name: "pa_staticroute"
tags:
- 'ansible'
- name: "ANSIBLE IMPORT TFSTATE FOR DICTIONARY CREATION"
set_fact:
tfstate: "{{ lookup('file','{{ playbook_dir }}/terraform.tfstate') | from_json }}"
- name: "USE TERRAFORM OUTPUT STORE AWS TUNNEL INFO"
set_fact:
simplified_tfstate_info: "{{ tfstate | my_magic_filter }}"
when: cloud_provider == 'aws'
- name: "Create IPSEC Tunnels"
include_role:
name: "pa_ipsec"
vars:
tfstate: "{{ simplified_tfstate_info }}"
tags:
- 'ansible'
when: cloud_provider == 'aws'
- name: "COMMIT THE CHANGES"
panos_commit:
ip_address: '{{ ansible_host }}'
username: '{{ username }}'
password: '{{ password }}'
tags:
- 'ansible'
- name: "Update and License Firewall"
hosts: "firewalls"
connection: "local"
gather_facts: "no"
vars_files:
- "{{ playbook_dir }}/provider.yml"
roles:
- role: "PaloAltoNetworks.paloaltonetworks"
tasks:
# - name: "COMMIT THE CHANGES"
# panos_commit:
# ip_address: '{{ ansible_host }}'
# username: '{{ username }}'
# password: '{{ password }}'
# tags:
# - 'ansible'
- name: "License the Firewall with Auth_Code"
include_role:
name: "pa_lic"
# tags:
# - 'ansible'
- name: "Update PANOS Software"
panos_software:
ip_address: '{{ ansible_host }}'
username: '{{ username }}'
password: '{{ password }}'
version: "{{ item.value.version}}"
restart: "{{ item.value.restart }}"
with_dict: "{{ cm_panos_software }}"
when: "cm_panos_software is defined"
tags:
- 'ansible'