repo_build : Initialize local facts fails when upgrading

Bug #1716663 reported by systems-sk
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack-Ansible
Fix Released
Undecided
Jean-Philippe Evrard

Bug Description

Openstack-Ansible Version pre-Upgrade: 14.1.0
Openstack-Ansible Version target: 14.2.8

Ubuntu 16.0.4

TASK [repo_build : Initialize local facts] *************************************
fatal: [ctr0002_repo_container-e20c637c]: FAILED! => {"failed": true, "msg": "The conditional check '('ansible_local' is not defined) or ('openstack_ansible' not in ansible_local) or ('repo_build' not in ansible_local['openstack_ansible']) or ('need_wheel_build' not in ansible_local['openstack_ansible']['repo_build'])' failed. The error was: error while evaluating conditional (('ansible_local' is not defined) or ('openstack_ansible' not in ansible_local) or ('repo_build' not in ansible_local['openstack_ansible']) or ('need_wheel_build' not in ansible_local['openstack_ansible']['repo_build'])): Unable to look up a name or access an attribute in template string ({% if ('ansible_local' is not defined) or ('openstack_ansible' not in ansible_local) or ('repo_build' not in ansible_local['openstack_ansible']) or ('need_wheel_build' not in ansible_local['openstack_ansible']['repo_build']) %} True {% else %} False {% endif %}).\nMake sure your variable name does not contain invalid characters like '-': argument of type 'StrictUndefined' is not iterable\n\nThe error appears to have been in '/etc/ansible/roles/repo_build/tasks/repo_build_prepare.yml': line 16, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Initialize local facts\n ^ here\n"}

In the file openstack-ansible-repo_build/tasks/repo_build_prepare.yml
It looks like the conditional has a minor problem, as it should check for ansible_local being not defined.
Instead, it checks if 'ansible_local' is not defined, which I think never is the case.

I removed the quotation marks around the variable name and the playbook successfully runs

Revision history for this message
Jean-Philippe Evrard (jean-philippe-evrard) wrote :

Got the same issue to a different branch:

TASK [repo_build : Initialize local facts] *****************************************************************************************************************************************************************************************************************************************************************
task path: /etc/ansible/roles/repo_build/tasks/repo_build_prepare.yml:16
Monday 02 October 2017 14:12:05 +0000 (0:00:00.904) 0:00:32.833 ********
fatal: [aio1]: FAILED! => {
    "failed": true,
    "msg": "The conditional check '('ansible_local' is not defined) or ('openstack_ansible' not in ansible_local) or ('repo_build' not in ansible_local['openstack_ansible']) or ('need_wheel_build' not in ansible_local['openstack_ansible']['repo_build'])' failed. The error was: error while evaluating conditional (('ansible_local' is not defined) or ('openstack_ansible' not in ansible_local) or ('repo_build' not in ansible_local['openstack_ansible']) or ('need_wheel_build' not in ansible_local['openstack_ansible']['repo_build'])): Unable to look up a name or access an attribute in template string ({% if ('ansible_local' is not defined) or ('openstack_ansible' not in ansible_local) or ('repo_build' not in ansible_local['openstack_ansible']) or ('need_wheel_build' not in ansible_local['openstack_ansible']['repo_build']) %} True {% else %} False {% endif %}).\nMake sure your variable name does not contain invalid characters like '-': argument of type 'StrictUndefined' is not iterable\n\nThe error appears to have been in '/etc/ansible/roles/repo_build/tasks/repo_build_prepare.yml': line 16, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Initialize local facts\n ^ here\n"
}

NO MORE HOSTS LEFT *****************************************************************************************************************************************************************************************************************************************************************************************

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

Revision history for this message
Jean-Philippe Evrard (jean-philippe-evrard) wrote :

We should probably use a different syntax indeed:

``
when: |
  "<condition>"
``

seem to work for me.

but

``
when:
  - <condition>
``

doesn't seem to work, like suggested.

``
  when:
    - "(ansible_local is not defined) or
       ('openstack_ansible' not in ansible_local) or
       ('repo_build' not in ansible_local['openstack_ansible']) or
       ('need_wheel_build' not in ansible_local['openstack_ansible']['repo_build'])"
``
Seem to work, but I have to test how this works.

Revision history for this message
Jean-Philippe Evrard (jean-philippe-evrard) wrote :

ok it seems to work without the ' ' around ansible_local.

Revision history for this message
Jean-Philippe Evrard (jean-philippe-evrard) wrote :

alternatively with jmespath:

not
ansible_local | default({}) | json_query('openstack_ansible.repo_build.need_venv_build') | default(False, True)

could be implemented.

Revision history for this message
Jean-Philippe Evrard (jean-philippe-evrard) wrote :

(Last one has to be tested)

Revision history for this message
Jean-Philippe Evrard (jean-philippe-evrard) wrote :

the jmespath has to be updated to:
when:
  - "(ansible_local | default({})) | json_query('type(openstack_ansible.repo_build.need_wheel_build)') == 'null'"

tags: added: low-
tags: added: low-hanging-fruit
removed: low-
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to openstack-ansible-repo_build (master)

Fix proposed to branch: master
Review: https://review.openstack.org/508928

Changed in openstack-ansible:
assignee: nobody → Jean-Philippe Evrard (jean-philippe-evrard)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to openstack-ansible-repo_build (master)

Reviewed: https://review.openstack.org/508928
Committed: https://git.openstack.org/cgit/openstack/openstack-ansible-repo_build/commit/?id=427be7bb2de2995ff8742ac8f211d554d0ec9478
Submitter: Jenkins
Branch: master

commit 427be7bb2de2995ff8742ac8f211d554d0ec9478
Author: Jean-Philippe Evrard <email address hidden>
Date: Mon Oct 2 17:06:02 2017 +0100

    Fix typo on conditional

    'ansible_local' is not a string, but a variable.

    Change-Id: I63817bb3c58a2c44d3e948bdb81005dc2e734c21
    Closes-Bug: 1716663

Changed in openstack-ansible:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to openstack-ansible-repo_build (stable/pike)

Fix proposed to branch: stable/pike
Review: https://review.openstack.org/509386

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to openstack-ansible-repo_build (stable/ocata)

Fix proposed to branch: stable/ocata
Review: https://review.openstack.org/509387

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to openstack-ansible-repo_build (stable/newton)

Fix proposed to branch: stable/newton
Review: https://review.openstack.org/509388

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to openstack-ansible-repo_build (stable/pike)

Reviewed: https://review.openstack.org/509386
Committed: https://git.openstack.org/cgit/openstack/openstack-ansible-repo_build/commit/?id=804ce35802d8caf5a5174128e8ac566b5629a223
Submitter: Jenkins
Branch: stable/pike

commit 804ce35802d8caf5a5174128e8ac566b5629a223
Author: Jean-Philippe Evrard <email address hidden>
Date: Mon Oct 2 17:06:02 2017 +0100

    Fix typo on conditional

    'ansible_local' is not a string, but a variable.

    Change-Id: I63817bb3c58a2c44d3e948bdb81005dc2e734c21
    Closes-Bug: 1716663
    (cherry picked from commit 427be7bb2de2995ff8742ac8f211d554d0ec9478)

tags: added: in-stable-pike
tags: added: in-stable-newton
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to openstack-ansible-repo_build (stable/newton)

Reviewed: https://review.openstack.org/509388
Committed: https://git.openstack.org/cgit/openstack/openstack-ansible-repo_build/commit/?id=e7202b29923272004afe1507c21bda89a1ae62fa
Submitter: Jenkins
Branch: stable/newton

commit e7202b29923272004afe1507c21bda89a1ae62fa
Author: Jean-Philippe Evrard <email address hidden>
Date: Mon Oct 2 17:06:02 2017 +0100

    Fix typo on conditional

    'ansible_local' is not a string, but a variable.

    Change-Id: I63817bb3c58a2c44d3e948bdb81005dc2e734c21
    Closes-Bug: 1716663
    (cherry picked from commit 427be7bb2de2995ff8742ac8f211d554d0ec9478)

tags: added: in-stable-ocata
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to openstack-ansible-repo_build (stable/ocata)

Reviewed: https://review.openstack.org/509387
Committed: https://git.openstack.org/cgit/openstack/openstack-ansible-repo_build/commit/?id=ec2810bbca0a70bd675a4a44a2b969d0e8d811e4
Submitter: Jenkins
Branch: stable/ocata

commit ec2810bbca0a70bd675a4a44a2b969d0e8d811e4
Author: Jean-Philippe Evrard <email address hidden>
Date: Mon Oct 2 17:06:02 2017 +0100

    Fix typo on conditional

    'ansible_local' is not a string, but a variable.

    Change-Id: I63817bb3c58a2c44d3e948bdb81005dc2e734c21
    Closes-Bug: 1716663
    (cherry picked from commit 427be7bb2de2995ff8742ac8f211d554d0ec9478)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/openstack-ansible-repo_build 17.0.0.0b1

This issue was fixed in the openstack/openstack-ansible-repo_build 17.0.0.0b1 development milestone.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/openstack-ansible-repo_build 14.2.11

This issue was fixed in the openstack/openstack-ansible-repo_build 14.2.11 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/openstack-ansible-repo_build 15.1.11

This issue was fixed in the openstack/openstack-ansible-repo_build 15.1.11 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/openstack-ansible-repo_build 16.0.3

This issue was fixed in the openstack/openstack-ansible-repo_build 16.0.3 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.