Configure Clock timezone and summertime on Cisco IOS with very easy Ansible playbook.
You can find a list of Clock Commands on Cisco IOS XR Software here
- Create an empty YAML file and name it config_clock.yaml with below codes:
# @author [Hawar Koyi] # @email [hawar.koy@gmail.com] # @create date 2021-10-02 16:29 # @desc [Automation - Conffigure Clock Timezone and Summertime on Cisco IOS] #Start of codes --- - name: Configure Clock Timezone and Summertime on Cisco IOS hosts: Cisco connection: network_cli gather_facts: false tasks: #Set timezone CET (Europe/Oslo) and summertime - name: Timezome and summertime ios_config: lines: #Configuration commands - clock timezone CET 1 0 - clock summer-time CEST recurring last Sun Mar 2:00 last Sun Oct 3:00 #Saving the configurations on start-config - name: Save running-config to start-config ios_config: save_when: modified #Get retur output from the show commands - name: "Get clock configurations" register: get_clock_config ios_command: commands: - "show running-config | include clock timezone" - "show running-config | include clock summer-time" #Output final results on the device run and start-config. - name: Show finally configurations on device debug: var: get_clock_config.stdout #End of codes
- Create an empty text file and name it hosts with devices IP-addresses and the defaults values.
As you can see I only added one device, otherwise you can add more than one device, if they have the same username and password.[Cisco] 192.168.10.122 192.168.xx.xx [Cisco:vars] ansible_connection=network_cli ansible_network_os=ios ansible_user=cisco ansible_password=cisco ansible_become=yes ansible_become_method=enable ansible_become_password=cisco
- Finally run this command:
ansible-playbook -i hosts config_clock.yaml
Results looks like the image below.
Like it if you want too Linkedin