diff --git a/group_vars/virtu.yml b/group_vars/virtu.yml new file mode 100644 index 0000000000000000000000000000000000000000..b999a5044966eb1fc99f408cd90a723052a2f927 --- /dev/null +++ b/group_vars/virtu.yml @@ -0,0 +1,4 @@ +--- +glob_debian_images: + cron_timer: '39 06 * * *' + rsync_host: "eclat.adm.crans.org" diff --git a/host_vars/gulp.cachan-adm.crans.org.yml b/host_vars/gulp.cachan-adm.crans.org.yml index a8c822dbc45c997d4df58e632c186b7e3ff21637..b44167aed19b484acaba8d558c2a6d9c2b2cb470 100644 --- a/host_vars/gulp.cachan-adm.crans.org.yml +++ b/host_vars/gulp.cachan-adm.crans.org.yml @@ -11,6 +11,9 @@ glob_ntp_client: debian_mirror: http://mirror.cachan-adm.crans.org/debian proxmox_mirror: http://mirror.cachan-adm.crans.org/proxmox/debian/pve +loc_debian_images: + rsync_host: 'mirror.cachan-adm.crans.org' + loc_postgres: subnets: - 172.17.10.0/24 diff --git a/plays/proxmox.yml b/plays/proxmox.yml new file mode 100755 index 0000000000000000000000000000000000000000..cc44d139e140f58ef4d96faff7e5aad7722b9c84 --- /dev/null +++ b/plays/proxmox.yml @@ -0,0 +1,8 @@ +#!/usr/bin/env ansible-playbook +--- +- hosts: virtu + vars: + debian_images: '{{ glob_debian_images | default({}) | combine(loc_debian_images | default({})) }}' + roles: + - proxmox-apt-sources + - proxmox-debian-images diff --git a/plays/root.yml b/plays/root.yml index 76ba3d1f6deb9ab3c828202ab309d3f48e0b9ed6..fed28c12b9d84887c67c6eb37c97e438e804c2a3 100755 --- a/plays/root.yml +++ b/plays/root.yml @@ -13,6 +13,7 @@ - import_playbook: baie.yml - import_playbook: utilities.yml - import_playbook: slapd.yml +- import_playbook: proxmox.yml - hosts: server,!sssd vars: diff --git a/roles/proxmox-debian-images/tasks/main.yml b/roles/proxmox-debian-images/tasks/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..a21c22ff5236ab54b325cfc378bbf663bf87c965 --- /dev/null +++ b/roles/proxmox-debian-images/tasks/main.yml @@ -0,0 +1,18 @@ +--- +- name: Auto-sync debian CD images to always have up-to-date Debian images + template: + src: cron.d/debian-images.j2 + dest: /etc/cron.d/debian-images + +- name: Install rsync + apt: + update_cache: true + name: rsync + register: apt_result + retries: 3 + until: apt_result is succeeded + +- name: Initial synchronization to download Debian images + shell: "rsync --verbose --dirs --compress --times --update --delete-after --delete-excluded --include 'debian-[0-9]*-amd64-netinst.iso' --exclude '*' rsync://eclat.adm.crans.org/mirror/cdimage-debian/release/current/amd64/iso-cd/ /var/lib/vz/template/iso/" + register: rsync_output + changed_when: '"debian" in rsync_output.stdout' diff --git a/roles/proxmox-debian-images/templates/cron.d/debian-images.j2 b/roles/proxmox-debian-images/templates/cron.d/debian-images.j2 new file mode 100644 index 0000000000000000000000000000000000000000..bec7e9f6a060faa222cf9d18515e446a4d3ce6ea --- /dev/null +++ b/roles/proxmox-debian-images/templates/cron.d/debian-images.j2 @@ -0,0 +1,3 @@ +{{ ansible_header | comment }} + +{{ debian_images.cron_timer }} root rsync --info=name1 --dirs --compress --times --update --delete-after --delete-excluded --include 'debian-[0-9]*-amd64-netinst.iso' --exclude '*' rsync://{{ debian_images.rsync_host }}/mirror/cdimage-debian/release/current/amd64/iso-cd/ /var/lib/vz/template/iso/