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 - name: Install podman, podman networking plugins, and python support packages
dnf: dnf:
name: ['podman', 'containernetworking-plugins', 'podman-plugins', 'python3-pip', 'systemd-container'] name: ['podman', 'containernetworking-plugins', 'podman-plugins', 'python3-pip', 'systemd-container']
@ -12,11 +14,22 @@
- pexpect - pexpect
- ansible-vault - ansible-vault
- name: Create Service Users - name: Create service users
user: user:
name: "{{ item }}" name: "{{ item.name }}"
loop: with_items:
"{{ service_users }}" - "{{ 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 - name: Enable systemd-user session initialization over ssh
lineinfile: lineinfile:
@ -25,25 +38,29 @@
- name: Enable remote login session linger - name: Enable remote login session linger
command: command:
cmd: loginctl enable-linger "{{ item }}" cmd: loginctl enable-linger "{{ item.name }}"
loop: with_items:
"{{ service_users }}" - "{{ service_users }}"
- name: Generate podman shell completion scripts for bash - name: Generate podman shell completion scripts for bash
command: "podman completion bash" command: "podman completion bash"
- name: Disable hosts files for containers by default - name: Disable hosts files for containers by default
file: file:
path: "/home/{{ service_users[0] }}/.config/containers/" path: "/home/{{ item.name }}/.config/containers/"
state: directory state: directory
become: yes become: yes
become_user: "{{ service_users[0] }}" become_user: "{{ item.name }}"
with_items:
- "{{ service_users }}"
- copy: - copy:
src: containers.conf src: containers.conf
dest: "/home/{{ service_users[0] }}/.config/containers/containers.conf" dest: "/home/{{ item.name }}/.config/containers/containers.conf"
become: yes become: yes
become_user: "{{ service_users[0] }}" become_user: "{{ item.name }}"
with_items:
- "{{ service_users }}"
- name: Enable podman.socket for {{ service_users[0] }} - name: Enable podman.socket for {{ service_users[0] }}
systemd: systemd:
@ -52,14 +69,16 @@
state: started state: started
scope: user scope: user
become: yes become: yes
become_user: "{{ service_users[0] }}" become_user: "{{ item.name }}"
with_items:
- "{{ service_users }}"
- name: Create machinectl bash alias - name: Create machinectl bash alias
lineinfile: lineinfile:
path: "/home/{{ item }}/.bashrc" path: "/home/{{ item.name }}/.bashrc"
regexp: '^su() ' regexp: '^su() '
line: "su() { if [[ $1 == \"-\" ]]; then command machinectl shell --uid \"$2\"; else command machinectl shell --uid \"$1\"; fi; }" 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: - lineinfile:
path: "/root/.bashrc" path: "/root/.bashrc"