Hi,
I'm trying to get a playbook to connect to a juniper switch and do a 'show version'
I'm totally new to this and wanted to do this without the use of yaml files for username and password.
This is the code for the playbook:
---
- hosts: switches
gather_facts: no
connection: local
tasks:
- name: DEFINE PROVIDER
set_fact:
hostinfo:
host: "{{ inventory_hostname }}"
password: **************
username: root
- debug: var=hostvars[inventory_hostname]
- name: show command
junos_command:
provider: "{{ hostinfo }}"
commands:
- show version
register: version
The host file contains only 1 ip address to the switch.
I get this error for task "show command"
fatal: [172.18.10.25]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"commands": ["show version"], "host": "172.18.10.25", "interval": 1, "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "port": 22, "provider": null, "retries": 10, "username": "root", "waitfor": null}, "module_name": "junos_command"}, "msg": "failed to connecto to 172.18.10.25:22 - "}
Is there something wrong with my code? I also tried specifying the username/password inside the task, didnt work either.
I can SSH to the switch from my server if not using ansible.
Thanks!
Oscar Bengtsson