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

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

Open
LukeDRussell opened this issue Feb 6, 2019 · 2 comments
Assignees

Comments

@LukeDRussell
Copy link

LukeDRussell commented Feb 6, 2019

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.

@trishnaguha
Copy link
Member

@LukeDRussell I am unable to reproduce the issue. network-engine sets the key to null if there is no match which caused the following test failure which is expected, it didn't hang for me.
I think this might be related to connection plugin, copying @Qalthos here.

TASK [15.5.1.txt - test `show version` parser] ***************************************************************************************************
fatal: [localhost]: FAILED! => {
    "assertion": "system.restart_time == '09:58:28'", 
    "changed": false, 
    "evaluated_to": false, 
    "msg": "Assertion failed"
}
	to retry, use: --limit @/home/tguha/workspace/cisco_ios/tests/test_parser_templates.retry

PLAY RECAP ***************************************************************************************************************************************
localhost                  : ok=22   changed=0    unreachable=0    failed=1 

@LukeDRussell
Copy link
Author

Ack, I'll have to find another way to reproduce this.

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

No branches or pull requests

2 participants