Files
product-demos/playbooks/network/configlet_ntp.yml
2022-02-04 09:21:45 -05:00

38 lines
694 B
YAML

---
- hosts: ios
gather_facts: no
vars:
ntp_servers:
- ntp server 10.10.10.13
- ntp server 10.10.10.14
tasks:
- name: "GET CONFIG"
ios_command:
commands:
- "show running-config full | include ntp server"
register: get_config
- debug: var=get_config.stdout_lines
- name: RUN 'Set NTP'
with_items: "{{ ntp_servers }}"
ios_config:
lines:
- "{{ item }}"
register: set_ntp
- name: RUN 'Remove NTP'
when: "(get_config.stdout_lines[0][0] != '') and (item not in ntp_servers)"
with_items: "{{ get_config.stdout_lines[0] }}"
register: remove_ntp
ios_config:
lines:
- "no {{ item }}"