redhat-openstack / infrared

Plugin based framework that aims to provide an easy-to-use CLI for Ansible based projects
https://infrared.readthedocs.io/en/latest/index.html
Apache License 2.0
99 stars 97 forks source link

Openstack plugin: provisioning 0 networks causes errors #357

Closed greg-hellings closed 5 years ago

greg-hellings commented 5 years ago

When attempting to provision with no networks (defining a custom network topology with network_vars: []) results in an error from the plugin playbook.

TASK [register networks resources] **********************************************************************
Tuesday 26 March 2019  09:29:04 -0500 (0:00:00.046)       0:00:01.470 ********* 
included: /home/ghelling/config/source/oasis/workspace/plugins/openstack/tasks/register_resources_file.yml for localhost

TASK [register resources] *******************************************************************************
Tuesday 26 March 2019  09:29:04 -0500 (0:00:00.074)       0:00:01.544 ********* 
fatal: [localhost]: FAILED! => 
  msg: |-
    The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'results'

    The error appears to have been in '/home/ghelling/config/source/oasis/workspace/plugins/openstack/tasks/register_resources_file.yml': line 1, column 3, but may
    be elsewhere in the file depending on the exact syntax problem.

    The offending line appears to be:

    - name: register resources
      ^ here

This results because the playbook does not guard against an empty return value from the skipped task when this array is empty.

avishaymahluf commented 5 years ago

Hi @greg-hellings,

Thank you for submitting this issue. I created the following patch that should solve that: https://review.gerrithub.io/#/c/redhat-openstack/infrared/+/449849