Update apt cache before installing scsitools

A few folks reported that installing scsitools was throwning an error
for them because the apt cache on the system hadn't been initialized.
This patch ensures that we update the apt cache before attempting to
install scsitools.

The patch also makes the workload run faster overall: previously,
we updated the apt cache each time we installed a package.  In this
patch, we break out the cache update into a separate task that runs
before any software is installed, thus eliminating several
time-consuming calls to "apt-get update".

Finally, this patch also makes the workload slightly more portable:
it replaces apt calls with package calls.  Adding a new guest OS
family should just require adding a new cache update block (if
necessary for that OS) with an appropriate when statement.

Change-Id: I30ffbf2da13f22475f920328d84e64460834bcdb
This commit is contained in:
Mark T. Voelker 2016-10-14 12:13:10 -04:00
parent f426660f75
commit 4d4514e2d2
1 changed files with 6 additions and 8 deletions

View File

@ -2,6 +2,10 @@
- stat: path=/tmp/diskflag
register: diskflag
- name: update apt cache
apt: update_cache=yes
when: ansible_os_family == "Debian"
- name: install scsitools
package: name=scsitools state=latest
@ -32,10 +36,7 @@
file: path=/var/lib/mysql state=directory
- name: Install NFS server
apt:
name=nfs-kernel-server
state=latest
update_cache=yes
package: name=nfs-kernel-server state=latest
- name: Setup NFS database access
lineinfile:
@ -65,10 +66,7 @@
fstype: nfs
- name: Install mysql and libraries
apt:
name="{{ item }}"
state=latest
update_cache=yes
package: name={{ item }} state=latest
with_items:
- mysql-server
- python-mysqldb