From 5548a1ff5a2da97d27d410bc88cdf58d4500c971 Mon Sep 17 00:00:00 2001
From: Emiliano Vavassori <syntaxerrormmm@gmail.com>
Date: Tue, 12 Jul 2016 22:00:25 +0200
Subject: [PATCH] Generalizing the edu package to be installed via preseed.

---
 domain.yml                                              | 1 +
 roles/preseed/defaults/main.yml                         | 1 +
 roles/preseed/tasks/preseed.yml                         | 5 +++++
 roles/preseed/templates/preseed/client-trusty.seed      | 4 ++--
 roles/preseed/templates/preseed/dev/client-trusty.seed  | 4 ++--
 roles/preseed/templates/preseed/dev/docenti-trusty.seed | 4 ++--
 roles/preseed/templates/preseed/docenti-trusty.seed     | 4 ++--
 roles/preseed/templates/preseed/edubuntu.seed           | 4 ++--
 8 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/domain.yml b/domain.yml
index 99017c0..205d573 100644
--- a/domain.yml
+++ b/domain.yml
@@ -20,6 +20,7 @@ org_department: "Laboratorio 1"
 org_city: Caravaggio
 org_phone: "+39 0363 50598"
 org_street: "Via Zenale e Butinone, 20"
+edu_package: secondary
 mirror_mode: remote
 #mirror_nfs_share: 192.168.255.1:/var/spool/apt-mirror/mirror
 mirror_host: it.archive.ubuntu.com
diff --git a/roles/preseed/defaults/main.yml b/roles/preseed/defaults/main.yml
index 798bb27..265a1ed 100644
--- a/roles/preseed/defaults/main.yml
+++ b/roles/preseed/defaults/main.yml
@@ -1,5 +1,6 @@
 ---
 # Defaults for installation
+edu_package: secondary
 mirror_mode: local
 mirror_host: archive.ubuntu.com
 mirror_path: /ubuntu
diff --git a/roles/preseed/tasks/preseed.yml b/roles/preseed/tasks/preseed.yml
index 677e472..276b30c 100644
--- a/roles/preseed/tasks/preseed.yml
+++ b/roles/preseed/tasks/preseed.yml
@@ -1,5 +1,10 @@
 ---
 
+- name: Configure the edu-package following settings in domain.yml
+  set_fact:
+    edu_package: "{{ ansible_local.domain.edu_package }}"
+  when: ansible_local.domain.edu_package is defined
+
 - name: Verifica configurazione ibay preseed
   shell: /sbin/e-smith/db accounts show ks
   register: chk_ks_created
diff --git a/roles/preseed/templates/preseed/client-trusty.seed b/roles/preseed/templates/preseed/client-trusty.seed
index 07d8d90..4151eeb 100644
--- a/roles/preseed/templates/preseed/client-trusty.seed
+++ b/roles/preseed/templates/preseed/client-trusty.seed
@@ -101,9 +101,9 @@ d-i	pkgsel/language-pack-patterns		string language-pack-gnome-$LL language-pack-
 
 # Adding libreoffice and ansible
 {% if ansible_bios_version == 'VirtualBox' %}
-d-i	pkgsel/include				string epoptes-client dialog vim screen cifs-utils curl git openssh-server software-properties-common sshpass ubuntu-edu-secondary python3-uno libreoffice ansible libnss-myhostname sysv-rc-conf unattended-upgrades update-notifier-common aptitude virtualbox-guest-dkms
+d-i	pkgsel/include				string epoptes-client dialog vim screen cifs-utils curl git openssh-server software-properties-common sshpass ubuntu-edu-{{ edu_package }} python3-uno libreoffice ansible libnss-myhostname sysv-rc-conf unattended-upgrades update-notifier-common aptitude virtualbox-guest-dkms
 {% else %}
-d-i	pkgsel/include				string epoptes-client dialog vim screen cifs-utils curl git openssh-server software-properties-common sshpass ubuntu-edu-secondary python3-uno libreoffice ansible libnss-myhostname sysv-rc-conf unattended-upgrades update-notifier-common aptitude
+d-i	pkgsel/include				string epoptes-client dialog vim screen cifs-utils curl git openssh-server software-properties-common sshpass ubuntu-edu-{{ edu_package }} python3-uno libreoffice ansible libnss-myhostname sysv-rc-conf unattended-upgrades update-notifier-common aptitude
 {% endif %}
 
 # Post installation tasks
diff --git a/roles/preseed/templates/preseed/dev/client-trusty.seed b/roles/preseed/templates/preseed/dev/client-trusty.seed
index bbe8af8..8a6763e 100644
--- a/roles/preseed/templates/preseed/dev/client-trusty.seed
+++ b/roles/preseed/templates/preseed/dev/client-trusty.seed
@@ -101,9 +101,9 @@ d-i	pkgsel/language-pack-patterns		string language-pack-gnome-$LL language-pack-
 
 # Adding libreoffice and ansible
 {% if ansible_bios_version == 'VirtualBox' %}
-d-i	pkgsel/include				string epoptes-client dialog vim screen cifs-utils curl git openssh-server software-properties-common sshpass ubuntu-edu-secondary python3-uno libreoffice ansible libnss-myhostname sysv-rc-conf unattended-upgrades update-notifier-common aptitude virtualbox-guest-dkms
+d-i	pkgsel/include				string epoptes-client dialog vim screen cifs-utils curl git openssh-server software-properties-common sshpass ubuntu-edu-{{ edu_package }} python3-uno libreoffice ansible libnss-myhostname sysv-rc-conf unattended-upgrades update-notifier-common aptitude virtualbox-guest-dkms
 {% else %}
-d-i	pkgsel/include				string epoptes-client dialog vim screen cifs-utils curl git openssh-server software-properties-common sshpass ubuntu-edu-secondary python3-uno libreoffice ansible libnss-myhostname sysv-rc-conf unattended-upgrades update-notifier-common aptitude
+d-i	pkgsel/include				string epoptes-client dialog vim screen cifs-utils curl git openssh-server software-properties-common sshpass ubuntu-edu-{{ edu_package }} python3-uno libreoffice ansible libnss-myhostname sysv-rc-conf unattended-upgrades update-notifier-common aptitude
 {% endif %}
 
 # Post installation tasks
diff --git a/roles/preseed/templates/preseed/dev/docenti-trusty.seed b/roles/preseed/templates/preseed/dev/docenti-trusty.seed
index 4ae318a..a45766a 100644
--- a/roles/preseed/templates/preseed/dev/docenti-trusty.seed
+++ b/roles/preseed/templates/preseed/dev/docenti-trusty.seed
@@ -101,9 +101,9 @@ d-i	pkgsel/language-pack-patterns		string language-pack-gnome-$LL language-pack-
 
 # Adding libreoffice and ansible
 {% if ansible_bios_version == 'VirtualBox' %}
-d-i	pkgsel/include				string epoptes dialog vim screen cifs-utils curl git openssh-server software-properties-common sshpass ubuntu-edu-secondary python3-uno libreoffice ansible libnss-myhostname sysv-rc-conf unattended-upgrades update-notifier-common aptitude virtualbox-guest-dkms
+d-i	pkgsel/include				string epoptes dialog vim screen cifs-utils curl git openssh-server software-properties-common sshpass ubuntu-edu-{{ edu_package }} python3-uno libreoffice ansible libnss-myhostname sysv-rc-conf unattended-upgrades update-notifier-common aptitude virtualbox-guest-dkms
 {% else %}
-d-i	pkgsel/include				string epoptes dialog vim screen cifs-utils curl git openssh-server software-properties-common sshpass ubuntu-edu-secondary python3-uno libreoffice ansible libnss-myhostname sysv-rc-conf unattended-upgrades update-notifier-common aptitude
+d-i	pkgsel/include				string epoptes dialog vim screen cifs-utils curl git openssh-server software-properties-common sshpass ubuntu-edu-{{ edu_package }} python3-uno libreoffice ansible libnss-myhostname sysv-rc-conf unattended-upgrades update-notifier-common aptitude
 {% endif %}
 
 # Post installation tasks
diff --git a/roles/preseed/templates/preseed/docenti-trusty.seed b/roles/preseed/templates/preseed/docenti-trusty.seed
index 163ba33..51672b8 100644
--- a/roles/preseed/templates/preseed/docenti-trusty.seed
+++ b/roles/preseed/templates/preseed/docenti-trusty.seed
@@ -101,9 +101,9 @@ d-i	pkgsel/language-pack-patterns		string language-pack-gnome-$LL language-pack-
 
 # Adding libreoffice and ansible
 {% if ansible_bios_version == 'VirtualBox' %}
-d-i	pkgsel/include				string epoptes dialog vim screen cifs-utils curl git openssh-server software-properties-common sshpass ubuntu-edu-secondary python3-uno libreoffice ansible libnss-myhostname sysv-rc-conf unattended-upgrades update-notifier-common aptitude virtualbox-guest-dkms
+d-i	pkgsel/include				string epoptes dialog vim screen cifs-utils curl git openssh-server software-properties-common sshpass ubuntu-edu-{{ edu_package }} python3-uno libreoffice ansible libnss-myhostname sysv-rc-conf unattended-upgrades update-notifier-common aptitude virtualbox-guest-dkms
 {% else %}
-d-i	pkgsel/include				string epoptes dialog vim screen cifs-utils curl git openssh-server software-properties-common sshpass ubuntu-edu-secondary python3-uno libreoffice ansible libnss-myhostname sysv-rc-conf unattended-upgrades update-notifier-common aptitude
+d-i	pkgsel/include				string epoptes dialog vim screen cifs-utils curl git openssh-server software-properties-common sshpass ubuntu-edu-{{ edu_package }} python3-uno libreoffice ansible libnss-myhostname sysv-rc-conf unattended-upgrades update-notifier-common aptitude
 {% endif %}
 
 # Post installation tasks
diff --git a/roles/preseed/templates/preseed/edubuntu.seed b/roles/preseed/templates/preseed/edubuntu.seed
index 5f9be93..edf3988 100644
--- a/roles/preseed/templates/preseed/edubuntu.seed
+++ b/roles/preseed/templates/preseed/edubuntu.seed
@@ -97,9 +97,9 @@ d-i	pkgsel/language-pack-patterns		string language-pack-gnome-$LL language-pack-
 
 # Adding libreoffice and ansible
 {% if ansible_bios_version == 'VirtualBox' %}
-d-i	pkgsel/include				string openssh-server libreoffice ansible vim screen git curl cifs-utils ubuntu-edu-secondary libnss-myhostname geogebra geogebra-gnome sysv-rc-conf virtualbox-guest-dkms
+d-i	pkgsel/include				string openssh-server libreoffice ansible vim screen git curl cifs-utils ubuntu-edu-{{ edu_package }} libnss-myhostname geogebra geogebra-gnome sysv-rc-conf virtualbox-guest-dkms
 {% else %}
-d-i	pkgsel/include				string openssh-server libreoffice ansible vim screen git curl cifs-utils ubuntu-edu-secondary libnss-myhostname geogebra geogebra-gnome sysv-rc-conf
+d-i	pkgsel/include				string openssh-server libreoffice ansible vim screen git curl cifs-utils ubuntu-edu-{{ edu_package }} libnss-myhostname geogebra geogebra-gnome sysv-rc-conf
 {% endif %}
 
 # Post installation tasks