infrastructure/roles/teamspeak/tasks/main.yml
Saibotk e7a172877b
refactor!(teamspeak): Use podman quadlet setup
This is mostly equivalent to the awesome role found in @histalek's repository:
bde4d9dacb/roles/teamspeak
2024-08-14 00:53:09 +02:00

73 lines
2 KiB
YAML

- name: Update default SELinux contexts.
community.general.sefcontext:
target: "{{ teamspeak_install_dir }}/data(/.*)?"
setype: "container_file_t"
selevel: "{{ teamspeak_selinux_level }}"
state: present
become: true
notify: "teamspeak selinux context changed"
- name: Create teamspeak install directory.
ansible.builtin.file:
path: "{{ teamspeak_install_dir }}"
owner: "root"
group: "root"
state: directory
mode: "0700"
become: true
- name: Ensure teamspeak data directory exists.
block:
- name: Check teamspeak data directory path.
ansible.builtin.stat:
path: "{{ teamspeak_install_dir }}/data"
become: true
register: teamspeak_stat_data_dir
- name: Create teamspeak data directory.
ansible.builtin.file:
path: "{{ teamspeak_install_dir }}/data"
owner: "{{ teamspeak_stat_data_dir.stat.uid | default('root') }}"
group: "{{ teamspeak_stat_data_dir.stat.gid | default('root') }}"
state: directory
mode: "0700"
become: true
- name: Open teamspeak ports.
ansible.posix.firewalld:
state: enabled
permanent: true
immediate: true
zone: public
port: "{{ item }}"
loop:
- "{{ teamspeak_voice_port }}/udp"
- "{{ teamspeak_filetransfer_port }}/tcp"
become: true
- name: Ensure container image is present on the host.
containers.podman.podman_image:
name: "{{ teamspeak_containerimage }}"
state: present
tag: "{{ teamspeak_image_tag }}"
become: true
- name: Create teamspeak container file.
ansible.builtin.template:
src: teamspeak.container.j2
dest: "/etc/containers/systemd/teamspeak.container"
owner: "root"
group: "root"
mode: "0644"
become: true
notify: "teamspeak service changed"
- name: Flush handlers
ansible.builtin.meta: flush_handlers
- name: Ensure teamspeak service is started.
ansible.builtin.systemd:
state: started
enabled: true
name: teamspeak.service
daemon_reload: true
become: true