refacto: Rewriting for Debian Sid

This commit is contained in:
2024-10-22 11:14:15 +02:00
parent 14e5cb0537
commit 49094e2389
9 changed files with 165 additions and 149 deletions

View File

@@ -1,72 +1,74 @@
---
# tasks file for podman
- name: Activer le lingering
- name: Enable lingering for podman user
ansible.builtin.command:
cmd: "loginctl enable-linger {{ container_user }}"
creates: /var/lib/systemd/linger/{{ container_user }}
cmd: "loginctl enable-linger {{ podman_user }}"
creates: /var/lib/systemd/linger/podman
become: true
loop: "{{ podman_containers }}"
loop_control:
label: "{{ item.name }}"
vars:
container_user: "podman-{{ item.user | default(item.name) }}"
- name: Créer les dossiers des volumes
- name: Create subvolumes paths
ansible.builtin.file:
path: "{{ item.1 | split(':') | first }}"
state: directory
owner: "{{ container_user }}"
group: "{{ container_user }}"
mode: u=rwX,g=rX,o=rX
become: true
loop: "{{ q('ansible.builtin.subelements', podman_containers, 'volumes', {'skip_missing': True}) }}"
loop_control:
label: "{{ item.0.name }}"
vars:
container_user: "podman-{{ item.0.user | default(item.0.name) }}"
register: folders
notify: Set default permissions on volumes folders
- name: Déployer les conteneurs
containers.podman.podman_container:
hostname: "{{ item.hostname | default(inventory_hostname) }}"
name: "{{ item.name }}"
image: "{{ item.image }}"
state: quadlet
device: "{{ item.device | default(omit) }}"
ports: "{{ item.ports | default(omit) }}"
volumes: "{{ item.volumes | default(omit) }}"
userns: "{{ item.userns | default(omit) }}"
mount: "{{ item.mount | default(omit) }}"
publish: "{{ item.publish | default(omit) }}"
env: "{{ item.env | default(omit) }}"
quadlet_options: "{{ item.quadlet_options | default(omit) }}"
sysctl: "{{ item.sysctl | default(omit) }}"
cap_add: "{{ item.cap_add | default(omit) }}"
recreate: true
- name: Exécuter les handlers
ansible.builtin.meta: flush_handlers
- name: Deploy pods
containers.podman.podman_pod: "{{ pod }}"
become: true
become_user: "{{ container_user }}"
register: deploy_container
become_user: "{{ podman_user }}"
loop: "{{ podman_pods }}"
loop_control:
label: "{{ item.name }}"
register: deployed_pods
vars:
pod: "{{ podman_pods_defaults | ansible.builtin.combine(item) }}"
- name: Start or restart pods
ansible.builtin.systemd_service:
name: "{{ item.item.name }}-pod.service"
state: "{{ 'restarted' if item.changed else 'started' }}"
daemon_reload: true
scope: user
become: true
become_user: "{{ podman_user }}"
loop: "{{ deployed_pods.results }}"
loop_control:
label: "{{ item.item.name }}"
- name: Deploy containers
containers.podman.podman_container: "{{ container }}"
become: true
become_user: "{{ podman_user }}"
loop: "{{ podman_containers }}"
loop_control:
label: "{{ item.name }}"
register: deployed_containers
vars:
container_user: "podman-{{ item.user | default(item.name) }}"
container: "{{ podman_containers_defaults | ansible.builtin.combine(item) }}"
- name: Démarrer ou redémarrer le conteneur
- name: Start or restart containers
ansible.builtin.systemd_service:
name: "{{ item.item.name }}.service"
state: "{{ 'restarted' if item.changed else 'started' }}"
daemon_reload: true
scope: user
become: true
become_user: "{{ container_user }}"
loop: "{{ deploy_container.results }}"
become_user: "{{ podman_user }}"
loop: "{{ deployed_containers.results }}"
loop_control:
label: "{{ item.item.name }}"
vars:
container_user: "podman-{{ item.item.user | default(item.item.name) }}"
- name: Activer le service de mise à jour automatique
- name: Enable containers auto-update service
ansible.builtin.systemd_service:
name: podman-auto-update.timer
daemon_reload: true
@@ -74,9 +76,4 @@
scope: user
when: podman_auto_update
become: true
become_user: "{{ container_user }}"
loop: "{{ deploy_container.results }}"
loop_control:
label: "{{ item.item.name }}"
vars:
container_user: "podman-{{ item.item.user | default(item.item.name) }}"
become_user: "{{ podman_user }}"

View File

@@ -3,28 +3,14 @@
- name: Installer les paquets
ansible.builtin.apt:
name:
- dbus-user-session
- containernetworking-dnsname
- containernetworking-plugins
- containernetworking-podman-machine
- dbus-user-session
- passt
- podman
- podman-aardvark-dns
- podman-docker
- podman-gvproxy
- podman-netavark
- python3-podman-compose
- uidmap
- systemd-container
name: "{{ podman_packages }}"
install_recommends: true
state: present
become: true
notify:
- Corriger le problème passt VS pasta
- Redémarrer l'instance
- Attendre que le port SSH soit ouvert
# - Fix passt VS pasta
# - Restart instance
# - Wait SSH is ready
- name: Exécuter les handlers
ansible.builtin.meta: flush_handlers
@@ -38,7 +24,7 @@
mode: u=rw,g=r,o=r
when: podman_configure_rsyslog
become: true
notify: Redémarrer rsyslog.service
notify: Restart rsyslog.service
- name: Désactiver le service de mise à jour automatique pour root
ansible.builtin.systemd_service:

View File

@@ -1,10 +1,10 @@
---
# tasks file for podman
- name: Importer les tâches d'installation
- name: Import installation tasks
ansible.builtin.import_tasks:
file: installation.yml
- name: Importer les tâches de configuration
- name: Import configuration tasks
ansible.builtin.import_tasks:
file: configuration.yml