Define condition for the first play host one time
We use the same condition, which defines against what host some "service" tasks should run against, several times. It's hard to keep it the same across the role and ansible spending additional resources to evaluate it each time, so it's simpler and better for the maintenance to set a boolean variable which will say for all tasks, that we want to run only against signle host, if they should run or not now. Change-Id: Ic7277f4d3c6697a5be2fa86e07f8b19f0c5db069
This commit is contained in:
parent
61a6ac9fba
commit
c4d5649b11
@ -56,8 +56,7 @@
|
|||||||
delegate_to: "{{ groups[neutron_services['neutron-server']['group']][0] }}"
|
delegate_to: "{{ groups[neutron_services['neutron-server']['group']][0] }}"
|
||||||
when:
|
when:
|
||||||
- "ansible_local['openstack_ansible']['neutron']['need_db_contract'] | bool"
|
- "ansible_local['openstack_ansible']['neutron']['need_db_contract'] | bool"
|
||||||
- "neutron_services['neutron-server']['group'] in group_names"
|
- "_neutron_is_first_play_host"
|
||||||
- "inventory_hostname == ((groups[neutron_services['neutron-server']['group']] | intersect(ansible_play_hosts)) | list)[0]"
|
|
||||||
listen:
|
listen:
|
||||||
- "Restart neutron services"
|
- "Restart neutron services"
|
||||||
- "venv changed"
|
- "venv changed"
|
||||||
|
@ -34,8 +34,7 @@
|
|||||||
|
|
||||||
- import_tasks: db_setup.yml
|
- import_tasks: db_setup.yml
|
||||||
when:
|
when:
|
||||||
- "neutron_services['neutron-server']['group'] in group_names"
|
- "_neutron_is_first_play_host"
|
||||||
- "inventory_hostname == ((groups[neutron_services['neutron-server']['group']] | intersect(ansible_play_hosts)) | list)[0]"
|
|
||||||
vars:
|
vars:
|
||||||
_oslodb_setup_host: "{{ neutron_db_setup_host }}"
|
_oslodb_setup_host: "{{ neutron_db_setup_host }}"
|
||||||
_oslodb_ansible_python_interpreter: "{{ neutron_db_setup_python_interpreter }}"
|
_oslodb_ansible_python_interpreter: "{{ neutron_db_setup_python_interpreter }}"
|
||||||
@ -52,8 +51,7 @@
|
|||||||
|
|
||||||
- import_tasks: mq_setup.yml
|
- import_tasks: mq_setup.yml
|
||||||
when:
|
when:
|
||||||
- "neutron_services['neutron-server']['group'] in group_names"
|
- "_neutron_is_first_play_host"
|
||||||
- "inventory_hostname == ((groups[neutron_services['neutron-server']['group']]| intersect(ansible_play_hosts)) | list)[0]"
|
|
||||||
vars:
|
vars:
|
||||||
_oslomsg_rpc_setup_host: "{{ neutron_oslomsg_rpc_setup_host }}"
|
_oslomsg_rpc_setup_host: "{{ neutron_oslomsg_rpc_setup_host }}"
|
||||||
_oslomsg_rpc_userid: "{{ neutron_oslomsg_rpc_userid }}"
|
_oslomsg_rpc_userid: "{{ neutron_oslomsg_rpc_userid }}"
|
||||||
@ -208,8 +206,7 @@
|
|||||||
type: "{{ neutron_service_type }}"
|
type: "{{ neutron_service_type }}"
|
||||||
description: "{{ neutron_service_description }}"
|
description: "{{ neutron_service_description }}"
|
||||||
when:
|
when:
|
||||||
- "neutron_services['neutron-server']['group'] in group_names"
|
- "_neutron_is_first_play_host"
|
||||||
- "inventory_hostname == ((groups[neutron_services['neutron-server']['group']] | intersect(ansible_play_hosts)) | list)[0]"
|
|
||||||
tags:
|
tags:
|
||||||
- neutron-config
|
- neutron-config
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
become_user: "{{ neutron_system_user_name }}"
|
become_user: "{{ neutron_system_user_name }}"
|
||||||
when:
|
when:
|
||||||
- "ansible_local['openstack_ansible']['neutron']['need_db_expand'] | bool"
|
- "ansible_local['openstack_ansible']['neutron']['need_db_expand'] | bool"
|
||||||
- "inventory_hostname == ((groups[neutron_services['neutron-server']['group']] | intersect(ansible_play_hosts)) | list)[0]"
|
- "_neutron_is_first_play_host"
|
||||||
|
|
||||||
- name: Disable the db expand fact
|
- name: Disable the db expand fact
|
||||||
ini_file:
|
ini_file:
|
||||||
@ -35,7 +35,7 @@
|
|||||||
become: yes
|
become: yes
|
||||||
become_user: "{{ neutron_system_user_name }}"
|
become_user: "{{ neutron_system_user_name }}"
|
||||||
when:
|
when:
|
||||||
- "inventory_hostname == ((groups[neutron_services['neutron-server']['group']] | intersect(ansible_play_hosts)) | list)[0]"
|
- "_neutron_is_first_play_host"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
register: _offline_migrations_check
|
register: _offline_migrations_check
|
||||||
failed_when:
|
failed_when:
|
||||||
|
@ -100,7 +100,7 @@
|
|||||||
flat: yes
|
flat: yes
|
||||||
changed_when: false
|
changed_when: false
|
||||||
with_items: "{{ neutron_core_files }}"
|
with_items: "{{ neutron_core_files }}"
|
||||||
run_once: true
|
when: _neutron_is_first_play_host
|
||||||
|
|
||||||
- name: Copy common neutron config
|
- name: Copy common neutron config
|
||||||
config_template:
|
config_template:
|
||||||
|
@ -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.
|
||||||
|
|
||||||
|
_neutron_is_first_play_host: "{{ (neutron_services['neutron-server']['group'] in group_names and inventory_hostname == (groups[neutron_services['neutron-server']['group']] | intersect(ansible_play_hosts)) | first) | bool }}"
|
||||||
|
|
||||||
###
|
###
|
||||||
### Open vSwitch
|
### Open vSwitch
|
||||||
###
|
###
|
||||||
|
Loading…
Reference in New Issue
Block a user