diff --git a/tasks/cinder_post_install.yml b/tasks/cinder_post_install.yml index 29d749c1..4678b9a7 100644 --- a/tasks/cinder_post_install.yml +++ b/tasks/cinder_post_install.yml @@ -84,7 +84,7 @@ flat: yes changed_when: false with_items: "{{ cinder_core_files }}" - run_once: true + when: _cinder_is_first_play_host - name: Copy common config config_template: diff --git a/tasks/main.yml b/tasks/main.yml index 89fac588..19b8c2e2 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -42,8 +42,7 @@ - import_tasks: db_setup.yml when: - - "cinder_services['cinder-api']['group'] in group_names" - - "inventory_hostname == ((groups[cinder_services['cinder-api']['group']] | intersect(ansible_play_hosts)) | list)[0]" + - _cinder_is_first_play_host vars: _oslodb_setup_host: "{{ cinder_db_setup_host }}" _oslodb_ansible_python_interpreter: "{{ cinder_db_setup_python_interpreter }}" @@ -60,8 +59,7 @@ - import_tasks: mq_setup.yml when: - - "cinder_services['cinder-api']['group'] in group_names" - - "inventory_hostname == ((groups[cinder_services['cinder-api']['group']]| intersect(ansible_play_hosts)) | list)[0]" + - _cinder_is_first_play_host vars: _oslomsg_rpc_setup_host: "{{ cinder_oslomsg_rpc_setup_host }}" _oslomsg_rpc_userid: "{{ cinder_oslomsg_rpc_userid }}" @@ -132,9 +130,7 @@ - import_tasks: cinder_db_sync.yml when: - - "groups['cinder_api'] | length > 0" - - "cinder_services['cinder-api']['group'] in group_names" - - "inventory_hostname == ((groups['cinder_api'] | intersect(ansible_play_hosts)) | list)[0]" + - _cinder_is_first_play_host tags: - cinder-config @@ -163,9 +159,7 @@ password: "{{ cinder_service_password }}" role: "{{ cinder_service_role_name }}" when: - - "groups['cinder_api'] | length > 0" - - "cinder_services['cinder-api']['group'] in group_names" - - "inventory_hostname == ((groups['cinder_api'] | intersect(ansible_play_hosts)) | list)[0]" + - "_cinder_is_first_play_host" tags: - cinder-config @@ -203,7 +197,6 @@ - import_tasks: cinder_backends.yml when: - "groups[cinder_services['cinder-volume']['group']] | length > 0" - - "cinder_services['cinder-api']['group'] in group_names" - - "inventory_hostname == ((groups[cinder_services['cinder-api']['group']] | intersect(ansible_play_hosts)) | list)[-1]" + - "_cinder_is_first_play_host" tags: - cinder-config diff --git a/vars/main.yml b/vars/main.yml index b4581149..f8f23919 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. +_cinder_is_first_play_host: "{{ (cinder_services['cinder-api']['group'] in group_names and inventory_hostname == (groups[cinder_services['cinder-api']['group']] | intersect(ansible_play_hosts)) | first) | bool }}" + _cinder_rootwrap_conf_overrides: DEFAULT: filters_path: "/etc/cinder/rootwrap.d,/usr/share/cinder/rootwrap"