From b70a0276f4a30143bc1276d8c76a354c0c2b15f6 Mon Sep 17 00:00:00 2001 From: Logan V Date: Fri, 28 Oct 2016 13:47:30 +0200 Subject: [PATCH] Update ansible-lint to 3.4.1 This patch updates all playbooks to ensure compliance with ansible-lint 3.4.1 and also implements updates to the distro/pip package install tasks to ensure that they use the appropriate variables designed for setting state. Additionally the utility playbook is set to use upper constraints when installing packages. Change-Id: I534388930317daf370cf6c943d62d1e50184ead9 --- playbooks/inventory/group_vars/utility_all.yml | 1 + playbooks/os-nova-install.yml | 4 ++-- playbooks/repo-build.yml | 5 +++-- playbooks/utility-install.yml | 10 ++++++---- tests/roles/bootstrap-host/tasks/install-apt.yml | 4 ++-- .../roles/bootstrap-host/tasks/prepare_aio_config.yml | 5 +++-- tests/roles/bootstrap-host/tasks/prepare_data_disk.yml | 2 +- .../bootstrap-host/tasks/prepare_loopback_cinder.yml | 9 ++++----- .../bootstrap-host/tasks/prepare_loopback_nova.yml | 2 +- .../bootstrap-host/tasks/prepare_loopback_swap.yml | 8 ++++---- .../bootstrap-host/tasks/prepare_loopback_swift.yml | 2 +- tox.ini | 4 ++-- 12 files changed, 30 insertions(+), 26 deletions(-) diff --git a/playbooks/inventory/group_vars/utility_all.yml b/playbooks/inventory/group_vars/utility_all.yml index cc1fda54ff..ad6a6e2257 100644 --- a/playbooks/inventory/group_vars/utility_all.yml +++ b/playbooks/inventory/group_vars/utility_all.yml @@ -38,6 +38,7 @@ tempest_service_available_swift: "{{ groups['swift_all'] is defined and groups[' # Ensure that the package state matches the global setting utility_package_state: "{{ package_state }}" +utility_pip_package_state: "latest" # Distribution packages to be installed into the utility container utility_distro_packages: diff --git a/playbooks/os-nova-install.yml b/playbooks/os-nova-install.yml index 31e5bf7d95..ab91ed924e 100644 --- a/playbooks/os-nova-install.yml +++ b/playbooks/os-nova-install.yml @@ -85,7 +85,7 @@ tags: - always - name: Add net/tun device to the compute - shell: | + command: | lxc-device -n {{ container_name }} add /dev/net/tun /dev/net/tun delegate_to: "{{ physical_host }}" when: @@ -104,7 +104,7 @@ tags: - always - name: Add kvm device to the compute - shell: | + command: | lxc-device -n {{ container_name }} add /dev/kvm /dev/kvm delegate_to: "{{ physical_host }}" register: device_add diff --git a/playbooks/repo-build.yml b/playbooks/repo-build.yml index a9f228f0e8..7e92ce60ad 100644 --- a/playbooks/repo-build.yml +++ b/playbooks/repo-build.yml @@ -21,7 +21,8 @@ key: repo_servers_{{ ansible_architecture }} tags: - always - - local_action: + - name: Prepare group of master repo servers + local_action: module: "add_host" name: "{{ item }}" groups: "repo_nodes" @@ -70,7 +71,7 @@ - _local_git_cache.stat.exists - name: Check if the repo container bind mount is empty - local_action: shell + local_action: command ls -1A {{ repo_build_git_bind_mount }} register: _local_repo_bind_mount_contents when: diff --git a/playbooks/utility-install.yml b/playbooks/utility-install.yml index 0f383113f0..8bb661a5b8 100644 --- a/playbooks/utility-install.yml +++ b/playbooks/utility-install.yml @@ -59,14 +59,14 @@ - name: Install apt packages apt: pkg: "{{ item }}" - state: latest + state: "{{ utility_package_state }}" with_items: "{{ utility_distro_packages | default([]) }}" when: ansible_pkg_mgr == 'apt' - name: Install yum packages yum: pkg: "{{ item }}" - state: latest + state: "{{ utility_package_state }}" with_items: "{{ utility_distro_packages | default([]) }}" when: ansible_pkg_mgr == 'yum' @@ -82,8 +82,10 @@ - name: Install pip packages pip: name: "{{ client_list.stdout_lines | union(utility_pip_packages) | join(' ') }}" - state: latest - extra_args: "{{ pip_install_options|default('') }}" + state: "{{ utility_pip_package_state }}" + extra_args: >- + {{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }} + {{ pip_install_options | default('') }} register: install_packages until: install_packages|success retries: 5 diff --git a/tests/roles/bootstrap-host/tasks/install-apt.yml b/tests/roles/bootstrap-host/tasks/install-apt.yml index 09cfdb52cf..0a433ebfe0 100644 --- a/tests/roles/bootstrap-host/tasks/install-apt.yml +++ b/tests/roles/bootstrap-host/tasks/install-apt.yml @@ -21,7 +21,7 @@ - apt-install-prerequisites - name: Determine the existing Ubuntu repo configuration - shell: 'grep -oP "^deb \K(\[?.*\]?.*ubuntu\S*\/?)(?= {{ ansible_distribution_release }} main)" /etc/apt/sources.list' + command: 'grep -oP "^deb \K(\[?.*\]?.*ubuntu\S*\/?)(?= {{ ansible_distribution_release }} main)" /etc/apt/sources.list' register: ubuntu_repo when: - bootstrap_host_ubuntu_repo is not defined @@ -30,7 +30,7 @@ - find-apt-repo - name: Determine the existing Ubuntu Security repo configuration - shell: 'grep -oP "^deb \K(\[?.*\]?.*ubuntu\S*\/?)(?= {{ ansible_distribution_release }}-security main)" /etc/apt/sources.list' + command: 'grep -oP "^deb \K(\[?.*\]?.*ubuntu\S*\/?)(?= {{ ansible_distribution_release }}-security main)" /etc/apt/sources.list' register: ubuntu_security_repo when: - bootstrap_host_ubuntu_security_repo is not defined diff --git a/tests/roles/bootstrap-host/tasks/prepare_aio_config.yml b/tests/roles/bootstrap-host/tasks/prepare_aio_config.yml index 90ce767360..0eefdd3801 100644 --- a/tests/roles/bootstrap-host/tasks/prepare_aio_config.yml +++ b/tests/roles/bootstrap-host/tasks/prepare_aio_config.yml @@ -55,7 +55,8 @@ - deploy-user-secrets - name: Generate any missing values in user_secrets - shell: ../scripts/pw-token-gen.py --file /etc/openstack_deploy/user_secrets.yml + command: ../scripts/pw-token-gen.py --file /etc/openstack_deploy/user_secrets.yml + changed_when: false tags: - generate_secrets @@ -84,7 +85,7 @@ register: pip_conf_file - name: Determine the fastest available OpenStack-Infra wheel mirror - shell: ../scripts/fastest-infra-wheel-mirror.py + command: ../scripts/fastest-infra-wheel-mirror.py register: fastest_wheel_mirror when: not pip_conf_file.stat.exists diff --git a/tests/roles/bootstrap-host/tasks/prepare_data_disk.yml b/tests/roles/bootstrap-host/tasks/prepare_data_disk.yml index 89284c7184..8cfd01c325 100644 --- a/tests/roles/bootstrap-host/tasks/prepare_data_disk.yml +++ b/tests/roles/bootstrap-host/tasks/prepare_data_disk.yml @@ -40,7 +40,7 @@ - "{{ ansible_mounts }}" - name: Partition the whole data disk for our usage - shell: "{{ item }}" + command: "{{ item }}" when: data_disk_partitions.rc == 1 or bootstrap_host_data_disk_device_force | bool with_items: - "parted --script /dev/{{ bootstrap_host_data_disk_device | regex_replace('!','/') }} mklabel gpt" diff --git a/tests/roles/bootstrap-host/tasks/prepare_loopback_cinder.yml b/tests/roles/bootstrap-host/tasks/prepare_loopback_cinder.yml index a1901a1adf..493b23c967 100644 --- a/tests/roles/bootstrap-host/tasks/prepare_loopback_cinder.yml +++ b/tests/roles/bootstrap-host/tasks/prepare_loopback_cinder.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Create sparse Cinder file - shell: "truncate -s {{ bootstrap_host_loopback_cinder_size }}G /openstack/cinder.img" + command: "truncate -s {{ bootstrap_host_loopback_cinder_size }}G /openstack/cinder.img" args: creates: /openstack/cinder.img register: cinder_create @@ -22,14 +22,14 @@ - cinder-file-create - name: Get a loopback device for cinder file - shell: losetup -f + command: losetup -f when: cinder_create | changed register: cinder_losetup tags: - cinder-device-get - name: Create the loopback device - shell: "losetup {{ cinder_losetup.stdout }} /openstack/cinder.img" + command: "losetup {{ cinder_losetup.stdout }} /openstack/cinder.img" when: cinder_create | changed tags: - cinder-device-create @@ -55,7 +55,7 @@ - cinder-rc-config - name: Make LVM physical volume on the cinder device - shell: "{{ item }}" + command: "{{ item }}" when: cinder_create | changed with_items: - "pvcreate {{ cinder_losetup.stdout }}" @@ -70,4 +70,3 @@ when: cinder_create | changed tags: - cinder-lvm-vg - diff --git a/tests/roles/bootstrap-host/tasks/prepare_loopback_nova.yml b/tests/roles/bootstrap-host/tasks/prepare_loopback_nova.yml index 609e3a46b8..37a6f899de 100644 --- a/tests/roles/bootstrap-host/tasks/prepare_loopback_nova.yml +++ b/tests/roles/bootstrap-host/tasks/prepare_loopback_nova.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Create sparse Nova file - shell: "truncate -s {{ bootstrap_host_loopback_nova_size }}G /openstack/nova.img" + command: "truncate -s {{ bootstrap_host_loopback_nova_size }}G /openstack/nova.img" args: creates: /openstack/nova.img register: nova_create diff --git a/tests/roles/bootstrap-host/tasks/prepare_loopback_swap.yml b/tests/roles/bootstrap-host/tasks/prepare_loopback_swap.yml index 14f83e8155..7eb0ea0ef2 100644 --- a/tests/roles/bootstrap-host/tasks/prepare_loopback_swap.yml +++ b/tests/roles/bootstrap-host/tasks/prepare_loopback_swap.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Create swap file - shell: "fallocate -l {{ bootstrap_host_swap_size }}G /openstack/swap.img" + command: "fallocate -l {{ bootstrap_host_swap_size }}G /openstack/swap.img" args: creates: /openstack/swap.img register: swap_create @@ -29,7 +29,7 @@ - swap-permissions - name: Format the swap file - shell: mkswap /openstack/swap.img + command: mkswap /openstack/swap.img when: swap_create | changed tags: - swap-format @@ -47,7 +47,8 @@ - swap-fstab - name: Bring swap file online - shell: swapon /openstack/swap.img + command: swapon /openstack/swap.img + changed_when: false tags: - swap-online @@ -58,4 +59,3 @@ state: present tags: - swap-sysctl - diff --git a/tests/roles/bootstrap-host/tasks/prepare_loopback_swift.yml b/tests/roles/bootstrap-host/tasks/prepare_loopback_swift.yml index c856cbf18f..4901942da2 100644 --- a/tests/roles/bootstrap-host/tasks/prepare_loopback_swift.yml +++ b/tests/roles/bootstrap-host/tasks/prepare_loopback_swift.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Create sparse Swift files - shell: "truncate -s {{ bootstrap_host_loopback_swift_size }}G /openstack/{{ item }}.img" + command: "truncate -s {{ bootstrap_host_loopback_swift_size }}G /openstack/{{ item }}.img" args: creates: "/openstack/{{ item }}.img" with_items: diff --git a/tox.ini b/tox.ini index cf6572498e..27d61544b9 100644 --- a/tox.ini +++ b/tox.ini @@ -90,8 +90,8 @@ commands = [testenv:ansible] deps = {[testenv]deps} - ansible==2.1.0 - ansible-lint>=2.7.0,<3.0.0 + ansible==2.2.0 + ansible-lint<=3.4.1 setenv = {[testenv]setenv} ANSIBLE_HOST_KEY_CHECKING = False