[apt] Configure APT sources
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
		
							
								
								
									
										5
									
								
								base.yml
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								base.yml
									
									
									
									
									
								
							@@ -1,5 +1,10 @@
 | 
			
		||||
#!/usr/bin/env ansible-playbook
 | 
			
		||||
---
 | 
			
		||||
- hosts: debian
 | 
			
		||||
  vars:
 | 
			
		||||
    apt: "{{ glob_apt | default({}) | combine(service_apt | default({})) | combine(loc_apt | default({})) }}"
 | 
			
		||||
  roles:
 | 
			
		||||
    - apt
 | 
			
		||||
 | 
			
		||||
- hosts: all
 | 
			
		||||
  roles:
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								group_vars/debian.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								group_vars/debian.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
			
		||||
---
 | 
			
		||||
glob_apt:
 | 
			
		||||
  mirror: "http://mirror.crans.org/"
 | 
			
		||||
  extra_repositories: []
 | 
			
		||||
							
								
								
									
										8
									
								
								group_vars/virtu.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								group_vars/virtu.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
---
 | 
			
		||||
service_apt:
 | 
			
		||||
  extra_repositories:
 | 
			
		||||
    - name: pve-entreprise
 | 
			
		||||
      repositories:
 | 
			
		||||
        - url: "{{ glob_apt.mirror }}proxmox/debian/pve"
 | 
			
		||||
          version: "{{ ansible_distribution_release }}"
 | 
			
		||||
          tags: "pve-no-subscription"
 | 
			
		||||
							
								
								
									
										18
									
								
								hosts
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								hosts
									
									
									
									
									
								
							@@ -1,16 +1,20 @@
 | 
			
		||||
[server]
 | 
			
		||||
templier.adh.crans.org
 | 
			
		||||
dt.adh.crans.org
 | 
			
		||||
[archlinux:children]
 | 
			
		||||
perso
 | 
			
		||||
 | 
			
		||||
[debian:children]
 | 
			
		||||
server
 | 
			
		||||
 | 
			
		||||
[perso]
 | 
			
		||||
ynerant-pc.fil.sand.auro.re
 | 
			
		||||
ynerant-thinkpad.wifi.sand.auro.re
 | 
			
		||||
localhost
 | 
			
		||||
 | 
			
		||||
[crans]
 | 
			
		||||
odlyd.crans.org
 | 
			
		||||
tealc.crans.org
 | 
			
		||||
zamok.crans.org
 | 
			
		||||
[server]
 | 
			
		||||
templier.adh.crans.org
 | 
			
		||||
dt.adh.crans.org
 | 
			
		||||
 | 
			
		||||
[virtu]
 | 
			
		||||
dt.adh.crans.org
 | 
			
		||||
 | 
			
		||||
[all:vars]
 | 
			
		||||
# Force remote to use Python 3
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										27
									
								
								roles/apt/tasks/main.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								roles/apt/tasks/main.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
---
 | 
			
		||||
- name: Add mirror.crans.org in /etc/hosts
 | 
			
		||||
  lineinfile:
 | 
			
		||||
    state: present
 | 
			
		||||
    path: /etc/hosts
 | 
			
		||||
    regex: "^{{ item }}"
 | 
			
		||||
    line: "{{ item }} mirror.crans.org charybde.crans.org mirror"
 | 
			
		||||
  loop:
 | 
			
		||||
    - "185.230.79.30"
 | 
			
		||||
    - "2a0c:700:2:0:ea39:35ff:fef0:48c9"
 | 
			
		||||
 | 
			
		||||
- name: Configure Debian repositories
 | 
			
		||||
  template:
 | 
			
		||||
    src: apt/sources.list.j2
 | 
			
		||||
    dest: /etc/apt/sources.list
 | 
			
		||||
    owner: root
 | 
			
		||||
    group: root
 | 
			
		||||
    mode: 0644
 | 
			
		||||
 | 
			
		||||
- name: Connfigure extra repositories
 | 
			
		||||
  template:
 | 
			
		||||
    src: apt/sources.list.d/sources.list.j2
 | 
			
		||||
    dest: "/etc/apt/sources.list.d/{{ item.name }}.list"
 | 
			
		||||
    owner: root
 | 
			
		||||
    group: root
 | 
			
		||||
    mode: 0644
 | 
			
		||||
  loop: "{{ apt.extra_repositories }}"
 | 
			
		||||
							
								
								
									
										8
									
								
								roles/apt/templates/apt/sources.list.d/sources.list.j2
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								roles/apt/templates/apt/sources.list.d/sources.list.j2
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
{{ ansible_header | comment }}
 | 
			
		||||
 | 
			
		||||
{% for repo in item.repositories -%}
 | 
			
		||||
deb {{ repo.url }} {{ repo.version }} {{ repo.tags }}
 | 
			
		||||
{% if repo.src is defined and repo.src -%}
 | 
			
		||||
deb-src {{ repo.url }} {{ repo.version }} {{ repo.tags }}
 | 
			
		||||
{% endif -%}
 | 
			
		||||
{% endfor -%}
 | 
			
		||||
							
								
								
									
										18
									
								
								roles/apt/templates/apt/sources.list.j2
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								roles/apt/templates/apt/sources.list.j2
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
{{ ansible_header | comment }}
 | 
			
		||||
 | 
			
		||||
{% if ansible_distribution_release != "bullseye" %}
 | 
			
		||||
{# Debian security does not exist yet for bullseye #}
 | 
			
		||||
# Mises à jour de sécurité
 | 
			
		||||
deb     {{ apt.mirror }}debian-security {{ ansible_distribution_release }}/updates main contrib non-free
 | 
			
		||||
 | 
			
		||||
{% endif %}
 | 
			
		||||
# Dépôt classique
 | 
			
		||||
deb     {{ apt.mirror }}debian {{ ansible_distribution_release }} main contrib non-free
 | 
			
		||||
 | 
			
		||||
# Dépôt pour mises à jour fréquentes (volatile)
 | 
			
		||||
deb     {{ apt.mirror }}debian {{ ansible_distribution_release }}-updates main contrib non-free
 | 
			
		||||
 | 
			
		||||
{% if backports | default(false) %}
 | 
			
		||||
# Backports
 | 
			
		||||
deb     {{ apt.mirror }}debian {{ ansible_distribution_release }}-backports main contrib non-free
 | 
			
		||||
{% endif %}
 | 
			
		||||
		Reference in New Issue
	
	Block a user