From be8824d261be72ae71de8bc7f408a1101647858b Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Tue, 14 Jun 2016 18:26:14 +0100 Subject: [PATCH] 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 --- defaults/main.yml | 1 + ...ck-host-apt-packages-b4d7af53d55d980d.yaml | 5 ++++ tasks/openstack_host_install_apt.yml | 2 +- tasks/openstack_host_install_yum.yml | 2 +- tasks/openstack_kernel_modules.yml | 24 +++++++++++-------- tasks/openstack_kernel_tuning.yml | 2 +- vars/redhat-7.yml | 2 +- vars/ubuntu-14.04.yml | 2 +- vars/ubuntu-16.04.yml | 2 +- 9 files changed, 26 insertions(+), 16 deletions(-) create mode 100644 releasenotes/notes/deprecate-openstack-host-apt-packages-b4d7af53d55d980d.yaml diff --git a/defaults/main.yml b/defaults/main.yml index b8a872e6..3d67b927 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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" } diff --git a/releasenotes/notes/deprecate-openstack-host-apt-packages-b4d7af53d55d980d.yaml b/releasenotes/notes/deprecate-openstack-host-apt-packages-b4d7af53d55d980d.yaml new file mode 100644 index 00000000..c1c1f1eb --- /dev/null +++ b/releasenotes/notes/deprecate-openstack-host-apt-packages-b4d7af53d55d980d.yaml @@ -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. diff --git a/tasks/openstack_host_install_apt.yml b/tasks/openstack_host_install_apt.yml index bb80b581..f4db8aae 100644 --- a/tasks/openstack_host_install_apt.yml +++ b/tasks/openstack_host_install_apt.yml @@ -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 diff --git a/tasks/openstack_host_install_yum.yml b/tasks/openstack_host_install_yum.yml index a62e7e70..e8702dfc 100644 --- a/tasks/openstack_host_install_yum.yml +++ b/tasks/openstack_host_install_yum.yml @@ -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 diff --git a/tasks/openstack_kernel_modules.yml b/tasks/openstack_kernel_modules.yml index f578042a..4d668c3a 100644 --- a/tasks/openstack_kernel_modules.yml +++ b/tasks/openstack_kernel_modules.yml @@ -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"]] diff --git a/tasks/openstack_kernel_tuning.yml b/tasks/openstack_kernel_tuning.yml index d47c1f1c..b1c3de5a 100644 --- a/tasks/openstack_kernel_tuning.yml +++ b/tasks/openstack_kernel_tuning.yml @@ -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 diff --git a/vars/redhat-7.yml b/vars/redhat-7.yml index af7e2d1b..c7e7f1f2 100644 --- a/vars/redhat-7.yml +++ b/vars/redhat-7.yml @@ -43,7 +43,7 @@ openstack_host_kernel_modules: - x_tables ## Base packages -openstack_host_yum_packages: +openstack_host_packages: - bridge-utils - '@Development Tools' - curl diff --git a/vars/ubuntu-14.04.yml b/vars/ubuntu-14.04.yml index b4569c11..89072be0 100644 --- a/vars/ubuntu-14.04.yml +++ b/vars/ubuntu-14.04.yml @@ -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 diff --git a/vars/ubuntu-16.04.yml b/vars/ubuntu-16.04.yml index af8e0eaf..ea73bca1 100644 --- a/vars/ubuntu-16.04.yml +++ b/vars/ubuntu-16.04.yml @@ -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