forked from PaloAltoNetworks/ansible-playbooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
show_changes.yml
51 lines (46 loc) · 1.58 KB
/
show_changes.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
---
# show_changes.yml - Checks for uncommitted changes and commits if necessary.
#
# Description
# ===========
#
# This issues the 'show config list changes' command to display the modified config elements in the candidate config
# using 'panos_op', and issues the commit command if there are uncommitted changes.
#
# 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 show_changes.yml
- hosts: '{{ target | default("firewall") }}'
connection: local
gather_facts: false
vars:
device:
ip_address: '{{ ip_address }}'
username: '{{ username | default(omit) }}'
password: '{{ password | default(omit) }}'
api_key: '{{ api_key | default(omit) }}'
tasks:
- name: Check for pending changes
paloaltonetworks.panos.panos_op:
provider: '{{ device }}'
cmd: 'show config list changes'
register: changes
- name: Display changes
ansible.builtin.debug:
msg: '{{ changes.stdout | from_json }}'
- name: Commit changes if needed
paloaltonetworks.panos.panos_commit:
provider: '{{ device }}'
when: >
(changes.stdout | from_json).response.result.journal is defined and
(changes.stdout | from_json).response.result.journal.entry | length > 0