question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Set commands now failing on junos_install_config

See original GitHub issue

In previous versions of junos_install_config this style of playbook would succeed. This playbook running against an vsrx in eve-ng.

---
- name: Juniper New Out of Box
  hosts: srx
  gather_facts: false
  connection: local

  tasks:
    
  - junos_install_config:
      file: "~/local_ansible/config.set"
      mode: telnet
      user: root
      port: 32781
      host: 10.0.254.1

This now fails under an updated version with the following. The full traceback is:

Traceback (most recent call last):
  File "/tmp/ansible_8olY8M/ansible_module_junos_install_config.py", line 1127, in <module>
    main()
  File "/tmp/ansible_8olY8M/ansible_module_junos_install_config.py", line 750, in main
    config_format_choices = juniper_junos_common.CONFIG_FORMAT_CHOICES
AttributeError: 'NoneType' object has no attribute 'CONFIG_FORMAT_CHOICES'

fatal: [vsrx]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_8olY8M/ansible_module_junos_install_config.py\", line 1127, in <module>\n    main()\n  File \"/tmp/ansible_8olY8M/ansible_module_junos_install_config.py\", line 750, in main\n    config_format_choices = juniper_junos_common.CONFIG_FORMAT_CHOICES\nAttributeError: 'NoneType' object has no attribute 'CONFIG_FORMAT_CHOICES'\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE", 
    "rc": 0
}

Reading the juniper_junos_config.py file shows updates in what arguments are expected. I have tried interpreting this and changed the playbook as:

  - junos_install_config:
      load: "override"
      src: "config.set"
      format: "set"
      mode: 'telnet'
      user: root
      port: 32781
      host: 10.0.254.1

Yet the same error persists. It would be nice to get some direction this. Thanks team!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
stacywsmithcommented, Nov 29, 2017

@crosson

I’m sorry I didn’t notice this earlier. This appears to be an installation issue with the new modules. The new modules use a library of shared code which doesn’t appear to be installed on your machine.

Unfortunately, I believe this is likely an issue with the ansible-galaxy command. It doesn’t handle upgrades cleanly. Please uninstall the modules, and then install cleanly with:

sudo ansible-galaxy remove Juniper.junos
sudo ansible-galaxy install git+https://github.com/Juniper/ansible-junos-stdlib.git,,Juniper.junos

Once this is done, you can confirm that the shared library of code exists by checking for the following file:

<roles_dir>/Juniper.junos/module_utils/juniper_junos_common.py

Note: <roles_dir> is usually /etc/ansible/roles could be different on your machine.

I successfully used the following playbook successfully when trying to replicate your issue:

---
- name: 'Replicate issue #308'
  hosts: junos-all
  connection: local
  gather_facts: no
  roles:
    - Juniper.junos

  tasks:
    - name: 'Replicate issue #308'
      junos_install_config:
        file: "./config.set"
        host: "{{ jaccess.console_ts }}"
        port: "{{ jaccess.console_port }}"
        mode: telnet
        user: root
      register: response
    - name: 'Print result'
      debug:
        var: response

If you wish to update to the new module name and argument syntax, you can also use this equivalent playbook:

---
- name: 'Replicate issue #308'
  hosts: junos-all
  connection: local
  gather_facts: no
  roles:
    - Juniper.junos

  tasks:
    - name: 'Replicate issue #308'
      juniper_junos_config:
        load: 'set'
        src: './config.set'
        host: '{{ jaccess.console_ts }}'
        port: '{{ jaccess.console_port }}'
        mode: telnet
        user: root
      register: response
    - name: 'Print result'
      debug:
        var: response

If you still have issues after cleanly installing the modules, please provide the version of Ansible you are using, and the version of PyEZ you are using.

0reactions
achhabr1commented, Mar 14, 2018

I am facing the same issue. I have opened up a new bug on this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Loading Configuration Files | Junos OS - Juniper Networks
To load a configuration that contains set configuration mode commands, specify the set option. This option executes the configuration instructions line by line ......
Read more >
Problem with Juniper Installation on local machine
These commands worked fine. sudo locale-gen en_US en_US.UTF-8 sudo dpkg-reconfigure locales sudo dpkg --configure -a sudo apt-get update -y ...
Read more >
Run arbitrary commands on an Juniper JUNOS device
Sends an arbitrary set of commands to an JUNOS node and returns the results read from the device. This module includes an argument...
Read more >
Juniper backup is not working, it is failing with command login ...
Run the remoteloginconsole.exe which is what Config Management is using, to test. Also what is set as the remote console in the Config....
Read more >
DAY ONE: AUTOMATING JUNOS® WITH ANSIBLE - NLogic
Create playbooks to execute commands on Junos devices. ▫ Create playbooks to update Junos device configuration, in either “set” or “config” format.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found