1

I want to create a playbook to get info and backup my Juniper Ex3400 switch. And i have faced some issue when followed the guide on internet. Here is my playbook and error. It' seems the juniper_junos_command cannot recognize, and all the required module was downloaded.

- name: get_config Ansible module
  hosts: HK01
  roles:
    - Juniper.junos
  connection: local
  gather_facts: no

  tasks:
    - name: Execute the get_config RPC#
      juniper_junos_command:
        commands:
          - "show version"
      register: junos_result

   - name: Print Version
     debug:
       var: junos_result
  FAILED! => {"changed": false, "module_stderr": "/home/leoltchan/.ansible/tmp/ansible-local-29004o9si_nf/ansible-tmp-1616579584.8777056-2906-176519637998237/AnsiballZ_juniper_junos_command.py: 
line 3: _ANSIBALLZ_WRAPPER: command not found\n/home/leoltchan/.ansible/tmp/ansible-local-29004o9si_nf/ansible-tmp-
1616579584.8777056-2906-176519637998237/AnsiballZ_juniper_junos_command.py:
 line 4: syntax error near unexpected token `('\n/home/leoltchan/.ansible/tmp/ansible-local-29004o9si_nf/ansible-tmp-1616579584.8777056-2906-
176519637998237/AnsiballZ_juniper_junos_command.py: line 4: `def _ansiballz_main():'\n", "module_stdout": "", "msg": 
"MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 2}

And here is my host inventory

[HK01]
192.168.8.250

[HK01:vars]
ansible_connection=ansible.netcommon.netconf
ansible_network_os=junipernetworks.junos.junos

ansible 2.10.7 config file = /etc/ansible/ansible.cfg configured module search path = ['/home/leoltchan/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/local/lib/python3.6/site-packages/ansible executable location = /usr/local/bin/ansible python version = 3.6.8 (default, Nov 16 2020, 16:55:22) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]

  • Hi climba15092, welcome to SO. I appreciate that you believe your python version is 2.7.5, but what is `ansible_python_interpreter` set to? It sure does seem like ansible is trying to run that python code using ... something else. It's also weird to see `hosts: HK01` but `connection: local`; are you in fact running `ansible-playbook` on that host? If you turn on fact gathering, does that work successfully? – mdaniel Mar 24 '21 at 16:08
  • In playbook specified `ansible_python_interpreter ` with python 3 and problem solved. It's wired as the default version is python 3.6.8 but i need to force with python3 in playbook. – climba15092 Mar 25 '21 at 06:33

0 Answers0