summaryrefslogtreecommitdiffstats
path: root/roles/podman/tasks/main.yml
blob: bfd673fff10d711f3bd7698dfd1c277b0181bb10 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
- name: "Install Podman"
  become: true
  ansible.builtin.package:
    name: "podman"
    state: "present"

- name: "Enable and start Podman socket service"
  become: true
  ansible.builtin.systemd_service:
    name: "podman.socket"
    enabled: true
    state: started

- name: "Configure Podman for rootless operation"
  ansible.builtin.command:
    cmd: "loginctl enable-linger {{ ansible_facts['user_uid'] }}"
  become: true
  changed_when: false
  failed_when: false

- name: "Create containers configuration directory"
  ansible.builtin.file:
    path: "{{ ansible_facts['env']['HOME'] }}/.config/containers"
    state: "directory"
    mode: "0755"

- name: "Configure Podman containers.conf"
  ansible.builtin.copy:
    dest: "{{ ansible_facts['env']['HOME'] }}/.config/containers/containers.conf"
    mode: "0644"
    content: |
      # Use systemd cgroup manager for proper integration with the host's
      # resource management on cgroup v2 systems. Requires cgroup delegation
      # (cpu, memory, pids controllers) in the user's systemd slice.
      [engine]
      cgroup_manager = "systemd"

      # Lower the default pasta MTU to prevent intermittent TLS errors
      # (SSL_ERROR_SYSCALL, unexpected eof) caused by packet fragmentation
      # in rootless podman's pasta networking layer.
      [network]
      pasta_options = ["--mtu", "1280"]

- name: "Configure container registries"
  become: true
  ansible.builtin.copy:
    dest: "/etc/containers/registries.conf"
    mode: "0644"
    content: |
      unqualified-search-registries = ["docker.io"]

      [[registry]]
      location = "docker.io"