This repository has been archived on 2021-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
ansible-role-launch-container/roles/nginxproxy/tasks/main.yml

34 lines
790 B
YAML

---
# Tasks to be run inside the Nginx proxy container
- set_fact:
container: '{{ nombre | urlencode | lower | regex_replace("_", "-") }}'
- name: Create basic Nginx config for new container
template:
src: newsite.conf.j2
dest: '/etc/nginx/conf.d/{{ container }}.{{ dominio }}.conf'
- name: Create folder for Let's Encrypt files
file:
path: '/var/www/{{ container }}'
state: directory
owner: www-data
group: www-data
mode: '0755'
- name: Restart Nginx
systemd:
name: nginx
state: restarted
- name: Request Let's Encrypt certificate
command:
cmd: 'certbot --redirect --agree-tos -m {{ email }} --hsts --nginx -n -d {{ nombre | lower }}.{{ dominio }}'
- name: Restart Nginx again
systemd:
name: nginx
state: restarted