Skip to content

Failing to construct json_object due to missing / null values should fail explicitly #218

Description

@LukeDRussell

ISSUE TYPE

  • Bug Report

ANSIBLE VERSION

ansible --version
ansible 2.7.6
  config file = /home/4032956/repos/network-automation/ansible.cfg
  configured module search path = ['/home/4032956/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/4032956/.pyenv/versions/3.7.1/envs/network-automation/lib/python3.7/site-packages/ansible
  executable location = /home/4032956/.pyenv/versions/network-automation/bin/ansible
  python version = 3.7.1 (default, Dec  4 2018, 14:17:28) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]

$ ansible-galaxy list -p roles/ | grep ansible-network
- ansible-network.cisco_ios, v2.7.0
- ansible-network.juniper_junos, v2.7.2
- ansible-network.network-engine, v2.7.2
- ansible-network.cisco_nxos, v2.7.1
- ansible-network.config_manager, v2.6.2
- ansible-network.network-engine, v2.7.1

Network OS

Not relevant

SUMMARY

When you construct a json_template that references a non-existing (or perhaps null) parsed variable, ansible hangs. It should fail explicitly with a useful message.

STEPS TO REPRODUCE

From inside ansible-network.cisco_ios

  1. Remove this line
  2. ansible-playbook tests/test_parser_templates.yaml -i tests/inventory

EXPECTED RESULTS

When network engine tries to construct the key restart_time (link) which is null / doesn't exist because the previous regex didn't match anything, it should produce a meaningful error.

ACTUAL RESULTS

TASK [lukedrussell.cisco_ios : run command and parse output] ****************************************************************
task path: /home/4032956/repos/network-automation/roles/lukedrussell.cisco_ios/includes/run_cli.yaml:6
<snip> attempting to start connection
<snip> using connection plugin network_cli
<snip> found existing local domain socket, using it!
<snip> updating play_context for connection
<snip>
<snip> local domain socket path is /home/4032956/.ansible/pc/c96ac4390e
Traceback (most recent call last):
  File "/home/4032956/.pyenv/versions/3.7.1/lib/python3.7/multiprocessing/queues.py", line 236, in _feed
    obj = _ForkingPickler.dumps(obj)
  File "/home/4032956/.pyenv/versions/3.7.1/lib/python3.7/multiprocessing/reduction.py", line 51, in dumps
    cls(buf, protocol).dump(obj)
TypeError: can't pickle StrictUndefined objects

The playbook hangs at this point for all hosts, and must Ctrl+C to break it.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions