@create date 2020-06-02 17:12:00
connection: network_cli
gather_facts: false
local_action: command date +%Y-%b-%d
register: date
local_action: command date +%H:%M
register: time
ios_config:
backup: yes
backup_options:
#ansible_host = getting device IP, ansible_net_hostname = getting device hostname
filename: "{{ ansible_net_hostname }}_{{ ansible_host }}.cfg"
#Please change /home/hawar/Desktop to your direcotry
#Every time create a new directory under named date and time
dir_path: /tmp/backups/{{ date.stdout }}_at_{{ time.stdout }}
ios_config:
parents: "interface Ethernet0/1"
lines:
- description Uplink
- ip address 192.168.0.1 255.255.255.0
debug: msg="All tasks completed on {{ date.stdout }} at {{ time.stdout }}."