Address Ansible bare variable usage

When executing the role with Ansible 2.1, the following
deprecation warning is issued in the output for some tasks.

[DEPRECATION WARNING]: Using bare variables is deprecated.

This patch addresses the tasks to fix the behaviour appropriately.

Change-Id: I5d883f4fa4388ec24f1da22d42b2c6d028d9ce94
This commit is contained in:
Jesse Pretorius
2016-06-14 18:26:14 +01:00
parent 026a4a20bc
commit be8824d261
9 changed files with 26 additions and 16 deletions

View File

@@ -26,6 +26,7 @@ openstack_host_sysstat_statistics_hour: 23
openstack_host_manage_hosts_file: true
## kernel modules for specific group hosts
openstack_host_specific_kernel_modules: []
# to include it in your play, an example is given below:
#openstack_host_specific_kernel_modules:
# - { name: "ebtables", pattern: "CONFIG_BRIDGE_NF_EBTABLES", group: "network_hosts" }

View File

@@ -0,0 +1,5 @@
---
deprecations:
- The ``openstack_host_apt_packages`` variable has been deprecated.
``openstack_host_packages`` should be used instead to override
packages required to install on all OpenStack hosts.

View File

@@ -39,6 +39,6 @@
until: install_packages|success
retries: 5
delay: 2
with_items: openstack_host_apt_packages
with_items: "{{ openstack_host_packages | deprecated(openstack_host_apt_packages, 'openstack_host_apt_packages', 'openstack_host_packages', 'Ocata') }}"
tags:
- openstack-apt-packages

View File

@@ -21,7 +21,7 @@
until: install_packages|success
retries: 5
delay: 2
with_items: openstack_host_yum_packages
with_items: "{{ openstack_host_packages }}"
tags:
- openstack-yum-packages
- openstack-packages

View File

@@ -16,15 +16,19 @@
- name: "Ensure kernel module(s)"
modprobe:
name: "{{ item }}"
with_items: openstack_host_kernel_modules
when: openstack_host_kernel_modules is defined and item != ''
with_items: "{{ openstack_host_kernel_modules }}"
when:
- openstack_host_kernel_modules | length > 0
- item != ''
- name: "Ensure kernel module(s) loaded at boot"
lineinfile:
dest: /etc/modules
line: "{{ item }}"
with_items: openstack_host_kernel_modules
when: openstack_host_kernel_modules is defined and item != ''
with_items: "{{ openstack_host_kernel_modules }}"
when:
- openstack_host_kernel_modules | length > 0
- item != ''
- name: get kernel release
command: "uname -r"
@@ -33,33 +37,33 @@
- name: check how kernel modules are implemented (statically builtin, dynamic, not set)
shell: grep {{ item.pattern }} /boot/config-{{ uname.stdout}}
register: modules
with_items: openstack_host_specific_kernel_modules
with_items: "{{ openstack_host_specific_kernel_modules }}"
when:
- openstack_host_specific_kernel_modules is defined
- openstack_host_specific_kernel_modules | length > 0
- inventory_hostname in groups["{{ item.group }}"]
ignore_errors: yes
- name: fail if a specific kernel module is not set
fail:
msg: "{{ item['stdout'] }}"
with_items: "{{ modules['results'] | default([]) }}"
when:
- modules['changed'] | bool
- "'is not set' in item['stdout']"
with_items: modules["results"]
- name: fail if a specific pattern is not valid
fail:
msg: "'pattern:' {{ item['item']['pattern'] }} 'is not valid. Search results for pattern lead to:' {{ item['stdout'] }}"
with_items: "{{ modules['results'] | default([]) }}"
when:
- modules['changed'] | bool
- "'=y' not in item['stdout']"
- "'=m' not in item['stdout']"
with_items: modules["results"]
- name: "Ensure dynamic specific kernel module(s) are loaded"
modprobe:
name: "{{ item['item']['name'] }}"
with_items: modules["results"]
with_items: "{{ modules['results'] | default([]) }}"
when:
- modules['changed'] | bool
- inventory_hostname in groups[item["item"]["group"]]
@@ -69,7 +73,7 @@
lineinfile:
dest: /etc/modules
line: "{{ item['item']['name'] }}"
with_items: modules["results"]
with_items: "{{ modules['results'] | default([]) }}"
when:
- modules['changed'] | bool
- inventory_hostname in groups[item["item"]["group"]]

View File

@@ -20,5 +20,5 @@
sysctl_set: "{{ item.set|default('yes') }}"
state: "{{ item.state|default('present') }}"
reload: "{{ item.reload|default('yes') }}"
with_items: openstack_kernel_options
with_items: "{{ openstack_kernel_options }}"
ignore_errors: true

View File

@@ -43,7 +43,7 @@ openstack_host_kernel_modules:
- x_tables
## Base packages
openstack_host_yum_packages:
openstack_host_packages:
- bridge-utils
- '@Development Tools'
- curl

View File

@@ -50,7 +50,7 @@ openstack_host_kernel_modules:
- x_tables
## Base packages
openstack_host_apt_packages:
openstack_host_packages:
- apparmor-utils
- apt-transport-https
- bridge-utils

View File

@@ -45,7 +45,7 @@ openstack_host_kernel_modules:
- x_tables
## Base packages
openstack_host_apt_packages:
openstack_host_packages:
- apparmor-utils
- apt-transport-https
- bridge-utils