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 fc036e18f7
commit 6bb0178f64
8 changed files with 55 additions and 40 deletions

View File

@ -32,19 +32,17 @@
- lxc-aa-profile
- name: Add volume group block device to cinder
shell: |
{% if item.1.volume_group is defined %}
if [ "$(pvdisplay | grep -B1 {{ item.1.volume_group }} | awk '/PV/ {print $3}')" ];then
for device in `pvdisplay | grep -B1 {{ item.1.volume_group }} | awk '/PV/ {print $3}'`
{% if item.value.volume_group is defined %}
if [ "$(pvdisplay | grep -B1 {{ item.value.volume_group }} | awk '/PV/ {print $3}')" ];then
for device in `pvdisplay | grep -B1 {{ item.value.volume_group }} | awk '/PV/ {print $3}'`
do lxc-device -n {{ container_name }} add $device
done
fi
{% else %}
echo "{{ item.1 }} volume_group not defined"
echo "{{ item.key }} volume_group not defined"
{% endif %}
with_items: cinder_backends|dictsort
when: >
cinder_backends is defined and
physical_host != container_name
with_dict: cinder_backends|default({})
when: physical_host != container_name
delegate_to: "{{ physical_host }}"
tags:
- cinder-lxc-devices

View File

@ -27,10 +27,9 @@
- name: Add in cinder devices types
shell: |
. {{ ansible_env.HOME }}/openrc
{{ cinder_bin }}/cinder type-create "{{ item.0 }}"
{{ cinder_bin }}/cinder type-key "{{ item.0 }}" set volume_backend_name="{{ item.1.volume_backend_name }}"
with_items: cinder_backends|dictsort
when: cinder_backends is defined
{{ cinder_bin }}/cinder type-create "{{ item.key }}"
{{ cinder_bin }}/cinder type-key "{{ item.key }}" set volume_backend_name="{{ item.value.volume_backend_name }}"
with_dict: cinder_backends|default({})
tags:
- cinder-backends
- cinder-backends-types

View File

@ -53,7 +53,6 @@
src: "{{ item.value.src }}"
dest: "{{ horizon_lib_dir }}/openstack_dashboard/static/dashboard/{{ item.value.dest }}"
with_dict: "{{ horizon_custom_uploads | default({}) }}"
when: horizon_custom_uploads is defined
tags:
- horizon-branding

View File

@ -13,17 +13,27 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Drop user provided ssl cert and key
- name: Drop user provided ssl cert
copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
src: "{{ horizon_user_ssl_cert }}"
dest: "{{ horizon_ssl_cert }}"
owner: "root"
group: "root"
mode: "{{ item.mode }}"
with_items:
- { src: "{{ horizon_user_ssl_cert }}", dest: "{{ horizon_ssl_cert }}", mode: "0644" }
- { src: "{{ horizon_user_ssl_key }}", dest: "{{ horizon_ssl_key }}", mode: "0640" }
when: horizon_user_ssl_cert is defined and horizon_user_ssl_key is defined
mode: "0644"
when: horizon_user_ssl_cert is defined
notify: Restart apache2
tags:
- horizon-configs
- horizon-ssl
- name: Drop user provided ssl key
copy:
src: "{{ horizon_user_ssl_key }}"
dest: "{{ horizon_ssl_key }}"
owner: "root"
group: "root"
mode: "0640"
when: horizon_user_ssl_key is defined
notify: Restart apache2
tags:
- horizon-configs

View File

@ -13,17 +13,27 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Drop user provided ssl cert and key
- name: Drop user provided ssl cert
copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
src: "{{ keystone_user_ssl_cert }}"
dest: "{{ keystone_ssl_cert }}"
owner: "root"
group: "root"
mode: "{{ item.mode }}"
with_items:
- { src: "{{ keystone_user_ssl_cert }}", dest: "{{ keystone_ssl_cert }}", mode: "0644" }
- { src: "{{ keystone_user_ssl_key }}", dest: "{{ keystone_ssl_key }}", mode: "0640" }
when: keystone_user_ssl_cert is defined and keystone_user_ssl_key is defined
mode: "0644"
when: keystone_user_ssl_cert is defined
notify: Restart Apache
tags:
- keystone-configs
- keystone-ssl
- name: Drop user provided ssl key
copy:
src: "{{ keystone_user_ssl_key }}"
dest: "{{ keystone_ssl_key }}"
owner: "root"
group: "root"
mode: "0640"
when: keystone_user_ssl_key is defined
notify: Restart Apache
tags:
- keystone-configs

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"