Wrong syntax for import_role in the ansible part of the templates.

Bug #1797412 reported by Sofer Athlan-Guyot
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tripleo
Fix Released
Critical
Sofer Athlan-Guyot

Bug Description

Hi,

discovered while testing the linting of the resulting template, so I don't have yet a public link to give yet[0]

But what you get is the cryptic following error:

Traceback (most recent call last):
  File "/tmp/.quickstart/bin/ansible-lint", line 11, in <module>
    sys.exit(main())
  File "/tmp/.quickstart/lib/python2.7/site-packages/ansiblelint/__main__.py", line 176, in main
    matches.extend(runner.run())
  File "/tmp/.quickstart/lib/python2.7/site-packages/ansiblelint/__init__.py", line 229, in run
    for child in ansiblelint.utils.find_children(arg, self.playbook_dir):
  File "/tmp/.quickstart/lib/python2.7/site-packages/ansiblelint/utils.py", line 171, in find_children
    for child in play_children(basedir, item, playbook[1], playbook_dir):
  File "/tmp/.quickstart/lib/python2.7/site-packages/ansiblelint/utils.py", line 221, in play_children
    return delegate_map[k](basedir, k, v, parent_type)
  File "/tmp/.quickstart/lib/python2.7/site-packages/ansiblelint/utils.py", line 249, in _taskshandlers_children
    main=th['import_role'].get('tasks_from', 'main')))
  File "/tmp/.quickstart/lib/python2.7/site-packages/ansiblelint/utils.py", line 290, in _roles_children
    results.extend(_look_for_role_files(basedir, role, main=main))
  File "/tmp/.quickstart/lib/python2.7/site-packages/ansiblelint/utils.py", line 333, in _look_for_role_files
    role_path = _rolepath(basedir, role)
  File "/tmp/.quickstart/lib/python2.7/site-packages/ansiblelint/utils.py", line 304, in _rolepath
    path_dwim(basedir, os.path.join('roles', role)),
  File "/tmp/.quickstart/lib64/python2.7/posixpath.py", line 75, in join
    if b.startswith('/'):
AttributeError: 'NoneType' object has no attribute 'startswith'

After some debugging of the trace it boiled down to this code[1]:

            - block:
              - name: load openvswitch module
                import_role:
                  role: tripleo-module-load
                vars:
                  modules:

After investigation that is the part that is failing in the ansible-lint part[2]

        elif 'import_role' in th:
            results.extend(_roles_children(basedir, k, [th['import_role'].get('name')], parent_type,
main=th['import_role'].get('tasks_from', 'main')))

we can see that it tries to access 'name' not 'role'. This is in line with the documentation[3].

So It seems the import_role parameter here is wrong and should be 'name', not 'role'.

[0] those are the reviews tested https://review.openstack.org/#/q/status:open++branch:master+topic:feature/standalone_ansible_lint

[1] https://github.com/openstack/tripleo-heat-templates/blob/master/docker/services/neutron-ovs-agent.yaml#L193..L200

[2] https://github.com/willthames/ansible-lint/blob/master/lib/ansiblelint/utils.py#L247-L249

[3] https://docs.ansible.com/ansible/2.4/import_role_module.html

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tripleo-heat-templates (master)

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

Changed in tripleo:
assignee: nobody → Sofer Athlan-Guyot (sofer-athlan-guyot)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tripleo-heat-templates (master)

Reviewed: https://review.openstack.org/609754
Committed: https://git.openstack.org/cgit/openstack/tripleo-heat-templates/commit/?id=c8c45bec6a19ad81c09c13d6460cdf1735623708
Submitter: Zuul
Branch: master

commit c8c45bec6a19ad81c09c13d6460cdf1735623708
Author: Sofer Athlan-Guyot <email address hidden>
Date: Thu Oct 11 17:55:02 2018 +0200

    import_role takes name as a parameter, not role.

    According to ansible documentation[1] the import_role task uses 'name'
    as a parameter for import_role, not 'role'.

    [1] https://docs.ansible.com/ansible/2.4/import_role_module.html

    Change-Id: Ibda367ed44eb9ddca04c266f5c40134f10dfe945
    Closes-Bug: #1797412

Changed in tripleo:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/tripleo-heat-templates 10.1.0

This issue was fixed in the openstack/tripleo-heat-templates 10.1.0 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.