Cleanup syntax issues for Ansible 2 compatibility

This patch fixes a few syntax issues required for Ansible 2
compatibility that Ansible 1.x was more lenient with.

When a 'when' clause is combined with a 'with_*' statement, the clause
is processed separately for each item. Tasks with 'when' clauses which
depended on an item variable being defined have either applied a default
empty value to the item or a new task individual task has been created
for each item in the loop.

Tasks within the os-cinder-install playboook have been updated to loop
through cinder_backends as a hash.

Change-Id: I9b53eb5dd709a6bed1797961015aa3dd328340f3
This commit is contained in:
Jimmy McCrory 2016-01-14 14:04:49 -08:00
parent 533a0a86cc
commit 0e2425621d
3 changed files with 10 additions and 11 deletions

View File

@ -31,8 +31,8 @@
owner: "{{ swift_system_user_name }}"
group: "{{ swift_system_group_name }}"
with_items:
- { item: "{{ swift.account }}", port: "{{ swift_account_port }}", type: "account" }
- { item: "{{ swift.container }}", port: "{{ swift_container_port}}", type: "container" }
- { item: "{{ swift.account | default({}) }}", port: "{{ swift_account_port }}", type: "account" }
- { item: "{{ swift.container | default({}) }}", port: "{{ swift_container_port}}", type: "container" }
tags:
- swift-rings
- swift-rings-contents
@ -68,8 +68,7 @@
command: "/usr/bin/python /etc/swift/scripts/swift_rings.py -f /etc/swift/scripts/{{ item[0] }}.contents -r {{ item[1] }}"
with_nested:
- [ 'account', 'container' ]
- swift_managed_regions
when: swift_managed_regions is defined
- swift_managed_regions | default([])
sudo: yes
sudo_user: "{{ swift_system_user_name }}"
args:
@ -95,8 +94,7 @@
command: "/usr/bin/python /etc/swift/scripts/swift_rings.py -f /etc/swift/scripts/object-{{ item[0].policy.index }}.contents -r {{ item[1] }}"
with_nested:
- "{{ swift.storage_policies }}"
- swift_managed_regions
when: swift_managed_regions is defined
- swift_managed_regions | default([])
sudo: yes
sudo_user: "{{ swift_system_user_name }}"
args:

View File

@ -61,8 +61,7 @@
command: "/usr/bin/python /etc/swift/scripts/swift_rings_check.py -f /etc/swift/scripts/{{ item[0] }}.contents -r {{ item[1] }}"
with_nested:
- [ 'account', 'container' ]
- swift_managed_regions
when: swift_managed_regions is defined
- swift_managed_regions | default([])
sudo: yes
sudo_user: "{{ swift_system_user_name }}"
args:
@ -88,8 +87,7 @@
command: "/usr/bin/python /etc/swift/scripts/swift_rings_check.py -f /etc/swift/scripts/object-{{ item[0].policy.index }}.contents -r {{ item[1] }}"
with_nested:
- "{{ swift.storage_policies }}"
- swift_managed_regions
when: swift_managed_regions is defined
- swift_managed_regions | default([])
sudo: yes
sudo_user: "{{ swift_system_user_name }}"
args:

View File

@ -18,7 +18,10 @@
name: "{{ item }}"
state: "started"
pattern: "{{ item }}"
with_items: swift_account_program_names + swift_container_program_names + swift_object_program_names
with_items:
- "{{ swift_account_program_names }}"
- "{{ swift_container_program_names }}"
- "{{ swift_object_program_names }}"
when: inventory_hostname in groups['swift_hosts']
- name: "Ensure services are started"