You've already forked role_podman
feat: Create role
This commit is contained in:
55
tasks/configuration.yml
Normal file
55
tasks/configuration.yml
Normal file
@@ -0,0 +1,55 @@
|
||||
---
|
||||
# tasks file for podman
|
||||
|
||||
- name: Créer l'utilisateur dédié
|
||||
ansible.builtin.include_role:
|
||||
name: users
|
||||
vars:
|
||||
users:
|
||||
- name: "{{ container_user }}"
|
||||
comment: Dedicated Podman user ({{ container.name }})
|
||||
update_password: on_create
|
||||
password_lock: true
|
||||
shell: /bin/bash
|
||||
|
||||
- name: Créer le chemin de stockage des définitions
|
||||
ansible.builtin.file:
|
||||
path: "{{ container_basepath }}"
|
||||
state: directory
|
||||
owner: "{{ container_user }}"
|
||||
group: "{{ container_user }}"
|
||||
mode: u=rwX,g=rwX,o=
|
||||
become: true
|
||||
|
||||
- name: Créer le volume
|
||||
containers.podman.podman_volume:
|
||||
name: "{{ item.split(':')[0] }}"
|
||||
when: container.volumes | length > 0
|
||||
loop: "{{ container.volumes }}"
|
||||
notify: Redémarrer le conteneur
|
||||
|
||||
- name: Déployer le conteneur
|
||||
ansible.builtin.template:
|
||||
src: podman-quadlet.container.j2
|
||||
dest: "{{ container_basepath }}/{{ container_filename }}"
|
||||
owner: "{{ container_user }}"
|
||||
group: "{{ container_user }}"
|
||||
mode: u=rw,g=rw,o=
|
||||
become: true
|
||||
register: deploy_container
|
||||
|
||||
- name: Activer le lingering
|
||||
ansible.builtin.command:
|
||||
cmd: "loginctl enable-linger {{ container_user }}"
|
||||
creates: /var/lib/systemd/linger/{{ container_user }}
|
||||
become: true
|
||||
|
||||
- name: Démarrer ou redémarrer le conteneur
|
||||
ansible.builtin.systemd_service:
|
||||
name: "{{ container_filename | replace('.container', '.service') }}"
|
||||
state: "{{ 'restarted' if deploy_container.changed else 'started' }}"
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
scope: user
|
||||
become: true
|
||||
become_user: "{{ container_user }}"
|
13
tasks/installation.yml
Normal file
13
tasks/installation.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
# tasks file for podman
|
||||
|
||||
- name: Installer les paquets
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- dbus-user-session
|
||||
- podman
|
||||
- rootlesskit
|
||||
- slirp4netns
|
||||
- systemd-container
|
||||
state: present
|
||||
become: true
|
18
tasks/main.yml
Normal file
18
tasks/main.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
# tasks file for podman
|
||||
|
||||
- name: Importer les tâches d'installation
|
||||
tags: installation
|
||||
ansible.builtin.import_tasks: installation.yml
|
||||
|
||||
- name: Importer les tâches de configuration
|
||||
tags: configuration
|
||||
ansible.builtin.include_tasks: configuration.yml
|
||||
loop: "{{ podman_containers }}"
|
||||
loop_control:
|
||||
label: "{{ container.name }}"
|
||||
loop_var: container
|
||||
vars:
|
||||
container_user: "podman-{{ container.user | default(container.name) }}"
|
||||
container_basepath: "/home/{{ container_user }}/.config/containers/systemd"
|
||||
container_filename: "podman-{{ container.name }}.container"
|
Reference in New Issue
Block a user