Update tasks for compatibility with new host_vars format

This commit is contained in:
Mike Holloway 2025-01-02 16:23:50 -05:00
parent 0042aa91dd
commit 3aa0652d26

View File

@ -1,3 +1,5 @@
- 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']
@ -12,11 +14,22 @@
- pexpect
- ansible-vault
- name: Create Service Users
- name: Create service users
user:
name: "{{ item }}"
loop:
"{{ service_users }}"
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:
@ -25,25 +38,29 @@
- name: Enable remote login session linger
command:
cmd: loginctl enable-linger "{{ item }}"
loop:
"{{ service_users }}"
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/{{ service_users[0] }}/.config/containers/"
path: "/home/{{ item.name }}/.config/containers/"
state: directory
become: yes
become_user: "{{ service_users[0] }}"
become_user: "{{ item.name }}"
with_items:
- "{{ service_users }}"
- copy:
src: containers.conf
dest: "/home/{{ service_users[0] }}/.config/containers/containers.conf"
dest: "/home/{{ item.name }}/.config/containers/containers.conf"
become: yes
become_user: "{{ service_users[0] }}"
become_user: "{{ item.name }}"
with_items:
- "{{ service_users }}"
- name: Enable podman.socket for {{ service_users[0] }}
systemd:
@ -52,14 +69,16 @@
state: started
scope: user
become: yes
become_user: "{{ service_users[0] }}"
become_user: "{{ item.name }}"
with_items:
- "{{ service_users }}"
- name: Create machinectl bash alias
lineinfile:
path: "/home/{{ item }}/.bashrc"
path: "/home/{{ item.name }}/.bashrc"
regexp: '^su() '
line: "su() { if [[ $1 == \"-\" ]]; then command machinectl shell --uid \"$2\"; else command machinectl shell --uid \"$1\"; fi; }"
loop: "{{ service_users }}"
with_items: "{{ service_users }}"
- lineinfile:
path: "/root/.bashrc"