From 3ae6f5a86b2ed9a622fab64fb9b9ae24b7fd9b61 Mon Sep 17 00:00:00 2001
From: Robin Sonnabend <robin@fsmpi.rwth-aachen.de>
Date: Wed, 17 Oct 2018 17:02:50 +0200
Subject: [PATCH] Remove with_items from apt

---
 apcupsd/tasks/main.yml        |  2 +-
 baremetal/tasks/main.yml      | 13 +++--
 branding/tasks/main.yml       |  1 -
 cups-client/tasks/main.yml    |  9 ++--
 debian-updates/tasks/main.yml | 11 ++---
 management/tasks/main.yml     | 30 ++++++------
 nullmailer/tasks/main.yml     | 36 +++++++-------
 texlive/tasks/main.yml        | 92 +++++++++++++++++------------------
 8 files changed, 96 insertions(+), 98 deletions(-)

diff --git a/apcupsd/tasks/main.yml b/apcupsd/tasks/main.yml
index 2949adc..013af18 100644
--- a/apcupsd/tasks/main.yml
+++ b/apcupsd/tasks/main.yml
@@ -2,7 +2,7 @@
 # file: roles/baremetal/tasks/apcupsd.yml
 
 - name: ensure apcupsd is installed
-  apt: state=latest name=apcupsd
+  apt: state=present name=apcupsd
   notify:
     - restart apcupsd
   tags:
diff --git a/baremetal/tasks/main.yml b/baremetal/tasks/main.yml
index a6df523..2ff7227 100644
--- a/baremetal/tasks/main.yml
+++ b/baremetal/tasks/main.yml
@@ -3,14 +3,13 @@
 
 - name: ensure baremetal-specific packages are installed
   apt:
-    name: "{{ item }}"
+    name:
+      - lldpd
+      - lm-sensors
+      - hddtemp
+      - smartmontools
+      - hdparm
     state: present
-  with_items:
-    - lldpd
-    - lm-sensors
-    - hddtemp
-    - smartmontools
-    - hdparm
   tags:
     - baremetal
     - packages
diff --git a/branding/tasks/main.yml b/branding/tasks/main.yml
index 4826bf4..c6585e6 100644
--- a/branding/tasks/main.yml
+++ b/branding/tasks/main.yml
@@ -82,7 +82,6 @@
   apt:
     name: apt-transport-https
     state: present
-  with_items: "{{ branding_apt_repos }}"
   when:
     - branding_apt_repos is defined
     - item|truncate(5, True, '') == "https"
diff --git a/cups-client/tasks/main.yml b/cups-client/tasks/main.yml
index 63830f0..7965918 100644
--- a/cups-client/tasks/main.yml
+++ b/cups-client/tasks/main.yml
@@ -2,10 +2,11 @@
 # file: roles/cups-client/tasks/main.yml
 
 - name: ensure cups-client is installed
-  apt: name="{{item}}" state=latest
-  with_items:
-    - cups-client
-    - cups-bsd
+  apt:
+    name:
+      - cups-client
+      - cups-bsd
+    state: latest
   tags:
     - cups-client
     - packages
diff --git a/debian-updates/tasks/main.yml b/debian-updates/tasks/main.yml
index cc8548c..e111da5 100644
--- a/debian-updates/tasks/main.yml
+++ b/debian-updates/tasks/main.yml
@@ -3,13 +3,12 @@
 
 - name: ensure any dependencies are available
   apt:
-    name: "{{ item }}"
+    name:
+      - python3
+      - fortune-mod
+      - fortunes
+      - fortunes-off
     state: present
-  with_items:
-    - python3
-    - fortune-mod
-    - fortunes
-    - fortunes-off
   tags:
     - debian-updates
 
diff --git a/management/tasks/main.yml b/management/tasks/main.yml
index 45f95e9..d03f7c3 100644
--- a/management/tasks/main.yml
+++ b/management/tasks/main.yml
@@ -2,17 +2,16 @@
 
 - name: ensure required software for ansible is installed
   apt:
-    name: "{{ item }}"
+    name:
+      - python-yaml
+      - python-jinja2
+      - python-paramiko
+      - python-cryptography
+      - python-sphinx # documentation
+      - python-packaging
+      - asciidoc # documentation
+      - squashfs-tools # needed for guest-overlay
     state: present
-  with_items:
-    - python-yaml
-    - python-jinja2
-    - python-paramiko
-    - python-cryptography
-    - python-sphinx # documentation
-    - python-packaging
-    - asciidoc # documentation
-    - squashfs-tools # needed for guest-overlay
   tags:
     - management
     - ansible
@@ -59,12 +58,11 @@
 
 - name: ensure we have the necessary packages for building packages
   apt:
-    name: "{{ item }}"
+    name:
+      - build-essential
+      - devscripts
+      - debhelper
+      - quilt
     state: present
-  with_items:
-    - build-essential
-    - devscripts
-    - debhelper
-    - quilt
   tags:
     - management
diff --git a/nullmailer/tasks/main.yml b/nullmailer/tasks/main.yml
index b3529d5..7d5ad37 100644
--- a/nullmailer/tasks/main.yml
+++ b/nullmailer/tasks/main.yml
@@ -10,23 +10,25 @@
     - nullmailer
 
 - name: ensure other smtp daemons are uninstalled
-  apt: name={{ item }} state=absent purge=yes
-  with_items:
-    - exim4
-    - postfix
-    - citadel-mta
-    - courier-mta
-    - esmtp-run
-    - lsb-invalid-mta
-    - masqmail
-    - msmtp-mta
-    - postfix
-    - qmail-run
-    - sendmail-bin
-    - ssmtp
-    - dma
-    - exim4-daemon-heavy
-    - exim4-daemon-light
+  apt:
+    state: absent
+    purge: yes
+    name:
+      - exim4
+      - postfix
+      - citadel-mta
+      - courier-mta
+      - esmtp-run
+      - lsb-invalid-mta
+      - masqmail
+      - msmtp-mta
+      - postfix
+      - qmail-run
+      - sendmail-bin
+      - ssmtp
+      - dma
+      - exim4-daemon-heavy
+      - exim4-daemon-light
   tags:
     - packages
     - nullmailer
diff --git a/texlive/tasks/main.yml b/texlive/tasks/main.yml
index 727b75e..8a5272e 100644
--- a/texlive/tasks/main.yml
+++ b/texlive/tasks/main.yml
@@ -4,68 +4,68 @@
 
 # this should be a real subset of texlive-full but not more than necessary
 - name: ensure texlive is installed
-  apt: name={{ item }} state=latest install_recommends=no
-  with_items:
-    - texlive-base
-    - texlive-games
-    - texlive-humanities
-    - texlive-math-extra
-    - texlive-music
-    - texlive-pictures
-    - texlive-publishers
-    - texlive-science
-    - texlive-xetex
-    - texlive-lang-german
-    - texlive-luatex
-    - texlive-bibtex-extra
-    - biber
+  apt:
+    name:
+      - texlive-base
+      - texlive-games
+      - texlive-humanities
+      - texlive-math-extra
+      - texlive-music
+      - texlive-pictures
+      - texlive-publishers
+      - texlive-science
+      - texlive-xetex
+      - texlive-lang-german
+      - texlive-luatex
+      - texlive-bibtex-extra
+      - biber
+    state: present
+    install_recommends: no
   tags:
     - texlive
     - packages
 
 - name: ensure some texlive recommandations are installed
-  apt: name={{ item }} state=latest install_recommends=no
-  with_items:
-    - ghostscript 
-    - lmodern 
-    - texlive-fonts-recommended-doc 
-    - tex-gyre
-    - texlive-humanities-doc 
-    - texlive-latex-base-doc 
-    - texlive-latex-extra-doc
-    - prosper
-    - texlive-latex-recommended-doc 
-    - texlive-pictures-doc 
-    - prerex 
-    - texlive-publishers-doc 
-    - texlive-science-doc
-    - libfile-mimeinfo-perl 
-    - libnet-dbus-perl 
-    - libx11-protocol-perl 
-    - x11-utils 
-    - x11-xserver-utils
-    - texlive-lang-greek
-    - fonts-cmu
-    - fonts-sil-charis
-    - texlive-fonts-extra
-    - texlive-generic-extra
+  apt:
+    name:
+      - ghostscript 
+      - lmodern 
+      - texlive-fonts-recommended-doc 
+      - tex-gyre
+      - texlive-humanities-doc 
+      - texlive-latex-base-doc 
+      - texlive-latex-extra-doc
+      - prosper
+      - texlive-latex-recommended-doc 
+      - texlive-pictures-doc 
+      - prerex 
+      - texlive-publishers-doc 
+      - texlive-science-doc
+      - libfile-mimeinfo-perl 
+      - libnet-dbus-perl 
+      - libx11-protocol-perl 
+      - x11-utils 
+      - x11-xserver-utils
+      - texlive-lang-greek
+      - fonts-cmu
+      - fonts-sil-charis
+      - texlive-fonts-extra
+      - texlive-generic-extra
+    state: present
+    install_recommends: no
   tags:
     - texlive
     - packages
 
 - name: ensure some texlive recommandations are installed for jessie
-  apt: name={{ item }} state=latest install_recommends=no
-  with_items:
-    - fonts-droid 
+  apt: name=fonts-droid state=latest install_recommends=no
   when: ansible_distribution_release == "jessie"
   tags:
     - texlive
     - packages
 
 - name: ensure some texlive recommandations are installed for stretch
-  apt: name={{ item }} state=latest install_recommends=no
-  with_items:
-    - fonts-droid-fallback
+  apt: name=fonts-droid-fallback state=latest install_recommends=no
   when: ansible_distribution_release == "stretch"
   tags:
     - texlive
-- 
GitLab