-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrun-container-unifi-controller-podman.yml
75 lines (66 loc) · 2.01 KB
/
run-container-unifi-controller-podman.yml
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
---
# I run this file with following line to test against my Vagrant Fedora:
# ansible-playbook --vault-password-file .vault-password -b -i \
# ~/vagrant/fedora/.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory \
# -e ansible_python_interpreter=/usr/bin/python3 -e state=running test-podman.yml
- name: ensure unifi container is running
hosts: all
vars:
container_name: unifi
container_image: jacobalberty/unifi:latest
#container_run_as_user: unifi
unifi_uid: 975
unifi_gid: 972
container_run_args: >-
--rm
-p 8080:8080 -p 8443:8443 -p 3478:3478/udp -p 10001:10001/udp
-v "{{exported_container_volumes_basedir}}/unifi:/unifi:Z"
--hostname="unifi.{{ my_domain }}"
--memory=2048M
-e TZ="{{ my_timezone }}"
-e UNIFI_UID="{{unifi_uid}}"
-e UNIFI_GID="{{unifi_gid}}"
container_firewall_ports:
- 8080/tcp
- 8443/tcp
- 3478/udp
- 10001/udp
tasks:
- name: set variable states when container state is running
set_fact:
user_state: present
when: unifi_state == "running"
- name: set varialbe states when container state is not running
set_fact:
user_state: absent
when: unifi_state != "running"
- name: ensure unifi group
group:
name: unifi
gid: "{{unifi_gid}}"
state: "{{ user_state }}"
when: unifi_state == "running"
- name: ensure unifi user
user:
name: unifi
comment: User to run unifi control software
uid: "{{unifi_uid}}"
group: unifi
shell: /sbin/nologin
state: "{{ user_state }}"
- name: ensure unifi group
group:
name: unifi
gid: "{{unifi_gid}}"
state: "{{ user_state }}"
when: unifi_state != "running"
- name: ensure unifi config dir
tags: unifi
file:
path: "{{exported_container_volumes_basedir}}/unifi"
state: directory
owner: "{{ unifi_uid }}"
group: "{{ unifi_gid }}"
- name: ensure container state
import_role:
name: podman_container_systemd