-
Notifications
You must be signed in to change notification settings - Fork 53
/
fw_config_lock.yml
61 lines (54 loc) · 1.9 KB
/
fw_config_lock.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
---
# fw_config_lock.yml - Handle firewall config locking.
#
# Description
# ===========
#
# Quick example of how to handle PAN-OS automatic config locks. This uses the Ansible 'retries' keyword to wait until
# there are no active config locks before continuing.
#
# This playbook requires connection details for the device to be specified in the variables 'ip_address', 'username',
# and 'password'. These may be defined as host variables (see `host_vars/firewall.yml` for an example) or
# extra vars.
#
# Modules Used
# ============
#
# panos_op - https://paloaltonetworks.github.io/pan-os-ansible/modules/panos_op.html
#
# Usage
# =====
#
# $ ansible-playbook -i inventory fw_config_lock.yml
- hosts: '{{ target | default("firewall") }}'
connection: local
vars:
device:
ip_address: '{{ ip_address }}'
username: '{{ username | default(omit) }}'
password: '{{ password | default(omit) }}'
api_key: '{{ api_key | default(omit) }}'
vsys: vsys1
tasks:
- name: Wait for config lock
paloaltonetworks.panos.panos_op:
provider: '{{ device }}'
cmd: '<show><config-locks><vsys>{{ vsys }}</vsys></config-locks></show>'
cmd_is_xml: true
retries: 30
delay: 10
register: result
until: result.stdout_xml == '<response status="success"><result><config-locks /></result></response>'
- name: Acquire config lock
paloaltonetworks.panos.panos_op:
provider: '{{ device }}'
cmd: '<request><config-lock><add><comment>Ansible config lock</comment></add></config-lock></request>'
cmd_is_xml: true
- name: Change configuration here.
ansible.builtin.debug:
msg: 'Configuration would be changed here'
- name: Release config lock
paloaltonetworks.panos.panos_op:
provider: '{{ device }}'
cmd: '<request><config-lock><remove></remove></config-lock></request>'
cmd_is_xml: true