role_podman/tasks/configuration.yml

80 lines
2.2 KiB
YAML
Raw Permalink Normal View History

2023-12-21 16:30:57 +00:00
---
# tasks file for podman
2024-10-22 09:14:15 +00:00
- name: Enable lingering for podman user
2024-06-06 00:39:39 +00:00
ansible.builtin.command:
2024-10-22 09:14:15 +00:00
cmd: "loginctl enable-linger {{ podman_user }}"
creates: /var/lib/systemd/linger/podman
2024-06-06 00:39:39 +00:00
become: true
2024-10-22 09:14:15 +00:00
- name: Create subvolumes paths
2024-06-09 14:10:19 +00:00
ansible.builtin.file:
path: "{{ item.1 | split(':') | first }}"
state: directory
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 }}"
2024-10-22 09:14:15 +00:00
register: folders
notify: Set default permissions on volumes folders
- name: Exécuter les handlers
ansible.builtin.meta: flush_handlers
- name: Deploy pods
containers.podman.podman_pod: "{{ pod }}"
become: true
become_user: "{{ podman_user }}"
loop: "{{ podman_pods }}"
loop_control:
label: "{{ item.name }}"
register: deployed_pods
2024-06-09 14:10:19 +00:00
vars:
2024-10-22 09:14:15 +00:00
pod: "{{ podman_pods_defaults | ansible.builtin.combine(item) }}"
2024-06-09 14:10:19 +00:00
2024-10-22 09:14:15 +00:00
- 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 }}"
2023-12-21 16:30:57 +00:00
become: true
2024-10-22 09:14:15 +00:00
become_user: "{{ podman_user }}"
2024-06-07 23:51:45 +00:00
loop: "{{ podman_containers }}"
loop_control:
label: "{{ item.name }}"
2024-10-22 09:14:15 +00:00
register: deployed_containers
2024-06-07 23:51:45 +00:00
vars:
2024-10-22 09:14:15 +00:00
container: "{{ podman_containers_defaults | ansible.builtin.combine(item) }}"
2024-06-09 14:10:19 +00:00
2024-10-22 09:14:15 +00:00
- name: Start or restart containers
2024-06-09 14:10:19 +00:00
ansible.builtin.systemd_service:
name: "{{ item.item.name }}.service"
state: "{{ 'restarted' if item.changed else 'started' }}"
daemon_reload: true
scope: user
become: true
2024-10-22 09:14:15 +00:00
become_user: "{{ podman_user }}"
loop: "{{ deployed_containers.results }}"
2024-06-09 14:10:19 +00:00
loop_control:
label: "{{ item.item.name }}"
2024-06-18 10:36:04 +00:00
2024-10-22 09:14:15 +00:00
- name: Enable containers auto-update service
2024-06-18 10:36:04 +00:00
ansible.builtin.systemd_service:
name: podman-auto-update.timer
daemon_reload: true
enabled: true
scope: user
when: podman_auto_update
become: true
2024-10-22 09:14:15 +00:00
become_user: "{{ podman_user }}"