Problems updating Junos configuration with new modules/versions

Hi,

I had been using the Juniper.junos modules from Ansible Galaxy successfully for a while now, but had been asked to update my python environment to corporate standards through Conda, which included newer versions of most modules. Ever since the update, I have been unable to use either the native junos_config module, nor the old junos_install_config. The junos_install_config now complains about the following, using that the exact same configuration files as before:

/private/etc/ansible/roles/Juniper.junos/library/junos_install_config:198: SyntaxWarning: import * only allowed at module level
def _load_via_netconf(module):

{“msg”: “Error: Module unable to decode valid JSON on stdin. Unable to figure out what parameters were passed”, “failed”: true}

Because of that error, I decided that I might as well update the playbooks to use the new native modules instead. However, when I try to push the configuration, he’re the output I get:

TASK [Pushing config … please wait] **********************************************************************************************************************************************************************************************************************
fatal: [switch]: FAILED! => {“changed”: false, “failed”: true, “msg”: “one of candidate or rollback must be specified”}

I looked a bit at the code to find what was candidate variable and as I expected, it seems to point to what src is. I’ve also validated through debug that the path is valid, so I really have no idea where to look afterwards.

Here’s the playbook:

  • name: Apply configuration
    hosts: all
    connection: local
    gather_facts: no
    vars:
    junos_creds:
    username: “{{ ansible_ssh_user }}”
    host: “{{ ansible_ssh_host }}”
    port: “{{ netconf_port }}”
    tasks:
  • name: Pushing config … please wait
    when: config_changed is defined
    junos_config: >
    provider: “{{ junos_creds }}”
    src: {{ junos_conf }}
    update: override
    comment: Test pushed by ansible

Here’s the detailed debug:

29707 1498596207.19598: ANSIBALLZ: Using lock for junos_config
29707 1498596207.19683: ANSIBALLZ: Acquiring lock
29707 1498596207.19731: ANSIBALLZ: Lock acquired: 4405365776
29707 1498596207.19772: ANSIBALLZ: Creating module
29707 1498596207.33891: ANSIBALLZ: Writing module
29707 1498596207.33985: ANSIBALLZ: Renaming module
29707 1498596207.34068: ANSIBALLZ: Done creating module
29707 1498596207.34157: _low_level_execute_command(): starting
29707 1498596207.34187: _low_level_execute_command(): executing: /bin/sh -c ‘echo ~ && sleep 0’
29707 1498596207.34226: in local.exec_command()
29707 1498596207.34252: opening command with Popen()
29707 1498596207.34696: done running command with Popen()
29707 1498596207.34801: getting output with communicate()
29707 1498596207.35497: done communicating
29707 1498596207.35543: done with local.exec_command()
29707 1498596207.35586: _low_level_execute_command() done: rc=0, stdout=/Users/user
, stderr=
29707 1498596207.35624: _low_level_execute_command(): starting
29707 1498596207.35659: _low_level_execute_command(): executing: /bin/sh -c ‘( umask 77 && mkdir -p “echo /Users/user/.ansible/tmp/ansible-tmp-1498596207.34-16034423383708” && echo ansible-tmp-1498596207.34-16034423383708=“echo /Users/user/.ansible/tmp/ansible-tmp-1498596207.34-16034423383708” ) && sleep 0’
29707 1498596207.35716: in local.exec_command()
29707 1498596207.35778: opening command with Popen()
29707 1498596207.36368: done running command with Popen()
29707 1498596207.36466: getting output with communicate()
29707 1498596207.38038: done communicating
29707 1498596207.38113: done with local.exec_command()
29707 1498596207.38160: _low_level_execute_command() done: rc=0, stdout=ansible-tmp-1498596207.34-16034423383708=/Users/user/.ansible/tmp/ansible-tmp-1498596207.34-16034423383708
, stderr=
29707 1498596207.38197: transferring module to remote /Users/user/.ansible/tmp/ansible-tmp-1498596207.34-16034423383708/junos_config.py
29707 1498596207.38477: done transferring module to remote
29707 1498596207.38530: _low_level_execute_command(): starting
29707 1498596207.38557: _low_level_execute_command(): executing: /bin/sh -c ‘chmod u+x /Users/user/.ansible/tmp/ansible-tmp-1498596207.34-16034423383708/ /Users/user/.ansible/tmp/ansible-tmp-1498596207.34-16034423383708/junos_config.py && sleep 0’
29707 1498596207.38585: in local.exec_command()
29707 1498596207.38614: opening command with Popen()
29707 1498596207.39066: done running command with Popen()
29707 1498596207.39149: getting output with communicate()
29707 1498596207.39983: done communicating
29707 1498596207.40043: done with local.exec_command()
29707 1498596207.40103: _low_level_execute_command() done: rc=0, stdout=, stderr=
29707 1498596207.40145: _low_level_execute_command(): starting
29707 1498596207.40182: _low_level_execute_command(): executing: /bin/sh -c ‘/usr/bin/python /Users/user/.ansible/tmp/ansible-tmp-1498596207.34-16034423383708/junos_config.py; rm -rf “/Users/user/.ansible/tmp/ansible-tmp-1498596207.34-16034423383708/” > /dev/null 2>&1 && sleep 0’
29707 1498596207.40217: in local.exec_command()
29707 1498596207.40243: opening command with Popen()
29707 1498596207.40679: done running command with Popen()
29707 1498596207.40873: getting output with communicate()
29707 1498596208.35579: done communicating
29707 1498596208.35621: done with local.exec_command()
29707 1498596208.35658: _low_level_execute_command() done: rc=0, stdout=
{“msg”: “one of candidate or rollback must be specified”, “failed”: true, “invocation”: {“module_args”: {“comment”: “configured by junos_config”, “src”: null, “ssh_keyfile”: null, “rollback”: null, “timeout”: 10, “confirm”: 0, “lines”: null, “update”: “merge”, “replace”: null, “username”: null, “host”: null, “zeroize”: false, “src_format”: null, “provider”: null, “password”: null, “backup”: false, “port”: null, “transport”: null}}}
, stderr=
29707 1498596208.35703: done with _execute_module (junos_config, {‘_ansible_version’: ‘2.3.1.0’, ‘_ansible_selinux_special_fs’: [u’fuse’, u’nfs’, u’vboxsf’, u’ramfs’, u’9p’], ‘_ansible_no_log’: False, ‘_ansible_module_name’: u’junos_config’, ‘_ansible_verbosity’: 0, ‘_ansible_syslog_facility’: u’LOG_USER’, ‘_ansible_socket’: u’/Users/user/.ansible/pc/ff4b836769’, ‘_ansible_diff’: False, ‘_ansible_debug’: True, ‘_ansible_check_mode’: False})
29707 1498596208.35751: handler run complete
29707 1498596208.35797: attempt loop complete, returning result
29707 1498596208.35854: _execute() done
29707 1498596208.35886: dumping result to json
29707 1498596208.35932: done dumping result, returning
29707 1498596208.35981: done running TaskExecutor() for switch/TASK: Pushing config … please wait
29707 1498596208.36033: sending task result
29707 1498596208.36108: done sending task result
29707 1498596208.36175: WORKER PROCESS EXITING
29528 1498596208.36396: marking switch as failed
29528 1498596208.36502: marking host switch failed, current state: HOST STATE: block=2, task=1, rescue=0, always=0, run_state=ITERATING_TASKS, fail_state=FAILED_NONE, pending_setup=False, tasks child state? (None), rescue child state? (None), always child state? (None), did rescue? False, did start at task? False
29528 1498596208.36539: ^ failed state is now: HOST STATE: block=2, task=1, rescue=0, always=0, run_state=ITERATING_COMPLETE, fail_state=FAILED_TASKS, pending_setup=False, tasks child state? (None), rescue child state? (None), always child state? (None), did rescue? False, did start at task? False
29528 1498596208.36566: getting the next task for host switch
29528 1498596208.37065: host switch is done iterating, returning
fatal: [switch]: FAILED! => {“changed”: false, “failed”: true, “msg”: “one of candidate or rollback must be specified”}

Thanks!

As per logs, value of src parameter is null

“src”: null

It seems there is an issue in your playbook.

Can you please make below change in the playbook and retry.

junos_config:

provider: “{{ junos_creds }}”
src: “{{ junos_conf }}”
update: override
comment: Test pushed by ansible

Regards,
Ganesh

Indeed, thanks a lot. I had tried a few things with the “src”, but never realized at least the mistake of the “>” after junos_config. All good now at least with the native modules!

Regards,
Sieg