Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

host_vars ignored by Jinja2 template #611

Open
dar72 opened this issue Mar 2, 2023 · 2 comments
Open

host_vars ignored by Jinja2 template #611

dar72 opened this issue Mar 2, 2023 · 2 comments
Assignees

Comments

@dar72
Copy link

dar72 commented Mar 2, 2023

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 
@chidanandpujar
Copy link
Collaborator

Hi @dar72
Thanks,
I am trying to replicate this issue on local test setup .

Thanks

@dineshbaburam91
Copy link
Collaborator

@dar72 Could you please share the jinja2 template file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants