diff --git a/tasks/ironic_db_setup.yml b/tasks/ironic_db_setup.yml index 7ee2d8fe..995812f9 100644 --- a/tasks/ironic_db_setup.yml +++ b/tasks/ironic_db_setup.yml @@ -25,5 +25,4 @@ become: yes changed_when: false when: - - ironic_services['ironic-inspector']['group'] in group_names - - inventory_hostname == groups[ironic_services['ironic-inspector']['group']][0] + - _ironic_inspector_is_first_play_host diff --git a/tasks/ironic_post_install.yml b/tasks/ironic_post_install.yml index 1971aff3..ea283bbf 100644 --- a/tasks/ironic_post_install.yml +++ b/tasks/ironic_post_install.yml @@ -25,7 +25,7 @@ OS_ENDPOINT_TYPE: internalURL when: - not ironic_enable_web_server_for_images | bool - - inventory_hostname == groups['ironic_all'][0] + - _ironic_api_is_first_play_host - not ironic_standalone | bool tags: - always diff --git a/tasks/main.yml b/tasks/main.yml index a850232b..8670d231 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -26,8 +26,7 @@ - import_tasks: db_setup.yml when: - - "ironic_services['ironic-api']['group'] in group_names" - - "inventory_hostname == ((groups[ironic_services['ironic-api']['group']]| intersect(ansible_play_hosts)) | list)[0]" + - _ironic_api_is_first_play_host vars: _oslodb_setup_host: "{{ ironic_db_setup_host }}" _oslodb_ansible_python_interpreter: "{{ ironic_db_setup_python_interpreter }}" @@ -44,8 +43,7 @@ - import_tasks: db_setup.yml when: - - "ironic_services['ironic-inspector']['group'] in group_names" - - "inventory_hostname == ((groups[ironic_services['ironic-inspector']['group']]| intersect(ansible_play_hosts)) | list)[0]" + - _ironic_inspector_is_first_play_host vars: _oslodb_setup_host: "{{ ironic_inspector_db_setup_host }}" _oslodb_ansible_python_interpreter: "{{ ironic_inspector_db_setup_python_interpreter }}" @@ -62,8 +60,7 @@ - import_tasks: mq_setup.yml when: - - "ironic_services['ironic-api']['group'] in group_names" - - "inventory_hostname == ((groups[ironic_services['ironic-api']['group']]| intersect(ansible_play_hosts)) | list)[0]" + - _ironic_api_is_first_play_host vars: _oslomsg_rpc_setup_host: "{{ ironic_oslomsg_rpc_setup_host }}" _oslomsg_rpc_userid: "{{ ironic_oslomsg_rpc_userid }}" @@ -153,7 +150,7 @@ _service_users: "{{ ironic_service_user_list }}" _service_endpoints: "{{ ironic_service_endpoint_list }}" _service_catalog: "{{ ironic_service_catalog_list }}" - when: (inventory_hostname == groups['ironic_api'][0] or inventory_hostname == groups['ironic_inspector'][0]) + when: (_ironic_api_is_first_play_host or _ironic_inspector_is_first_play_host) tags: - ironic-config diff --git a/vars/main.yml b/vars/main.yml index a04b26c5..3b4e47dd 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +_ironic_api_is_first_play_host: "{{ (ironic_services['ironic-api']['group'] in group_names and inventory_hostname == (groups[ironic_services['ironic-api']['group']] | intersect(ansible_play_hosts)) | first) | bool }}" +_ironic_inspector_is_first_play_host: "{{ (ironic_services['ironic-inspector']['group'] in group_names and inventory_hostname == (groups[ironic_services['ironic-inspector']['group']] | intersect(ansible_play_hosts)) | first) | bool }}" + # This special list brings together all of the package installations into one # task to save time.