ansible-junos-stdlib
ansible-junos-stdlib copied to clipboard
host_vars ignored by Jinja2 template
Issue Type
- Bug Report
Module Name
juniper_junos_config
juniper.device collection and Python libraries version
ansible 2.10.8
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/support/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0]
Jinja2==3.0.3
juniper.device 1.0.2
OS / Environment
QFX 5100 JUNOS 20.1R1.11
Summary
I'm trying to put initial configs onto devices via the console port. When trying to use Jinja2 to create a base config including variables, the host_vars files seem to be ignored. No variables placed in host_vars are available to the template.
Steps to reproduce
---
- name: Load Initial Configuration
hosts: qfx1
connection: local
gather_facts: no
vars_prompt:
- name: "DEVICE_PASSWORD"
prompt: "Device password"
private: yes
tasks:
- name: Load initial configuration and commit
juniper.device.config:
passwd: "{{ DEVICE_PASSWORD }}"
user: "root"
mode: "serial"
load: "overwrite"
template: "configs/qfx_base.conf"
format: "text"
vars:
myvar: "test"
register: response
- name: Print the response
debug:
var: response
Expected results
Actual results
ansible-playbook -i hosts config_push_serial.yml
Device password:
PLAY [Load Initial Configuration] ************************************************************************************************************************************************************
TASK [Load initial configuration and commit] *************************************************************************************************************************************************
fatal: [qfx1]: FAILED! => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false
}
MSG:
Failure loading the configuraton: ConfigLoadError(severity: error, bad_element: ;, message: error: invalid value
error: error recovery ignores input until this point
error: error recovery ignores input until this point
error: error recovery ignores input until this point
error: error recovery ignores input until this point
error: error recovery ignores input until this point
error: error recovery ignores input until this point
error: error recovery ignores input until this point
error: error recovery ignores input until this point
error: error recovery ignores input until this point
warning: mgd: statement has no contents; ignored
error: invalid ip address or hostname: /32
error: invalid value
error: error recovery ignores input until this point
error: error recovery ignores input until this point
error: error recovery ignores input until this point
warning: mgd: statement has no contents; ignored)
PLAY RECAP ***********************************************************************************************************************************************************************************
qfx1 : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0