- name: "Demonstrate connecting to switches" #hosts: switches hosts: all gather_facts: no tasks: ### # Collect data # - name: Gather facts (ios) cisco.ios.ios_facts: gather_subset: all when: ansible_network_os == 'cisco.ios.ios' - name: ansible.builtin.file: path: /configs/{{building_name}} state: directory - name: backup (ios) cisco.ios.ios_config: backup: yes backup_options: dir_path: /configs/{{building_name}} filename: "{{ inventory_hostname }}.cfg" when: ansible_network_os == 'cisco.ios.ios' - name: show running config cisco.nxos.nxos_command: commands: show running-config vdc-all register: show_run when: ansible_network_os == 'cisco.nxos.nxos' - name: output copy: content: "{{show_run.stdout[0] | regex_replace('Time: .*',' ')}}" dest: /configs/{{building_name}}/{{inventory_hostname}}.cfg when: ansible_network_os == 'cisco.nxos.nxos' - name: Display some facts debug: msg: "The hostname is {{ ansible_facts }}" tags: never