diff --git a/tasks/glance_post_install.yml b/tasks/glance_post_install.yml index d042c577..a12e9f02 100644 --- a/tasks/glance_post_install.yml +++ b/tasks/glance_post_install.yml @@ -108,7 +108,7 @@ dest: "{{ item.tmp_f }}" flat: yes changed_when: false - run_once: true + when: _glance_is_first_play_host with_items: "{{ glance_core_files }}" - name: Copy common config @@ -130,7 +130,7 @@ state: absent changed_when: false delegate_to: localhost - run_once: true + when: _glance_is_first_play_host with_items: "{{ glance_core_files }}" # NOTE(cloudnull): This will ensure strong permissions on all rootwrap files. diff --git a/tasks/main.yml b/tasks/main.yml index 0165d79e..efc3842d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -42,8 +42,7 @@ - import_tasks: db_setup.yml when: - - "glance_services['glance-api']['group'] in group_names" - - "inventory_hostname == ((groups[glance_services['glance-api']['group']]| intersect(ansible_play_hosts)) | list)[0]" + - "_glance_is_first_play_host" vars: _oslodb_setup_host: "{{ glance_db_setup_host }}" _oslodb_ansible_python_interpreter: "{{ glance_db_setup_python_interpreter }}" @@ -60,8 +59,7 @@ - import_tasks: mq_setup.yml when: - - "glance_services['glance-api']['group'] in group_names" - - "inventory_hostname == ((groups[glance_services['glance-api']['group']]| intersect(ansible_play_hosts)) | list)[0]" + - "_glance_is_first_play_host" vars: _oslomsg_rpc_setup_host: "{{ glance_oslomsg_rpc_setup_host }}" _oslomsg_rpc_userid: "{{ glance_oslomsg_rpc_userid }}" @@ -87,8 +85,7 @@ - import_tasks: glance_db_sync.yml when: - - "glance_services['glance-api']['group'] in group_names" - - "inventory_hostname == ((groups[glance_services['glance-api']['group']]| intersect(ansible_play_hosts)) | list)[0]" + - "_glance_is_first_play_host" tags: - glance-config @@ -119,8 +116,7 @@ url: "{{ glance_service_adminurl }}" service: "{{ glance_service_name }}" when: - - "glance_services['glance-api']['group'] in group_names" - - "inventory_hostname == ((groups[glance_services['glance-api']['group']]| intersect(ansible_play_hosts)) | list)[0]" + - "_glance_is_first_play_host" tags: - glance-config diff --git a/vars/main.yml b/vars/main.yml index 1bebf0ea..7dc44247 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +_glance_is_first_play_host: "{{ (glance_services['glance-api']['group'] in group_names and inventory_hostname == (groups[glance_services['glance-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.