Closed flaviomeyer closed 5 years ago
As you are doing an until
loop, and checking for a specific attribute, you will need to make sure that even when the request fails, and that attribute is not available that the until
doesn't fail as such.
Something like:
until: (result.json|default(dict(s=[1,1,1,1,1]))).s[4] == 0"
If you have further questions please stop by IRC or the mailing list:
@sivel
Thanks it works with "until: (result.json|default(dict(s=[1,1,1,1,1]))).s[4] == 0"
.
Hi @meyerf99 and @sivel
I'am facing the issue @meyerf99 mentioned below. it's verify helpful for me if you can able to help in this case.
Error -:
2019-05-27 20:45:16,635 INFO: TASK [include_tasks] *** task path: /usr/share/opnfv-apex/ansible/playbooks/prepare_overcloud_containers.yml:31 fatal: [192.168.122.244]: FAILED! => {"msg": "The conditional check 'item in (response.json)['repositories']|join(\" \")' failed. The error was: error while evaluating conditional (item in (response.json)['repositories']|join(\" \")): 'dict object' has no attribute 'json'
The error appears to be in '/usr/share/opnfv-apex/ansible/playbooks/prepare_overcloud_containers.yml': line 31, column 7, but may be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
register: response
- include_tasks: patch_containers.yml
^ here
"}
2019-05-27 20:45:16,635 INFO: PLAY RECAP ***** 192.168.122.244 : ok=5 changed=3 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
============================================================================== ### Below is the line were error showing in playbook.
_register: response
- include_tasks: patch_containers.yml
with_items: "{{ patched_docker_services }}"
loop_control:
loop_var: item
when:
- patched_docker_services|length > 0
- item in (response.json)['repositories']|join(" ")
SUMMARY
ISSUE TYPE
COMPONENT NAME
uri
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
Target OS: CentOS 7.6
STEPS TO REPRODUCE
EXPECTED RESULTS
Write value 0 to variable result when output of json parsing is value 0
ACTUAL RESULTS
ansible-playbook -i /Users/fmeyer/.ansible/hosts playbook/aem_test.yml -vvv ansible-playbook 2.7.8 config file = None configured module search path = ['/Users/fmeyer/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/local/Cellar/ansible/2.7.8/libexec/lib/python3.7/site-packages/ansible executable location = /usr/local/bin/ansible-playbook python version = 3.7.2 (default, Feb 12 2019, 08:15:36) [Clang 10.0.0 (clang-1000.11.45.5)] No config file found; using defaults /Users/fmeyer/.ansible/hosts did not meet host_list requirements, check plugin documentation if this is unexpected /Users/fmeyer/.ansible/hosts did not meet script requirements, check plugin documentation if this is unexpected Parsed /Users/fmeyer/.ansible/hosts inventory source with ini plugin
PLAYBOOK: aem_test.yml ** 1 plays in playbook/aem_test.yml
PLAY [aem_test] ***** META: ran handlers
TASK [test : check if AEM Publish successfully installed] *** task path: /Users/fmeyer/git/ansible/test/tasks/main.yml:2 <192.168.25.142> ESTABLISH SSH CONNECTION FOR USER: root <192.168.25.142> SSH: EXEC sshpass -d41 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o User=root -o ConnectTimeout=10 -o ControlPath=/Users/fmeyer/.ansible/cp/3bcfb0a675 192.168.25.142 '/bin/sh -c '"'"'echo ~root && sleep 0'"'"'' <192.168.25.142> (0, b'/root\n', b'') <192.168.25.142> ESTABLISH SSH CONNECTION FOR USER: root <192.168.25.142> SSH: EXEC sshpass -d41 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o User=root -o ConnectTimeout=10 -o ControlPath=/Users/fmeyer/.ansible/cp/3bcfb0a675 192.168.25.142 '/bin/sh -c '"'"'( umask 77 && mkdir -p "
\n<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\"/>\necho /root/.ansible/tmp/ansible-tmp-1553806800.1948202-246961565380639
" && echo ansible-tmp-1553806800.1948202-246961565380639="echo /root/.ansible/tmp/ansible-tmp-1553806800.1948202-246961565380639
" ) && sleep 0'"'"'' <192.168.25.142> (0, b'ansible-tmp-1553806800.1948202-246961565380639=/root/.ansible/tmp/ansible-tmp-1553806800.1948202-246961565380639\n', b'') Using module file /usr/local/Cellar/ansible/2.7.8/libexec/lib/python3.7/site-packages/ansible/modules/net_tools/basics/uri.py <192.168.25.142> PUT /Users/fmeyer/.ansible/tmp/ansible-local-11900zwc6atju/tmpwa7hl9v3 TO /root/.ansible/tmp/ansible-tmp-1553806800.1948202-246961565380639/AnsiballZ_uri.py <192.168.25.142> SSH: EXEC sshpass -d41 sftp -o BatchMode=no -b - -C -o ControlMaster=auto -o ControlPersist=60s -o User=root -o ConnectTimeout=10 -o ControlPath=/Users/fmeyer/.ansible/cp/3bcfb0a675 '[192.168.25.142]' <192.168.25.142> (0, b'sftp> put /Users/fmeyer/.ansible/tmp/ansible-local-11900zwc6atju/tmpwa7hl9v3 /root/.ansible/tmp/ansible-tmp-1553806800.1948202-246961565380639/AnsiballZ_uri.py\n', b'') <192.168.25.142> ESTABLISH SSH CONNECTION FOR USER: root <192.168.25.142> SSH: EXEC sshpass -d41 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o User=root -o ConnectTimeout=10 -o ControlPath=/Users/fmeyer/.ansible/cp/3bcfb0a675 192.168.25.142 '/bin/sh -c '"'"'chmod u+x /root/.ansible/tmp/ansible-tmp-1553806800.1948202-246961565380639/ /root/.ansible/tmp/ansible-tmp-1553806800.1948202-246961565380639/AnsiballZ_uri.py && sleep 0'"'"'' <192.168.25.142> (0, b'', b'') <192.168.25.142> ESTABLISH SSH CONNECTION FOR USER: root <192.168.25.142> SSH: EXEC sshpass -d41 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o User=root -o ConnectTimeout=10 -o ControlPath=/Users/fmeyer/.ansible/cp/3bcfb0a675 -tt 192.168.25.142 '/bin/sh -c '"'"'/usr/bin/python /root/.ansible/tmp/ansible-tmp-1553806800.1948202-246961565380639/AnsiballZ_uri.py && sleep 0'"'"'' <192.168.25.142> (1, b'\r\n{"status": 500, "content_length": "3247", "url": "http://localhost:4503/system/console/bundles.json", "content": "\nHTTP ERROR 500
\nProblem accessing /system/console/bundles.json. Reason:\n
Caused by:
\n\n\n\n", "failed": true, "connection": "close", "content_type": "text/html;charset=iso-8859-1", "invocation": {"module_args": {"directory_mode": null, "force": false, "remote_src": null, "status_code": ["200"], "body_format": "json", "owner": null, "follow": false, "client_key": null, "group": null, "use_proxy": true, "unsafe_writes": null, "setype": null, "content": null, "serole": null, "follow_redirects": "safe", "return_content": true, "method": "GET", "body": null, "url_username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "url_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "dest": null, "selevel": null, "force_basic_auth": false, "removes": null, "http_agent": "ansible-httpget", "user": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "regexp": null, "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "src": null, "url": "http://localhost:4503/system/console/bundles.json", "validate_certs": true, "seuser": null, "client_cert": null, "creates": null, "headers": {"Content-Type": "application/json"}, "delimiter": null, "mode": null, "timeout": 30, "attributes": null, "backup": null}}, "date": "Thu, 28 Mar 2019 18:03:22 GMT", "redirected": false, "cache_control": "must-revalidate,no-cache,no-store", "msg": "Status code was 500 and not [200]: HTTP Error 500: Server Error"}\r\n', b'Shared connection to 192.168.25.142 closed.\r\n') <192.168.25.142> Failed to connect to the host via ssh: Shared connection to 192.168.25.142 closed. <192.168.25.142> ESTABLISH SSH CONNECTION FOR USER: root <192.168.25.142> SSH: EXEC sshpass -d41 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o User=root -o ConnectTimeout=10 -o ControlPath=/Users/fmeyer/.ansible/cp/3bcfb0a675 192.168.25.142 '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1553806800.1948202-246961565380639/ > /dev/null 2>&1 && sleep 0'"'"'' <192.168.25.142> (0, b'', b'') fatal: [192.168.25.142]: FAILED! => { "msg": "The conditional check 'result.json.s[4] == 0' failed. The error was: error while evaluating conditional (result.json.s[4] == 0): 'dict object' has no attribute 'json'" }