Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ansible deployment configuration #687

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions deploy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM inducer/debian-amd64-minbase
MAINTAINER Andreas Kloeckner <[email protected]>
# EXPOSE 9941
# RUN useradd runcode

RUN echo 'APT::Default-Release "testing";' >> /etc/apt/apt.conf

RUN apt update
RUN apt -y -o APT::Install-Recommends=0 -o APT::Install-Suggests=0 install ansible python3-distutils
RUN mkdir /root/ansible
COPY *.yml /root/ansible/
COPY *.j2 /root/ansible/
RUN cd /root/ansible && ansible-playbook -i inventory.yml relate.yml

4 changes: 4 additions & 0 deletions deploy/inventory.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
webservers:
hosts:
mycontainer:
ansible_connection: local
33 changes: 33 additions & 0 deletions deploy/relate-nginx-site.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
server {
listen *:80;
listen [::]:80;
server_name {{relate_server_name}};

rewrite ^ https://$server_name$request_uri? permanent; # enforce https

add_header X-Frame-Options SAMEORIGIN;
}

server {
listen *:443 ssl;
listen [::]:443 ssl;

ssl_certificate {{ relate_cert.cert }};
ssl_certificate_key {{ relate_cert.key }};

client_max_body_size 100M;

location / {
include uwsgi_params;
uwsgi_read_timeout 300;
uwsgi_pass unix:/tmp/uwsgi-relate.sock;
}
location /static {
alias /home/relate/relate/static;
}
location /media {
alias /home/relate/relate/media;
}

add_header X-Frame-Options SAMEORIGIN;
}
31 changes: 31 additions & 0 deletions deploy/relate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
- hosts: webservers
vars:
relate_server_name: relate.localhost
self_signed_cert:
key: /etc/ssl/private/server.key
cert: /etc/ssl/certs/server.crt
relate_cert:
key: "{{ self_signed_cert.key }}"
cert: "{{ self_signed_cert.cert }}"

remote_user: root
tasks:

- name: Create self-signed certificate, if configured.
command: >
openssl req -x509 -nodes -subj '/CN={{ relate_server_name }}' -days 365
-newkey rsa:4096 -sha256 -keyout {{ self_signed_cert.key }} -out {{ self_signed_cert.cert }}
creates={{ self_signed_cert.cert }}

- name: Ensure nginx is at the latest version
apt:
name: nginx-light
state: latest

- name: Write nginx config file
template:
src: relate-nginx-site.j2
dest: /etc/nginx/sites-available/relate-nginx-site

# vim: shiftwidth=2