Skip to content

Instantly share code, notes, and snippets.

@mbruzek
Last active June 2, 2021 22:09
Show Gist options
  • Save mbruzek/862922f1193b2fac6f2d9d964a60952e to your computer and use it in GitHub Desktop.
Save mbruzek/862922f1193b2fac6f2d9d964a60952e to your computer and use it in GitHub Desktop.
hosts.ini
[ios]
sg250a ansible_host=192.168.1.254
[ios:vars]
ansible_become=yes
ansible_become_method=enable
ansible_connection=ansible.netcommon.network_cli
ansible_network_os=cisco.ios.ios
- - - - -
- name: Set the configuration on a Cisco switch
become: yes
hosts: ios
gather_facts: no
vars:
backup_path: backup/files/here
tasks:
- name: Set the startup configuration
cisco.ios.ios_config:
backup: yes
backup_options:
filename: 2021_06_02_cisco_backup.txt
dir_path: "{{ backup_path }}"
src: cisco_configuration.txt
save_when: always
- - - - -
cisco_configuration.txt
hostname newhostname
- - - - - - - - -
ansible-playbook -vvv -i hosts.ini -u automater -k -K set_startup_config.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment