diff --git a/host_vars/gabriel.c3heaven.de b/host_vars/gabriel.c3heaven.de index 5c6cabf9e40956ae86fbfbe58a8fa28a71003b41..eff4a1eb96ce252e317721c9499a307f94be2093 100644 --- a/host_vars/gabriel.c3heaven.de +++ b/host_vars/gabriel.c3heaven.de @@ -11,12 +11,13 @@ acmetool_cert_domains: - www.c3heaven.de angelguide_deployment_path: "/var/www/angelguide" +website_deployment_path: "/var/www/static" nginx_https_sites: - name: "c3heaven.de" locations: - location: "/" - config: "root /var/www/html;" + config: "root {{ website_deployment_path }};" - location: "~ /wiki(.*)$" config: "return 301 https://wiki.c3heaven.de$1?$args;" - location: "~ /kanboard(.*)$" diff --git a/roles/website-deployment/defaults/main.yml b/roles/website-deployment/defaults/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..621d685e2a0343a3a3269fabd1e51743cdf2734e --- /dev/null +++ b/roles/website-deployment/defaults/main.yml @@ -0,0 +1,4 @@ +website_deployment_user: website +website_deployment_path: /var/www/static +website_deployment_keys: + - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMW+8/hse/foM2TWgM5MA6LuT4A/eb0/biFUQwLt85nN diff --git a/roles/website-deployment/tasks/main.yml b/roles/website-deployment/tasks/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..bf97a123e648564d85388c352750f93dd892497d --- /dev/null +++ b/roles/website-deployment/tasks/main.yml @@ -0,0 +1,16 @@ +- name: create website deployment user + user: + name: "{{ website_deployment_user }}" + home: "{{ website_deployment_path }}" + system: yes + shell: /bin/sh + +- name: create .ssh directory for the website user + file: + path: "{{ website_deployment_path }}/.ssh" + state: directory + +- name: copy website deployment ssh keys + template: + src: authorized_keys.j2 + dest: "{{ website_deployment_path }}/.ssh/authorized_keys" diff --git a/roles/website-deployment/templates/authorized_keys.j2 b/roles/website-deployment/templates/authorized_keys.j2 new file mode 100644 index 0000000000000000000000000000000000000000..a298faa9736651717577db3e6c50a0cbee29188b --- /dev/null +++ b/roles/website-deployment/templates/authorized_keys.j2 @@ -0,0 +1,3 @@ +{% for key in website_deployment_keys %} +command="/usr/local/bin/rrsync {{ website_deployment_path }}",no-agent-forwarding,no-port-forwarding,no-pty,no-user-rc,no-X11-forwarding {{ key }} +{% endfor %} diff --git a/web-ci-deployment.yml b/web-ci-deployment.yml index 56cc715207a63d96a5655cfd0e5311a04f371a38..c4e756a5f5527457300e595ffc45a4dfc7346fad 100644 --- a/web-ci-deployment.yml +++ b/web-ci-deployment.yml @@ -1,8 +1,9 @@ # Add directories, users, SSH keys etc. needed for automatic web deployment # of e.g. the angel guide via Gitlab CI -- name: allow angelguide deployment +- name: allow website and angelguide deployment hosts: gabriel.c3heaven.de become: yes roles: - angelguide-deployment + - website-deployment