ansible/roles/speedtest/tasks/main.yml

60 lines
1.7 KiB
YAML

---
- name: Install packages
apt:
name:
- docker.io
- docker-compose
- name: Create speedtest group
group: name=speedtest
- name: Create speedtest user
user:
name: speedtest
home: /opt/speedtest
shell: /bin/bash
group: speedtest
groups: docker
- name: Configure speedtest container
template: src=docker-compose.yml.j2 dest=/opt/speedtest/docker-compose.yml
notify: Restart speedtest
- name: Ensure certificates are available
command: openssl req -x509 -nodes -newkey rsa:2048 -keyout /etc/nginx/ssl/{{ speedtest_domain }}.key -out /etc/nginx/ssl/{{ speedtest_domain }}.crt -days 730 -subj "/CN={{ speedtest_domain }}" creates=/etc/nginx/ssl/{{ speedtest_domain }}.crt
notify: Restart nginx
- name: Configure certificate manager for speedtest
template: src=certs.j2 dest=/etc/acertmgr/{{ speedtest_domain }}.conf
notify: Run acertmgr
- name: Configure vhost
template: src=vhost.j2 dest=/etc/nginx/sites-available/speedtest
notify: Restart nginx
- name: Enable vhost
file: src=/etc/nginx/sites-available/speedtest dest=/etc/nginx/sites-enabled/speedtest state=link
notify: Restart nginx
- name: Systemd unit for speedtest
template: src=speedtest.service.j2 dest=/etc/systemd/system/speedtest.service
notify:
- Reload systemd
- Restart speedtest
- name: Systemd unit for speedtest-reload
template: src=speedtest-reload.{{ item }}.j2 dest=/etc/systemd/system/speedtest-reload.{{ item }}
with_items:
- "service"
- "timer"
notify:
- Reload systemd
- Restart speedtest-reload
- name: Start the speedtest service
service: name=speedtest state=started enabled=yes
- name: Enable auto update timer
service: name=speedtest-reload.timer state=started enabled=yes