diff --git a/roles/preseed/tasks/preseed.yml b/roles/preseed/tasks/preseed.yml index 32d107a..474b633 100644 --- a/roles/preseed/tasks/preseed.yml +++ b/roles/preseed/tasks/preseed.yml @@ -50,10 +50,6 @@ with_items: - postseed-client.sh - postseed-docenti.sh - sudo: yes - -- name: Copia script per pulseaudio - copy: - src: preseed/pulseaudio-perms.sh - dest: /var/lib/nethserver/ibay/ks/preseed/pulseaudio-perms.sh + - pulseaudio-perms.sh + - checksum.fact sudo: yes diff --git a/roles/preseed/templates/preseed/checksum.fact b/roles/preseed/templates/preseed/checksum.fact new file mode 100644 index 0000000..61e2514 --- /dev/null +++ b/roles/preseed/templates/preseed/checksum.fact @@ -0,0 +1,54 @@ +#!/usr/bin/env python + +from subprocess import Popen, PIPE, STDOUT +from os.path import isfile +from json import dumps, loads +from hashlib import md5 +import requests + +repo_path = '/var/lib/{{ ansible_local.domain.domainfull }}/config' +pkgver_file = '/var/lib/{{ ansible_local.domain.domainfull }}/pkg-ver.txt' +repover_file = '/var/lib/{{ ansible_local.domain.domainfull }}/repo-ver.txt' + +local_pkg_hash = '' +local_repo_hash = '' + +live_repo_hash = '' +# Getting live versions for repo +p = Popen("bash -c \"pushd %s >/dev/null; git log --pretty=oneline -1 | cut -d' ' -f 1; popd > /dev/null\"" % repo_path, shell=True, stdout=PIPE, stderr=STDOUT) +live_repo_hash = p.communicate()[0].strip() + +live_pkg_hash = '' +# Recreating pkg checksum +r = requests.get("http://%s:3000/ansible_host" % '{{ ansible_local.domain.serverfqdn }}') +if r.status_code == 200: + response = loads(r.text.encode('ascii', 'ignore')) + retval = sorted(response['addpkg']) + [ '-' ] + sorted(response['delpkg']) + live_pkg_hash = md5("".join(retval)).hexdigest() + +if isfile(pkgver_file): + local_pkg_hash = open(pkgver_file, 'r').read().strip() + +if isfile(repover_file): + local_repo_hash = open(repover_file, 'r').read().strip() + +pkg_needed = False +repo_needed = False + +# Determining if run for packages and for configuraton has to be done +if local_pkg_hash != live_pkg_hash: + pkg_needed = True + +if local_repo_hash != live_repo_hash: + repo_needed = True + +retval = { + 'needs_repo_run': repo_needed, + 'repover': live_repo_hash, + 'repover_file': repover_file, + 'needs_pkg_run': pkg_needed, + 'pkgver': live_pkg_hash, + 'pkgver_file': pkgver_file +} + +print(dumps(retval)) diff --git a/roles/preseed/templates/preseed/client-trusty.seed b/roles/preseed/templates/preseed/client-trusty.seed index 143d21a..8d8fdb4 100644 --- a/roles/preseed/templates/preseed/client-trusty.seed +++ b/roles/preseed/templates/preseed/client-trusty.seed @@ -101,16 +101,16 @@ 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 dialog vim screen cifs-utils curl git openssh-server software-properties-common sshpass ubuntu-edu-secondary libreoffice ansible libnss-myhostname sysv-rc-conf 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-secondary libreoffice ansible libnss-myhostname sysv-rc-conf virtualbox-guest-dkms {% else %} -d-i pkgsel/include string dialog vim screen cifs-utils curl git openssh-server software-properties-common sshpass ubuntu-edu-secondary libreoffice ansible libnss-myhostname sysv-rc-conf +d-i pkgsel/include string epoptes-client dialog vim screen cifs-utils curl git openssh-server software-properties-common sshpass ubuntu-edu-secondary libreoffice ansible libnss-myhostname sysv-rc-conf {% endif %} # Post installation tasks # Update system d-i preseed/late_command string in-target apt-get -y upgrade; \ in-target apt-get -y dist-upgrade; \ - in-target apt-get -y purge libnss-mdns unity-webapps-common zeitgeist-core zeitgeist-datahub; \ + in-target apt-get -y purge libnss-mdns unity-webapps-common zeitgeist-core zeitgeist-datahub epoptes; \ in-target apt-get -y autoremove; \ sed -i'' -e 's/ubuntu/gnome-fallback/g' /target/usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf; \ in-target /bin/bash -c "curl -sSL http://{{ ansible_local.domain.serverfqdn }}/ks/preseed/postseed-client.sh | /bin/bash >/root/postseed.log 2>&1"; diff --git a/roles/preseed/templates/preseed/docenti-trusty.seed b/roles/preseed/templates/preseed/docenti-trusty.seed index cdbca44..7079964 100644 --- a/roles/preseed/templates/preseed/docenti-trusty.seed +++ b/roles/preseed/templates/preseed/docenti-trusty.seed @@ -101,16 +101,16 @@ 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 dialog vim screen cifs-utils curl git openssh-server software-properties-common sshpass ubuntu-edu-secondary libreoffice ansible libnss-myhostname sysv-rc-conf virtualbox-guest-dkms +d-i pkgsel/include string epoptes dialog vim screen cifs-utils curl git openssh-server software-properties-common sshpass ubuntu-edu-secondary libreoffice ansible libnss-myhostname sysv-rc-conf virtualbox-guest-dkms {% else %} -d-i pkgsel/include string dialog vim screen cifs-utils curl git openssh-server software-properties-common sshpass ubuntu-edu-secondary libreoffice ansible libnss-myhostname sysv-rc-conf +d-i pkgsel/include string epoptes dialog vim screen cifs-utils curl git openssh-server software-properties-common sshpass ubuntu-edu-secondary libreoffice ansible libnss-myhostname sysv-rc-conf {% endif %} # Post installation tasks # Update system d-i preseed/late_command string in-target apt-get -y upgrade; \ in-target apt-get -y dist-upgrade; \ - in-target apt-get -y purge libnss-mdns unity-webapps-common zeitgeist-core zeitgeist-datahub; \ + in-target apt-get -y purge libnss-mdns unity-webapps-common zeitgeist-core zeitgeist-datahub epoptes-client; \ in-target apt-get -y autoremove; \ sed -i'' -e 's/ubuntu/gnome-fallback/g' /target/usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf; \ in-target bash -c "curl -sSL http://{{ ansible_local.domain.serverfqdn }}/ks/preseed/postseed-docenti.sh | /bin/bash >/root/post-ks.log 2>&1";