Playbook
This commit is contained in:
parent
451c8fee6e
commit
1caa7659ae
9 changed files with 80 additions and 0 deletions
23
files/unifi.service
Normal file
23
files/unifi.service
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Unifi server
|
||||||
|
Requires=docker.service
|
||||||
|
After=docker.service
|
||||||
|
|
||||||
|
DefaultDependencies=no
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
Environment="HOME=/root"
|
||||||
|
ExecStartPre=-/usr/bin/env sh -c '/usr/bin/env docker kill unifi 2>/dev/null'
|
||||||
|
ExecStartPre=-/usr/bin/env sh -c '/usr/bin/env docker rm unifi 2>/dev/null'
|
||||||
|
|
||||||
|
ExecStart=/usr/bin/env docker run --rm --name unifi --log-driver=none -p 3478:3478/udp -p 8080:8080 -p 8443:8443 -p 6789:6789 -p 8843:8843 -p 8880:8880 -v unifi:/var/lib/unifi -v unifilog:/unifi -v unifirun:/var/run/unifi jacobalberty/unifi:stable-6
|
||||||
|
|
||||||
|
ExecStop=-/usr/bin/env sh -c '/usr/bin/env docker kill unifi 2>/dev/null'
|
||||||
|
ExecStop=-/usr/bin/env sh -c '/usr/bin/env docker rm unifi 2>/dev/null'
|
||||||
|
Restart=always
|
||||||
|
RestartSec=30
|
||||||
|
SyslogIdentifier=unifi
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
4
group_vars/unifi
Normal file
4
group_vars/unifi
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
unifi_hostname: unifi
|
||||||
|
unifi_version: jacobalberty/unifi:stable-6
|
||||||
|
unifi_selinux: no
|
||||||
|
unifi_bareos: no
|
11
install.yml
Executable file
11
install.yml
Executable file
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
- name: "Set up a Unifi Server"
|
||||||
|
hosts: "unifi"
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- include: tasks/hostname.yml
|
||||||
|
- include: tasks/update.yml
|
||||||
|
- include: tasks/packete.yml
|
||||||
|
- include: tasks/firewall.yml
|
||||||
|
- include: tasks/docker.yml
|
||||||
|
- include: tasks/starten.yml
|
12
tasks/docker.yml
Normal file
12
tasks/docker.yml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
- name: Ensure Unifi Docker image is pulled
|
||||||
|
docker_image:
|
||||||
|
name: "{{ unifi_version }}"
|
||||||
|
source: 'pull'
|
||||||
|
|
||||||
|
- name: Ensure Unifi systemd is installed
|
||||||
|
copy:
|
||||||
|
src: files/unifi.service
|
||||||
|
dest: /etc/systemd/system/unifi.service
|
||||||
|
mode: 0644
|
||||||
|
owner: root
|
||||||
|
group: root
|
2
tasks/firewall.yml
Normal file
2
tasks/firewall.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
- name: open bareos port
|
||||||
|
firewalld: port=9102/tcp zone=public permanent=true state=enabled immediate=yes
|
3
tasks/hostname.yml
Normal file
3
tasks/hostname.yml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
- name: Set a hostname
|
||||||
|
ansible.builtin.hostname:
|
||||||
|
name: "{{ unifi_hostname }}"
|
18
tasks/packete.yml
Normal file
18
tasks/packete.yml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
- name: Chrony installieren
|
||||||
|
dnf: name=chrony update_cache=no state=latest
|
||||||
|
|
||||||
|
- name: repository holen
|
||||||
|
shell:
|
||||||
|
"dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo"
|
||||||
|
|
||||||
|
- name: repository holen docker
|
||||||
|
shell:
|
||||||
|
"dnf install -y docker-ce --nobest"
|
||||||
|
|
||||||
|
- name: PIP3 installieren
|
||||||
|
dnf: name=python3-pip update_cache=no state=latest
|
||||||
|
|
||||||
|
- name: docker-python
|
||||||
|
shell:
|
||||||
|
"pip3 install docker"
|
||||||
|
|
3
tasks/starten.yml
Normal file
3
tasks/starten.yml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
- name: Dienste starten
|
||||||
|
shell:
|
||||||
|
"systemctl start docker; systemctl enable docker; systemctl daemon-reload; systemctl start unifi"
|
4
tasks/update.yml
Normal file
4
tasks/update.yml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
- name: Upgrade all packages
|
||||||
|
yum:
|
||||||
|
name: '*'
|
||||||
|
state: latest
|
Loading…
Reference in a new issue