Refactor to install in a single transaction 16/9016/2
authorMohammed Naser <mnaser@vexxhost.com>
Fri, 23 Feb 2018 01:41:13 +0000 (20:41 -0500)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Fri, 23 Feb 2018 01:45:24 +0000 (20:45 -0500)
This patch moves the variables to the appropriate vars folder with
the correct ansible_os_family.  It lists all of the common packages
in main.yml and distro-specific in the respective YAML file.

It also makes the installation happen with a single transaction
by providing a list to the package module.

Change-Id: Ie9b955280ef488c1e938d2925f1bdf7a7e78ea1a
Signed-off-by: Mohammed Naser <mnaser@vexxhost.com>
tasks/main.yml
vars/Debian.yaml [new file with mode: 0644]
vars/RedHat.yaml [new file with mode: 0644]
vars/main.yml

index 5766028..3e68e4d 100644 (file)
@@ -1,34 +1,13 @@
 ---
-- name: Pull in package names
-  include_vars: "{{item}}"
+- name: Load operating-system specific variables
+  include_vars: "{{ item }}"
   with_first_found:
-    - 'pkg-names-{{ansible_distribution}}.yaml'
-    - 'pkg-names-{{ansible_os_family}}.yaml'
-    - 'pkg-names.yaml'
+    - "{{ ansible_os_family }}.yaml"
 
 - name: Install LF Recommended Tools
   package:
-    name: '{{item}}'
+    name: "{{ lf_recommended_tools_packages }}"
     state: present
-  with_items:
-    - ansible
-    - ant
-    - crudini
-    - facter
-    - git
-    - git-review
-    - graphviz
-    - jq
-    - sshpass
-    - sshuttle
-    - unzip
-    - xmlstarlet
-    - '{{pkg_gnu_parallel}}'
-    - '{{pkg_netcat}}'
-    - '{{pkg_perl_digest_sha}}'
-    - '{{pkg_perl_extutils_makemaker}}'
-    - '{{pkg_perl_xml_xpath}}'
-    - '{{pkg_xz}}'
   become: true
 
 - name: Install fedora-packager
diff --git a/vars/Debian.yaml b/vars/Debian.yaml
new file mode 100644 (file)
index 0000000..a7a34b6
--- /dev/null
@@ -0,0 +1,8 @@
+---
+lf_recommended_tools_packages_distro:
+  - parallel
+  - netcat
+  - libdigest-sha-perl
+  - libextutils-makemaker-cpanfile-perl
+  - libxml-xpath-perl
+  - xz-utils
diff --git a/vars/RedHat.yaml b/vars/RedHat.yaml
new file mode 100644 (file)
index 0000000..ce252e1
--- /dev/null
@@ -0,0 +1,8 @@
+---
+lf_recommended_tools_packages_distro:
+  - http://ftp.riken.jp/Linux/cern/centos/7/cern/x86_64/Packages/parallel-20150522-1.el7.cern.noarch.rpm
+  - nc
+  - perl-Digest-SHA
+  - perl-ExtUtils-MakeMaker
+  - perl-XML-XPath
+  - xz
index 24db448..70a738b 100644 (file)
@@ -1,2 +1,15 @@
 ---
-# vars file for lf-recommended-tools
+lf_recommended_tools_packages: "{{ lf_recommended_tools_packages_common }} + {{ lf_recommended_tools_packages_distro }}"
+lf_recommended_tools_packages_common:
+  - ansible
+  - ant
+  - crudini
+  - facter
+  - git
+  - git-review
+  - graphviz
+  - jq
+  - sshpass
+  - sshuttle
+  - unzip
+  - xmlstarlet