- import_tasks: include-vars.yml - name: Install podman, podman networking plugins, and python support packages dnf: name: ['podman', 'containernetworking-plugins', 'podman-plugins', 'python3-pip', 'systemd-container'] state: present - name: Install podman-compose pip Package pip: name: "{{ item }}" state: present with_items: - podman-compose - pexpect - ansible-vault - name: Create service users user: name: "{{ item.name }}" with_items: - "{{ service_users }}" - name: Create service folders become_user: "{{ item.0.name }}" file: path: "/home/{{ item.0.name }}/{{ item.1 }}" state: directory # debug: # msg: "name: {{ item.0.name }}\n service: {{ item.1 }}" with_subelements: - "{{ service_users }}" - services - name: Enable systemd-user session initialization over ssh lineinfile: dest: /etc/pam.d/sshd line: "session optional pam_systemd.so" - name: Enable remote login session linger command: cmd: loginctl enable-linger "{{ item.name }}" with_items: - "{{ service_users }}" - name: Generate podman shell completion scripts for bash command: "podman completion bash" - name: Disable hosts files for containers by default file: path: "/home/{{ item.name }}/.config/containers/" state: directory become: yes become_user: "{{ item.name }}" with_items: - "{{ service_users }}" - copy: src: containers.conf dest: "/home/{{ item.name }}/.config/containers/containers.conf" become: yes become_user: "{{ item.name }}" with_items: - "{{ service_users }}" - name: Enable podman.socket for {{ service_users[0] }} systemd: name: podman.socket enabled: true state: started scope: user become: yes become_user: "{{ item.name }}" with_items: - "{{ service_users }}" - name: Create machinectl bash alias lineinfile: path: "/home/{{ item.name }}/.bashrc" regexp: '^su() ' line: "su() { if [[ $1 == \"-\" ]]; then command machinectl shell --uid \"$2\"; else command machinectl shell --uid \"$1\"; fi; }" with_items: "{{ service_users }}" - lineinfile: path: "/root/.bashrc" regexp: '^su() ' line: "su() { if [[ $1 == \"-\" ]]; then command machinectl shell --uid \"$2\"; else command machinectl shell --uid \"$1\"; fi; }" - name: Enable permissive_container_t SELinux Context selinux_permissive: name: container_t permissive: true - name: Add hosts file entry for hostname lineinfile: path: /etc/hosts regexp: '^127\.0\.0\.1' line: "127.0.0.1 {{ inventory_hostname }} localhost localhost.localdomain localhost4 localhost4.localdomain4" owner: root group: root mode: 0644 - lineinfile: path: /etc/hosts regexp: '^::1' line: "::1 {{ inventory_hostname }} localhost localhost.localdomain localhost6 localhost6.localdomain6" owner: root group: root mode: 0644 # - name: Copy cni networking driver config into place # blockinfile: # name: "/etc/cni/net.d/podman.conflist" # insertafter: "*\"plugins\": [*" # block: " { # \"type\": \"dnsname\", # \"domainName\": \"dns.podman\", # \"capabilities\": { # \"aliases\": true # }"