From 758a9abcd4cdd5e07f8eba48ba11c479963ae830 Mon Sep 17 00:00:00 2001 From: Arvydas Silanskas Date: Mon, 15 Jul 2024 22:09:39 +0300 Subject: [PATCH] add ansible --- deploy/README.adoc | 6 ++++++ deploy/deploy.yml | 21 +++++++++++++++++++++ deploy/hosts | 7 +++++++ deploy/template/scheme_index.conf | 15 +++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 deploy/README.adoc create mode 100644 deploy/deploy.yml create mode 100644 deploy/hosts create mode 100644 deploy/template/scheme_index.conf diff --git a/deploy/README.adoc b/deploy/README.adoc new file mode 100644 index 0000000..8fc2c29 --- /dev/null +++ b/deploy/README.adoc @@ -0,0 +1,6 @@ += Ansible deployment of the static site + +This folder contains deployment playbook. It is presumed that target uses nginx and systemd. + +. Build the static site (see ../build folder) +. Invoke `ansible-playbook -i hosts deploy.yml -e content_zip_file=../build/schemeindex.zip` from this directory diff --git a/deploy/deploy.yml b/deploy/deploy.yml new file mode 100644 index 0000000..462b321 --- /dev/null +++ b/deploy/deploy.yml @@ -0,0 +1,21 @@ +--- +- name: 'Deploy scheme index' + hosts: index.scheme.org + tasks: + - name: 'Upload nginx config' + template: + src: 'template/scheme_index.conf' + dest: '{{nginx_conf_d_location}}/scheme_index.conf' + - name: 'Ensure content root exists' + file: + name: '{{root_location}}' + state: 'directory' + - name: 'Upload scheme index content' + unarchive: + src: '{{content_zip_file}}' + dest: '{{root_location}}' + - name: 'Reload nginx service' + systemd_service: + name: 'nginx' + state: 'reloaded' + diff --git a/deploy/hosts b/deploy/hosts new file mode 100644 index 0000000..d4b44dc --- /dev/null +++ b/deploy/hosts @@ -0,0 +1,7 @@ +all: + hosts: + index.scheme.org: + ansible_user: root + certs_location: /etc/letsencrypt/live/index.scheme.org/ + nginx_conf_d_location: /etc/nginx/conf.d + root_location: /var/www/scheme_index diff --git a/deploy/template/scheme_index.conf b/deploy/template/scheme_index.conf new file mode 100644 index 0000000..699d27b --- /dev/null +++ b/deploy/template/scheme_index.conf @@ -0,0 +1,15 @@ +server { + + listen 1443 ssl; + server_name index.scheme.org; + ssl_certificate {{certs_location}}/fullchain.pem; + ssl_certificate_key {{certs_location}}/privkey.pem; + + root {{root_location}}; + index index.html; + + location / { + try_files $uri index.html; + } + +}