-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpeak_script.yml
25 lines (21 loc) · 908 Bytes
/
peak_script.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
---
- hosts: NAT_RTR
gather_facts: no
tasks:
- name: Set ssh port (set defualt 22 port when port is not defined)
set_fact:
ansible_port: "{{ ansible_port | default(22) }}"
- name: Run backup with password (when password is defined)
when: ansible_ssh_pass is defined
block:
- name: Ensure that sshpass is installed
ansible.builtin.shell: whereis sshpass | awk '{print $2}'
run_once: yes
register: sshpass
delegate_to: localhost
- name: Execute PEAK (with password authentication)
# shell with delegate_to: localhost works better that ansible.builtin.raw
ansible.builtin.shell: >-
sshpass -p '{{ ansible_ssh_pass }}' ssh -o StrictHostKeyChecking=no {{ ansible_user }}@{{ inventory_hostname }} -p {{ ansible_port }} /system/script/run PEAK
register: execute
delegate_to: localhost