fix: Review CoreOS compatibility
This commit is contained in:
parent
3cfe5831f2
commit
d6b72cda24
@ -1,7 +1,14 @@
|
||||
---
|
||||
# defaults file for podman
|
||||
|
||||
# Dedicated user
|
||||
podman_user: podman
|
||||
|
||||
# Enable container auto-update
|
||||
podman_auto_update: true
|
||||
|
||||
# Define pods
|
||||
podman_pods: []
|
||||
|
||||
# Define containers
|
||||
podman_containers: []
|
||||
|
@ -1,11 +1,11 @@
|
||||
---
|
||||
# handlers file for exim4
|
||||
# handlers file for podman
|
||||
|
||||
- name: Set default permissions on volumes folders
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
owner: root
|
||||
group: root
|
||||
owner: "{{ podman_user }}"
|
||||
group: "{{ podman_user }}"
|
||||
become: true
|
||||
loop: "{{ folders.results | selectattr('changed', 'equalto', true) }}"
|
||||
loop_control:
|
||||
|
25
tasks/containers.yml
Normal file
25
tasks/containers.yml
Normal file
@ -0,0 +1,25 @@
|
||||
---
|
||||
# tasks file for podman
|
||||
|
||||
- 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: "{{ podman_containers_defaults | ansible.builtin.combine(item) }}"
|
||||
|
||||
- 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: "{{ podman_user }}"
|
||||
loop: "{{ deployed_containers.results }}"
|
||||
loop_control:
|
||||
label: "{{ item.item.name }}"
|
@ -1,74 +1,14 @@
|
||||
---
|
||||
# tasks file for podman
|
||||
|
||||
- name: Ensure podman.service is started
|
||||
ansible.builtin.systemd_service:
|
||||
name: podman.service
|
||||
state: started
|
||||
enabled: true
|
||||
masked: false
|
||||
daemon_reload: true
|
||||
become: true
|
||||
- name: Import task to prepare instance
|
||||
ansible.builtin.import_tasks:
|
||||
file: prepare.yml
|
||||
|
||||
- name: Create subvolumes paths
|
||||
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 }}"
|
||||
register: folders
|
||||
notify: Set default permissions on volumes folders
|
||||
- name: Import task to manage pods
|
||||
ansible.builtin.import_tasks:
|
||||
file: pods.yml
|
||||
|
||||
- name: Exécuter les handlers
|
||||
ansible.builtin.meta: flush_handlers
|
||||
|
||||
- name: Deploy pods
|
||||
containers.podman.podman_pod: "{{ pod }}"
|
||||
become: true
|
||||
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
|
||||
become: true
|
||||
loop: "{{ deployed_pods.results }}"
|
||||
loop_control:
|
||||
label: "{{ item.item.name }}"
|
||||
|
||||
- name: Deploy containers
|
||||
containers.podman.podman_container: "{{ container }}"
|
||||
become: true
|
||||
loop: "{{ podman_containers }}"
|
||||
loop_control:
|
||||
label: "{{ item.name }}"
|
||||
register: deployed_containers
|
||||
vars:
|
||||
container: "{{ podman_containers_defaults | ansible.builtin.combine(item) }}"
|
||||
|
||||
- name: Start or restart containers
|
||||
ansible.builtin.systemd_service:
|
||||
name: "{{ item.item.name }}.service"
|
||||
state: "{{ 'restarted' if item.changed else 'started' }}"
|
||||
daemon_reload: true
|
||||
become: true
|
||||
loop: "{{ deployed_containers.results }}"
|
||||
loop_control:
|
||||
label: "{{ item.item.name }}"
|
||||
|
||||
- name: Enable containers auto-update service
|
||||
ansible.builtin.systemd_service:
|
||||
name: podman-auto-update.timer
|
||||
daemon_reload: true
|
||||
enabled: true
|
||||
when: podman_auto_update
|
||||
become: true
|
||||
- name: Import task to manage pods
|
||||
ansible.builtin.import_tasks:
|
||||
file: containers.yml
|
||||
|
25
tasks/pods.yml
Normal file
25
tasks/pods.yml
Normal file
@ -0,0 +1,25 @@
|
||||
---
|
||||
# tasks file for podman
|
||||
|
||||
- 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
|
||||
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 }}"
|
49
tasks/prepare.yml
Normal file
49
tasks/prepare.yml
Normal file
@ -0,0 +1,49 @@
|
||||
---
|
||||
# tasks file for podman
|
||||
|
||||
- name: Create dedicated group
|
||||
ansible.builtin.group:
|
||||
name: "{{ podman_user }}"
|
||||
become: true
|
||||
|
||||
- name: Create dedicated user
|
||||
ansible.builtin.user:
|
||||
name: "{{ podman_user }}"
|
||||
comment: Dedicated Podman user
|
||||
password_lock: true
|
||||
shell: /bin/bash
|
||||
group: podman
|
||||
become: true
|
||||
|
||||
- name: Disable global podman auto-update
|
||||
ansible.builtin.systemd_service:
|
||||
name: podman-auto-update.timer
|
||||
enabled: false
|
||||
become: true
|
||||
|
||||
- name: Enable containers auto-update service
|
||||
ansible.builtin.command:
|
||||
cmd: systemctl --user --machine={{ podman_user }}@ start podman-auto-update.timer
|
||||
when: podman_auto_update
|
||||
become: true
|
||||
|
||||
- name: Enable lingering for podman user
|
||||
ansible.builtin.command:
|
||||
cmd: loginctl enable-linger {{ podman_user }}
|
||||
creates: /var/lib/systemd/linger/podman
|
||||
become: true
|
||||
|
||||
- name: Create subvolumes paths
|
||||
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 }}"
|
||||
register: folders
|
||||
notify: Set default permissions on volumes folders
|
||||
|
||||
- name: Execute handlers
|
||||
ansible.builtin.meta: flush_handlers
|
Loading…
x
Reference in New Issue
Block a user