[proxmox] Automatically synchronize Debian images
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>certbot_on_virtu
							parent
							
								
									9f71b1cbde
								
							
						
					
					
						commit
						80a40df6c4
					
				| 
						 | 
				
			
			@ -0,0 +1,4 @@
 | 
			
		|||
---
 | 
			
		||||
glob_debian_images:
 | 
			
		||||
  cron_timer: '39 06 * * *'
 | 
			
		||||
  rsync_host: "eclat.adm.crans.org"
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			@ -13,6 +13,7 @@
 | 
			
		|||
- import_playbook: baie.yml
 | 
			
		||||
- import_playbook: utilities.yml
 | 
			
		||||
- import_playbook: slapd.yml
 | 
			
		||||
- import_playbook: proxmox.yml
 | 
			
		||||
 | 
			
		||||
- hosts: server,!sssd
 | 
			
		||||
  vars:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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'
 | 
			
		||||
| 
						 | 
				
			
			@ -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/
 | 
			
		||||
		Loading…
	
		Reference in New Issue