Switch from run_once back to inventory scoping

As it turns out, run_once executes a task
once per batch when executed from a serialised
playbook instead of once per set of play hosts
as previously thought.

In this patch we implement a combination of
dynamic inclusion, inventory scoping and
play host scoping to achieve the required
goal of only running it once, even when the
playbook is executed using limits.

Depends-On: I548971e2de92280fe2cc4ff0a6a926497733fa7d
Change-Id: Icde03cd2610f52859fd8d2d7540f442a36e51695
This commit is contained in:
Jesse Pretorius 2017-07-04 14:08:02 +01:00 committed by Jesse Pretorius (odyssey4me)
parent 9ef1b61fe9
commit 1bcd6d5812
4 changed files with 13 additions and 10 deletions

View File

@ -70,7 +70,8 @@
delegate_to: "{{ groups[neutron_services['neutron-server']['group']][0] }}"
when:
- "ansible_local['openstack_ansible']['neutron']['need_db_contract'] | bool"
run_once: yes
- "neutron_services['neutron-server']['group'] in group_names"
- "inventory_hostname == ansible_play_hosts[0]"
listen: "Restart neutron services"
- name: Start services

View File

@ -86,15 +86,22 @@
- neutron-config
- include: neutron_db_setup.yml
static: no
when:
- "neutron_services['neutron-server']['group'] in group_names"
tags:
- neutron-config
- include: neutron_service_setup.yml
run_once: yes
static: no
when:
- "neutron_services['neutron-server']['group'] in group_names"
- "inventory_hostname == ansible_play_hosts[0]"
tags:
- neutron-config
- include: neutron_l3_ha.yml
static: no
when:
- "neutron_services['neutron-l3-agent']['group'] in group_names"
tags:

View File

@ -17,10 +17,9 @@
command: "{{ neutron_bin }}/neutron-db-manage upgrade --expand"
become: yes
become_user: "{{ neutron_system_user_name }}"
delegate_to: "{{ groups[neutron_services['neutron-server']['group']][0] }}"
when:
- "ansible_local['openstack_ansible']['neutron']['need_db_expand'] | bool"
run_once: yes
- "inventory_hostname == ansible_play_hosts[0]"
- name: Disable the db expand fact
ini_file:
@ -33,13 +32,13 @@
command: "{{ neutron_bin }}/neutron-db-manage has_offline_migrations"
become: yes
become_user: "{{ neutron_system_user_name }}"
delegate_to: "{{ groups[neutron_services['neutron-server']['group']][0] }}"
when:
- "inventory_hostname == ansible_play_hosts[0]"
changed_when: false
register: _offline_migrations_check
failed_when:
- "_offline_migrations_check.rc == 1"
- "'Need to apply migrations from neutron contract branch' not in _offline_migrations_check.stdout"
run_once: yes
- name: Set the fact for the required offline migrations
ini_file:

View File

@ -29,7 +29,6 @@
until: add_service|success
retries: 5
delay: 2
run_once: yes
# Create an admin user
- name: Ensure neutron user
@ -48,7 +47,6 @@
until: add_service|success
retries: 5
delay: 10
run_once: yes
# Add a role to the user
- name: Ensure neutron user to admin role
@ -67,7 +65,6 @@
until: add_service|success
retries: 5
delay: 10
run_once: yes
# Create an endpoint
- name: Ensure neutron endpoint
@ -92,4 +89,3 @@
until: add_service|success
retries: 5
delay: 10
run_once: yes