xoxys.podman/tasks/main.yml

67 lines
1.9 KiB
YAML
Raw Normal View History

2022-03-18 18:07:25 +00:00
---
2024-02-03 21:33:14 +00:00
- name: Ensure required packages are installed
ansible.builtin.package:
name: "{{ item }}"
state: "present"
loop:
- podman
- container-selinux
- bash-completion
2024-02-03 21:33:14 +00:00
- name: Install Podman bash-completion
ansible.builtin.command:
cmd: "podman completion bash -f /etc/bash_completion.d/podman"
creates: "/etc/bash_completion.d/podman"
2024-02-03 21:33:14 +00:00
- name: Deploy container configuration
ansible.builtin.template:
src: etc/containers/containers.conf.j2
dest: /etc/containers/containers.conf
owner: root
group: root
mode: "0644"
2024-02-03 21:33:14 +00:00
- name: Deploy storage configuration
ansible.builtin.template:
src: etc/containers/storage.conf.j2
dest: /etc/containers/storage.conf
owner: root
group: root
mode: "0644"
2024-02-03 21:33:14 +00:00
- name: Set SELinux booleans
ansible.posix.seboolean:
name: "{{ item.name }}"
state: "{{ item.state | bool }}"
persistent: "{{ item.persistent | default(True) | bool }}"
loop: "{{ podman_sebooleans }}"
loop_control:
label: "{{ item.name }}: {{ item.state | bool }}"
2024-02-03 21:33:14 +00:00
- name: Configure namespace id range
ansible.builtin.lineinfile:
dest: "{{ item }}"
regexp: "^containers:"
line: "containers:{{ podman_nsremap_range_start }}:{{ podman_nsremap_range_length }}"
loop:
- /etc/subuid
- /etc/subgid
2024-02-03 21:33:14 +00:00
- name: Handle registry logins
containers.podman.podman_login:
registry: "{{ item.url | default(omit) }}"
username: "{{ item.username }}"
password: "{{ item.password }}"
state: '{{ item.state | default("present") }}'
loop: "{{ podman_registries }}"
loop_control:
label: "{{ item.url }}"
- name: Enable podman socket
ansible.builtin.service:
name: podman.socket
daemon_reload: True
enabled: "{{ podman_socket_enabled | bool }}"
masked: "{{ not podman_socket_enabled | bool }}"
state: "{{ podman_socket_enabled | bool | ternary('started', 'stopped', 'started') }}"