forked from PaloAltoNetworks/ansible-playbooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fw_shutdown.yml
41 lines (38 loc) · 1.31 KB
/
fw_shutdown.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
---
# fw_shutdown.yml - Shuts down a PAN-OS device.
#
# Description
# ===========
#
# This issues the shutdown command using the 'panos_op' module. This uses the Ansible 'ignore_errors' keyword because
# issuing the shutdown command terminates the API connection.
#
# 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_shutdown.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) }}'
tasks:
- name: Issue firewall shutdown command
paloaltonetworks.panos.panos_op:
provider: '{{ device }}'
cmd: '<request><shutdown><system></system></shutdown></request>'
cmd_is_xml: true
register: "cmd_output"
failed_when: '"Command succeeded with no output" not in cmd_output.msg' # Always returns this error when succesful!