ops/playbooks/server/addDomainAndEncrypt.yml

49 lines
1.4 KiB
YAML
Raw Normal View History

2022-01-01 21:29:35 +03:30
---
- name: letsencrypt
hosts: supermaster
become: yes
tasks:
2022-01-21 00:40:30 +03:30
- name: add domain to nginx with j2 block
template:
src: template/nginx-server-block.j2
dest: /tmp/new-nginx-server-block.{{item.server_name}}.conf
with_items:
2022-02-28 12:50:57 +03:30
- server_name: dev.capitan.igarson.app
2022-01-21 00:40:30 +03:30
server_config: ""
2022-02-28 12:50:57 +03:30
service_port: 10003
conf_file: ngrok.conf
2022-01-21 00:40:30 +03:30
2022-01-01 21:29:35 +03:30
2022-01-21 00:40:30 +03:30
- name: append /tmp/new-nginx-server-block.conf to specific conf
shell: |
cat /tmp/new-nginx-server-block.{{item.server_name}}.conf >> /etc/nginx/sites-available/{{ item.conf_file }}
rm -rf /tmp/new-nginx-server-block.{{item.server_name}}.conf
with_items:
2022-02-28 12:50:57 +03:30
- server_name: dev.capitan.igarson.app
2022-01-21 00:40:30 +03:30
server_config: ""
2022-02-28 12:50:57 +03:30
service_port: 10003
conf_file: ngrok.conf
2022-01-21 00:40:30 +03:30
2022-01-01 21:29:35 +03:30
- name: encrypt all domains
2022-01-21 00:40:30 +03:30
shell: |
certbot --nginx -d {{item.server_name}} -n --redirect
2022-01-01 21:29:35 +03:30
with_items:
2022-02-28 12:50:57 +03:30
- server_name: dev.capitan.igarson.app
2022-01-21 00:40:30 +03:30
server_config: ""
2022-02-28 12:50:57 +03:30
service_port: 10003
conf_file: ngrok.conf
2022-01-21 00:40:30 +03:30
- name: Reload nginx to activate specified site
service: name=nginx state=restarted
- name: cron job for renew certificates
cron:
name: renew_certificates
special_time: weekly
2022-02-28 12:50:57 +03:30
job: certbot renew --post-hook "systemctl reload nginx"
2022-01-21 00:40:30 +03:30
2022-01-01 21:29:35 +03:30