Merge "Define condition for the first play host one time"

This commit is contained in:
Zuul 2020-09-21 08:49:44 +00:00 committed by Gerrit Code Review
commit 6dd71d2b0e
3 changed files with 8 additions and 13 deletions

View File

@ -84,7 +84,7 @@
flat: yes flat: yes
changed_when: false changed_when: false
with_items: "{{ cinder_core_files }}" with_items: "{{ cinder_core_files }}"
run_once: true when: _cinder_is_first_play_host
- name: Copy common config - name: Copy common config
config_template: config_template:

View File

@ -42,8 +42,7 @@
- import_tasks: db_setup.yml - import_tasks: db_setup.yml
when: when:
- "cinder_services['cinder-api']['group'] in group_names" - _cinder_is_first_play_host
- "inventory_hostname == ((groups[cinder_services['cinder-api']['group']] | intersect(ansible_play_hosts)) | list)[0]"
vars: vars:
_oslodb_setup_host: "{{ cinder_db_setup_host }}" _oslodb_setup_host: "{{ cinder_db_setup_host }}"
_oslodb_ansible_python_interpreter: "{{ cinder_db_setup_python_interpreter }}" _oslodb_ansible_python_interpreter: "{{ cinder_db_setup_python_interpreter }}"
@ -60,8 +59,7 @@
- import_tasks: mq_setup.yml - import_tasks: mq_setup.yml
when: when:
- "cinder_services['cinder-api']['group'] in group_names" - _cinder_is_first_play_host
- "inventory_hostname == ((groups[cinder_services['cinder-api']['group']]| intersect(ansible_play_hosts)) | list)[0]"
vars: vars:
_oslomsg_rpc_setup_host: "{{ cinder_oslomsg_rpc_setup_host }}" _oslomsg_rpc_setup_host: "{{ cinder_oslomsg_rpc_setup_host }}"
_oslomsg_rpc_userid: "{{ cinder_oslomsg_rpc_userid }}" _oslomsg_rpc_userid: "{{ cinder_oslomsg_rpc_userid }}"
@ -132,9 +130,7 @@
- import_tasks: cinder_db_sync.yml - import_tasks: cinder_db_sync.yml
when: when:
- "groups['cinder_api'] | length > 0" - _cinder_is_first_play_host
- "cinder_services['cinder-api']['group'] in group_names"
- "inventory_hostname == ((groups['cinder_api'] | intersect(ansible_play_hosts)) | list)[0]"
tags: tags:
- cinder-config - cinder-config
@ -163,9 +159,7 @@
password: "{{ cinder_service_password }}" password: "{{ cinder_service_password }}"
role: "{{ cinder_service_role_name }}" role: "{{ cinder_service_role_name }}"
when: when:
- "groups['cinder_api'] | length > 0" - "_cinder_is_first_play_host"
- "cinder_services['cinder-api']['group'] in group_names"
- "inventory_hostname == ((groups['cinder_api'] | intersect(ansible_play_hosts)) | list)[0]"
tags: tags:
- cinder-config - cinder-config
@ -203,7 +197,6 @@
- import_tasks: cinder_backends.yml - import_tasks: cinder_backends.yml
when: when:
- "groups[cinder_services['cinder-volume']['group']] | length > 0" - "groups[cinder_services['cinder-volume']['group']] | length > 0"
- "cinder_services['cinder-api']['group'] in group_names" - "_cinder_is_first_play_host"
- "inventory_hostname == ((groups[cinder_services['cinder-api']['group']] | intersect(ansible_play_hosts)) | list)[-1]"
tags: tags:
- cinder-config - cinder-config

View File

@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # 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: _cinder_rootwrap_conf_overrides:
DEFAULT: DEFAULT:
filters_path: "/etc/cinder/rootwrap.d,/usr/share/cinder/rootwrap" filters_path: "/etc/cinder/rootwrap.d,/usr/share/cinder/rootwrap"