vm-ansible/roles/webserver/tasks/main.yaml
Kristóf Torma 4e1833bbbf
Some checks reported errors
continuous-integration/drone/push Build was killed
add valid cert to internal communication
2023-03-05 18:26:08 +01:00

83 lines
1.7 KiB
YAML

---
- name: "Install Nginx via apt"
apt:
update_cache: yes
state: present
name:
- nginx
- name: Copy default nginx config
ansible.builtin.copy:
src: nginx.conf
dest: /etc/nginx/nginx.conf
owner: root
group: root
mode: '0644'
- name: Enable and restart nginx daemon
service:
name: nginx
state: restarted
enabled: yes
- name: Generate certificate for all server instances
command:
cmd: certbot certonly --non-interactive --agree-tos -m tormakristof@tormakristof.eu --nginx -d {{item.domain}}
with_items: "{{ webserver }}"
- name: "Generate certbot script"
ansible.builtin.template:
src: certbot.sh
dest: /etc/cron.weekly/certbot
owner: root
group: root
mode: '0700'
- name: "Generate nginx configuration"
ansible.builtin.template:
src: nginx.conf
dest: /etc/nginx/nginx.conf
owner: root
group: root
mode: '0644'
- name: Reload nginx daemon
service:
name: nginx
state: reloaded
- name: "Install nginx exporter"
apt:
update_cache: yes
state: present
name:
- prometheus-nginx-exporter
- name: Allow nginx exporter via ufw
community.general.ufw:
rule: allow
port: 9113
proto: tcp
src: 192.168.69.0/24
- name: Copy default nginx config
ansible.builtin.copy:
src: prometheus-nginx-exporter
dest: /etc/default/prometheus-nginx-exporter
owner: root
group: root
mode: '0644'
- name: Enable and restart exporter daemon
service:
name: prometheus-nginx-exporter
state: restarted
enabled: yes
- name: Allow https port via ufw
community.general.ufw:
rule: allow
port: https
src: 192.168.69.0/24
...