From b3f9331a1291a54d35d8e0f3e58d1341d08cc1b9 Mon Sep 17 00:00:00 2001 From: Vlad Raducanu Date: Wed, 21 Apr 2021 12:19:13 +0100 Subject: [PATCH] Fixed issue with IOS SSH connection. The default Ansible setting was to us PK auth so I changed it back to default and added an environment variable for the @home_linux@ collection to keep it working --- home_linux/home_inventory.yml | 5 +++-- .../{first_playbook.yml => device_audit.yml} | 0 ios_devices/inventory.yml | 10 ++++++---- ios_devices/test.yml | 14 -------------- ios_devices/test_show_version.yml | 19 +++++++++++++++++++ 5 files changed, 28 insertions(+), 20 deletions(-) rename ios_devices/{first_playbook.yml => device_audit.yml} (100%) delete mode 100644 ios_devices/test.yml create mode 100644 ios_devices/test_show_version.yml diff --git a/home_linux/home_inventory.yml b/home_linux/home_inventory.yml index 2dfb5e2..21376f8 100644 --- a/home_linux/home_inventory.yml +++ b/home_linux/home_inventory.yml @@ -1,7 +1,8 @@ -all: +home: hosts: 192.168.1.50: 192.168.1.51: 192.168.1.52: 192.168.1.53: - \ No newline at end of file + vars: + ansible_ssh_private_key_file = /home/vraducanu/.ssh/id_rsa \ No newline at end of file diff --git a/ios_devices/first_playbook.yml b/ios_devices/device_audit.yml similarity index 100% rename from ios_devices/first_playbook.yml rename to ios_devices/device_audit.yml diff --git a/ios_devices/inventory.yml b/ios_devices/inventory.yml index 08c05c1..164b240 100644 --- a/ios_devices/inventory.yml +++ b/ios_devices/inventory.yml @@ -1,5 +1,7 @@ -[baguleykit] -172.16.1.254 +baguleykit: + hosts: + 172.16.1.254: -[homekit] -192.168.1.60 \ No newline at end of file +homekit: + hosts: + 192.168.1.60: \ No newline at end of file diff --git a/ios_devices/test.yml b/ios_devices/test.yml deleted file mode 100644 index b72d41a..0000000 --- a/ios_devices/test.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- - -- name: Test playbook - reads and prints device info - hosts: homekit - gather_facts: false - connection: network_cli - roles: - - common - - tasks: - - - name: Run one command on device - ios_command: - commands: show version \ No newline at end of file diff --git a/ios_devices/test_show_version.yml b/ios_devices/test_show_version.yml new file mode 100644 index 0000000..d8f82dd --- /dev/null +++ b/ios_devices/test_show_version.yml @@ -0,0 +1,19 @@ +--- + +- name: Test playbook - reads and prints device info + hosts: homekit + gather_facts: false + connection: network_cli + roles: + - common + + tasks: + + - name: Run "show version" command on devices + ios_command: + commands: show version + register: output + + - name: Print the output of "show version" + debug: + var: output.stdout_lines \ No newline at end of file