diff --git a/tasks/main.yml b/tasks/main.yml index e9057df..e273f54 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -25,8 +25,7 @@ - import_tasks: db_setup.yml when: - - "magnum_services['magnum-api']['group'] in group_names" - - "inventory_hostname == ((groups[magnum_services['magnum-api']['group']]| intersect(ansible_play_hosts)) | list)[0]" + - "_magnum_is_first_play_host" vars: _oslodb_setup_host: "{{ magnum_db_setup_host }}" _oslodb_ansible_python_interpreter: "{{ magnum_db_setup_python_interpreter }}" @@ -43,8 +42,7 @@ - import_tasks: mq_setup.yml when: - - "magnum_services['magnum-api']['group'] in group_names" - - "inventory_hostname == ((groups[magnum_services['magnum-api']['group']]| intersect(ansible_play_hosts)) | list)[0]" + - "_magnum_is_first_play_host" vars: _oslomsg_rpc_setup_host: "{{ magnum_oslomsg_rpc_setup_host }}" _oslomsg_rpc_userid: "{{ magnum_oslomsg_rpc_userid }}" @@ -106,7 +104,7 @@ - systemd-service - import_tasks: magnum_db_sync.yml - when: inventory_hostname == groups['magnum_all'][0] + when: _magnum_is_first_play_host tags: - magnum-config @@ -121,7 +119,7 @@ - uwsgi - import_tasks: magnum_service_setup.yml - when: inventory_hostname == groups['magnum_all'][0] + when: _magnum_is_first_play_host tags: - magnum-config @@ -129,6 +127,6 @@ meta: flush_handlers - import_tasks: magnum_resources.yml - when: inventory_hostname == groups['magnum_all'][0] + when: _magnum_is_first_play_host tags: - magnum-config diff --git a/vars/main.yml b/vars/main.yml index 78118c9..e59b4c4 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -14,6 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +_magnum_is_first_play_host: "{{ (magnum_services['magnum-api']['group'] in group_names and inventory_hostname == (groups[magnum_services['magnum-api']['group']] | intersect(ansible_play_hosts)) | first) | bool }}" + # # Compile a list of the services on a host based on whether # the host is in the host group and the service is enabled.