I have my inventory.ini
, playbook called checklist.yml
, and ansible.cfg
.
I use VS code and I have the extension "remote - ssh" to connect to the network script server. Then I git pull from the script server and run ansible-playbook checklist.yml
.
However, I only get errors. Not sure what I am doing wrong. I have been reading the documentation but it goes on about different modules and becomes confusing.
inventory.ini
[junos_devices]
LAB-AAOC-MPLS-PE02
checklist.yml
---
- name: Get Device Information
hosts: all
connection: local
gather_facts: no
roles:
- juniper.junos
#region Variables
vars_prompt:
- name: username
prompt: Junos Username
private: no
- name: password
prompt: Junos Password
private: yes
vars:
credentials:
username: "{{ username }}"
password: "{{ password }}"
#endregion
#region task
tasks:
- name: test task
juniper_junos_command:
provider: "{{ credentials }}"
commands:
- "show access-list"
register: output
- name: print outputs
debug:
var: output
# with_items: "{{response.results}}"
#endregion
ansible.cfg
[defaults]
# some basic default values...
inventory = ~/Ansible---Network-Devices-Checklist/inventory.ini
The output error I get is the following. I assume something is wrong with my inventory file but I have been stuck for quite a while
PLAY [Get Device Information] **************************************************************************************************************************************************************
TASK [test task] ***************************************************************************************************************************************************************************
[WARNING]: Both option user and its alias username are set.
fatal: [LAB-AAOC-MPLS-PE02]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"}, "changed": false, "msg": "Unable to make a PyEZ connection: ConnectError(host: LAB-AAOC-MPLS-PE02, msg: )"}
PLAY RECAP *********************************************************************************************************************************************************************************
LAB-AAOC-MPLS-PE02 : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
I have tried analyzing example code and reading documentation.