Adapt to more scoped config

This commit is contained in:
Luke Murphy 2020-04-14 13:02:16 +02:00
parent ddaa516e38
commit 22e15e4b50
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
11 changed files with 55 additions and 27 deletions

View File

@ -1,4 +1,8 @@
---
# Note(decentral1se): please note that the majority of the vars that are
# referenced in this play are passed in via --extra-vars definitions in the
# functions script
- name: Check if internal system variables exists
stat:
path: "{{ plugin_config_root }}/vars.yml"
@ -12,9 +16,13 @@
- name: Export internal deployment variables
set_fact:
dokku_mariadb_db_addr: "dokku-mariadb-{{ app }}"
dokku_mariadb_db_user: "mariadb"
dokku_hostname: "{{ lookup('file', '/home/dokku/HOSTNAME') }}"
dokku:
{
app: "{{ app }}",
mariadb_addr: "dokku-mariadb-{{ app }}",
mariadb_user: "mariadb",
hostname: "{{ lookup('file', '/home/dokku/HOSTNAME') }}",
}
- name: Check if the application config file exists
stat:
@ -26,6 +34,7 @@
when: config_yml.stat.exists
include_vars:
file: "{{ app_config_root }}/config.yml"
name: "config"
- name: Check if an application vault directory exists
stat:
@ -38,5 +47,6 @@
include_vars:
ignore_unknown_extensions: true
dir: "{{ app_config_root }}/vault"
name: "vault"
extensions:
- yml

View File

@ -1,7 +1,7 @@
---
- name: Remove database(s)
shell: "dokku {{ item.type }}:destroy {{ app }} --force"
shell: "dokku {{ item.type }}:destroy {{ dokku.app }} --force"
args:
removes: "/var/lib/dokku/services/{{ item.type }}/{{ app }}"
removes: "/var/lib/dokku/services/{{ item.type }}/{{ dokku.app }}"
with_items: "{{ db }}"
when: db is defined

View File

@ -1,7 +1,7 @@
---
- name: Set HTTP 80 port proxy
dokku_ports:
app: "{{ app }}"
app: "{{ dokku.app }}"
mappings:
- "http:80:{{ port }}"
- "http:80:{{ vars.port }}"
state: present

View File

@ -1,17 +1,17 @@
---
- name: Setup lets encrypt certificates
shell: "dokku letsencrypt {{ app }}"
shell: "dokku letsencrypt {{ dokku.app }}"
args:
creates: "/home/dokku/{{ app }}/letsencrypt/certs"
creates: "/home/dokku/{{ dokku.app }}/letsencrypt/certs"
- name: Setup lets encrypt certificates renew cron job
shell: dokku letsencrypt:cron-job --add
args:
creates: "/home/dokku/{{ app }}/letsencrypt/cron-job"
creates: "/home/dokku/{{ dokku.app }}/letsencrypt/cron-job"
- name: Set HTTP 443 port
dokku_ports:
app: "{{ app }}"
app: "{{ dokku.app }}"
mappings:
- "https:443:{{ port }}"
- "https:443:{{ vars.port }}"
state: present

View File

@ -1,24 +1,32 @@
---
- name: Check if a custom nginx directory exists
stat:
path: "{{ app_config_root }}/nginx.d/"
register: custom_nginx_d
- name: Create nginx customisation directory
become: true
file:
path: "/home/dokku/{{ app }}/nginx.conf.d/"
path: "/home/dokku/{{ dokku.app }}/nginx.conf.d/"
state: directory
owner: dokku
group: dokku
when: custom_nginx_d.stat.exists
- name: Copy over the nginx custom configuration
become: true
template:
src: "{{ item }}"
dest: "/home/dokku/{{ app }}/nginx.conf.d/{{ item | basename }}"
dest: "/home/dokku/{{ dokku.app }}/nginx.conf.d/{{ item | basename }}"
owner: dokku
group: dokku
with_fileglob:
- "{{ app_config_root }}/nginx.d/*.conf"
when: custom_nginx_d.stat.exists
- name: Reload nginx to enable custom configurations
become: true
service:
name: nginx
state: reloaded
when: custom_nginx_d.stat.exists

View File

@ -1,7 +1,7 @@
---
- name: Remove automatically configured ports
dokku_ports:
app: "{{ app }}"
app: "{{ dokku.app }}"
mappings:
- "http:{{ port }}:{{ port }}"
- "http:{{ vars.port }}:{{ vars.port }}"
state: absent

View File

@ -10,27 +10,27 @@
shell: "
dokku
{{ item.type }}:create
{{ app }}
{{ dokku.app }}
--password {{ item.passwd }}
--root-password {{ item.root_passwd }}
"
args:
creates: "/var/lib/dokku/services/{{ item.type }}/{{ app }}"
creates: "/var/lib/dokku/services/{{ item.type }}/{{ dokku.app }}"
with_items: "{{ db }}"
when: db is defined
- name: "Link {{ item.type }} database to application"
dokku_service_link:
app: "{{ app }}"
name: "{{ app }}"
app: "{{ dokku.app }}"
name: "{{ dokku.app }}"
service: "{{ item.type }}"
with_items: "{{ db }}"
when: db is defined
- name: "Specify {{ item.type }} volume mounts"
dokku_storage:
app: "{{ app }}"
app: "{{ dokku.app }}"
mounts:
- "/var/lib/dokku/services/{{ item.type }}/{{ app }}:{{ mount_map[item.type] }}"
- "/var/lib/dokku/services/{{ item.type }}/{{ dokku.app }}:{{ mount_map[item.type] }}"
with_items: "{{ db }}"
when: db is defined

View File

@ -1,8 +1,8 @@
---
- name: "Configure {{ domain }} dedicated domain"
- name: "Configure {{ vars.domain }} dedicated domain"
dokku_domains:
app: "{{ app }}"
app: "{{ dokku.app }}"
domains:
- "{{ domain }}"
- "{{ vars.domain }}"
state: present
when: domain is defined
when: vars.domain is defined

View File

@ -1,7 +1,7 @@
---
- name: Configure the app environment
dokku_config:
app: "{{ app }}"
app: "{{ dokku.app }}"
restart: false
config: "{{ env }}"
when: env is defined

View File

@ -0,0 +1,9 @@
---
- name: Copy over template files
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: dokku
group: dokku
with_items: "{{ templates }}"
when: templates is defined

View File

@ -6,5 +6,6 @@
- include: ./lib/domain.yml
- include: ./lib/database.yml
- include: ./lib/volumes.yml
- include: ./lib/templates.yml
- include: ./lib/env.yml
- include: ./lib/hooks.yml