diff --git a/tasks/main.yml b/tasks/main.yml index b88d498..006cdf5 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -90,8 +90,7 @@ - common-mq - zun-config when: - - "zun_services['zun-api']['group'] in group_names" - - "inventory_hostname == ((groups[zun_services['zun-api']['group']] | intersect(ansible_play_hosts)) | list)[0]" + - _zun_is_first_play_host vars: _oslomsg_rpc_setup_host: "{{ zun_oslomsg_rpc_setup_host }}" _oslomsg_rpc_userid: "{{ zun_oslomsg_rpc_userid }}" @@ -128,8 +127,7 @@ - username: "{{ zun_galera_user }}" password: "{{ zun_galera_password }}" when: - - "zun_services['zun-api']['group'] in group_names" - - "inventory_hostname == ((groups['zun_api'] | intersect(ansible_play_hosts)) | list)[0]" + - _zun_is_first_play_host tags: - always @@ -169,8 +167,7 @@ type: "{{ zun_service_type }}" description: "{{ zun_service_description }}" when: - - "zun_services['zun-api']['group'] in group_names" - - "inventory_hostname == ((groups['zun_api'] | intersect(ansible_play_hosts)) | list)[0]" + - _zun_is_first_play_host tags: - always diff --git a/tasks/zun_post_install.yml b/tasks/zun_post_install.yml index e7b0795..abf0da6 100644 --- a/tasks/zun_post_install.yml +++ b/tasks/zun_post_install.yml @@ -84,5 +84,4 @@ become_user: "{{ zun_system_user_name }}" changed_when: false when: - - zun_services['zun-api']['group'] in group_names - - inventory_hostname == ((groups['zun_api'] | intersect(ansible_play_hosts)) | list)[0] + - _zun_is_first_play_host diff --git a/vars/main.yml b/vars/main.yml index dbfa38e..70e7953 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -13,6 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +_zun_is_first_play_host: >- + {{ + (zun_services['zun-api']['group'] in group_names and + inventory_hostname == groups[zun_services['zun-api']['group']] | select('in', ansible_play_hosts) | first) | bool + }} + _zun_oslomsg_rpc_vhost_conf: >- {{ (zun_oslomsg_rpc_vhost is string) | ternary(