From 72ee94acce62f79928e665206cb27437b967c4bf Mon Sep 17 00:00:00 2001 From: Johan Guldmyr Date: Wed, 20 Nov 2019 11:18:03 +0200 Subject: [PATCH] Put the package dependencies in variables Fix this warning:
Invoking "apt" only once while using a loop via
squash_actions is deprecated. Instead of using a loop to supply multiple
items
and specifying `name: "{{item}}"`, please use `name:
Also some bonus ansible-lint fixes around {{ whitespaces }} --- defaults/main.yml | 31 ++++++++++++++++++++++++++++++ tasks/main.yml | 49 +++++++++++------------------------------------ 2 files changed, 42 insertions(+), 38 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 060c75d..267d2cb 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -14,3 +14,34 @@ rally_install_args: "--branch {{ rally_install_version }}" rally_verify_purger_cron_enabled: False rally_verify_purger_arguments: "-p cron -s 90 -n 5" + +rally_yum_dependencies: + - "python2-pip" + - "wget" + - "sqlite" + - "python-devel" + - "openssl-devel" + - "git" + - "libffi-devel" + - "gcc" + - "libxml2-devel" + - "libxslt-devel" + - "gmp-devel" + - "postgresql-devel" + - "redhat-rpm-config" + +rally_deb_dependencies: + - "python-pip" + - "python-setuptools" + - "wget" + - "sqlite" + - "python-dev" + - "libpython-dev" + - "libssl-dev" + - "git" + - "libffi-dev" + - "build-essential" + - "libxml2-dev" + - "libxslt-dev" + - "libpq-dev" + - "iputils-ping" diff --git a/tasks/main.yml b/tasks/main.yml index 5804226..42a8c55 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -10,45 +10,18 @@ var: rally_bin verbosity: 1 -- name: Install dependencies Centos +- name: Install dependencies CentOS yum: - name: "{{item}}" + name: "{{ rally_yum_dependencies }}" state: installed - with_items: - - "python2-pip" - - "wget" - - "sqlite" - - "python-devel" - - "openssl-devel" - - "git" - - "libffi-devel" - - "gcc" - - "libxml2-devel" - - "libxslt-devel" - - "gmp-devel" - - "postgresql-devel" - - "redhat-rpm-config" - when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' and not rally_bin.stat.exists + when: + - (ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux') + - not rally_bin.stat.exists - name: Install dependencies Ubuntu apt: - name: "{{item}}" - state: installed - with_items: - - "python-pip" - - "python-setuptools" - - "wget" - - "sqlite" - - "python-dev" - - "libpython-dev" - - "libssl-dev" - - "git" - - "libffi-dev" - - "build-essential" - - "libxml2-dev" - - "libxslt-dev" - - "libpq-dev" - - "iputils-ping" + name: "{{ rally_deb_dependencies }}" + state: present when: ansible_distribution == 'Ubuntu' and not rally_bin.stat.exists - name: Create group for Rally @@ -71,7 +44,7 @@ - name: Create Rally directories file: - path: "{{item.path}}" + path: "{{ item.path }}" state: directory owner: rally group: rally @@ -167,15 +140,15 @@ path: "/home/rally/rally/etc/rally/rally.conf" section: openstack option: swift_operator_role - value: "{{rally_tempest_swift_operator_role}}" + value: "{{ rally_tempest_swift_operator_role }}" when: rally_tempest_swift_operator_role is defined - name: Rally configure swift reseller admin role become: True become_user: rally - ini_file: + ini_file: path: "/home/rally/rally/etc/rally/rally.conf" section: openstack option: "swift_reseller_admin_role" - value: "{{rally_tempest_swift_reseller_admin_role}}" + value: "{{ rally_tempest_swift_reseller_admin_role }}" when: rally_tempest_swift_reseller_admin_role is defined