Deploying 2012.pycon.fr.

This commit is contained in:
Julien Palard 2019-02-12 23:40:05 +01:00
parent 35816beeca
commit c31ae804ee
7 changed files with 86 additions and 0 deletions

View File

@ -27,3 +27,11 @@
pelican_repo: https://github.com/AFPy/pyconfr_2010
pelican_path_in_repo: 2011/
pelican_home: "/srv/{{ pelican_user }}/"
- hosts: pycons
roles: [static]
vars:
static_user: pycon2012
static_https: true
static_domain: 2012.pycon.fr
static_repo: https://github.com/AFPy/pyconfr_2012

View File

@ -0,0 +1,6 @@
static_user: pycon2010
static_https: false
static_domain: some_static_website.pycon.fr
static_repo: https://github.com/AFPy/pyconfr_2010
static_path_in_repo: 2010/
static_home: "/srv/{{ static_user }}/"

View File

@ -0,0 +1,4 @@
---
- name: reload nginx
service: name=nginx state=reloaded

View File

@ -0,0 +1,4 @@
---
dependencies:
- { role: letsencrypt, domains: ["{{ static_domain }}"], when: static_https }

View File

@ -0,0 +1,4 @@
---
- include: static.yml
tags: static

View File

@ -0,0 +1,27 @@
---
- name: Install nginx and dependencies
apt:
name: [nginx, git]
- name: Create user
user:
name: "{{ static_user }}"
shell: /bin/false
system: yes
home: "{{ static_home }}"
- name: Clone repo
git:
repo: "{{ static_repo }}"
dest: "{{ static_home }}/www/"
register: clone_repo
- name: Configure nginx
template:
src: nginx-vhost
dest: "/etc/nginx/conf.d/{{ static_domain }}.conf"
owner: root
group: root
mode: 0644
notify: reload nginx

View File

@ -0,0 +1,33 @@
{% if static_https %}
server {
listen 80;
server_name {{ static_domain }};
location / {
return 301 https://{{ static_domain }}$request_uri;
}
}
server
{
listen 443 ssl;
server_name {{ static_domain }};
include snippets/letsencrypt-{{ static_domain }}.conf;
location / {
root {{ static_home }}/www/;
try_files $uri $uri/ =404;
}
}
{% else %}
server {
listen 80;
server_name {{ static_domain }};
location / {
root {{ static_home }}/www/;
try_files $uri $uri/ =404;
}
}
{% endif %}