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 - name: Check if internal system variables exists
stat: stat:
path: "{{ plugin_config_root }}/vars.yml" path: "{{ plugin_config_root }}/vars.yml"
@ -12,9 +16,13 @@
- name: Export internal deployment variables - name: Export internal deployment variables
set_fact: set_fact:
dokku_mariadb_db_addr: "dokku-mariadb-{{ app }}" dokku:
dokku_mariadb_db_user: "mariadb" {
dokku_hostname: "{{ lookup('file', '/home/dokku/HOSTNAME') }}" app: "{{ app }}",
mariadb_addr: "dokku-mariadb-{{ app }}",
mariadb_user: "mariadb",
hostname: "{{ lookup('file', '/home/dokku/HOSTNAME') }}",
}
- name: Check if the application config file exists - name: Check if the application config file exists
stat: stat:
@ -26,6 +34,7 @@
when: config_yml.stat.exists when: config_yml.stat.exists
include_vars: include_vars:
file: "{{ app_config_root }}/config.yml" file: "{{ app_config_root }}/config.yml"
name: "config"
- name: Check if an application vault directory exists - name: Check if an application vault directory exists
stat: stat:
@ -38,5 +47,6 @@
include_vars: include_vars:
ignore_unknown_extensions: true ignore_unknown_extensions: true
dir: "{{ app_config_root }}/vault" dir: "{{ app_config_root }}/vault"
name: "vault"
extensions: extensions:
- yml - yml

View File

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

View File

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

View File

@ -1,17 +1,17 @@
--- ---
- name: Setup lets encrypt certificates - name: Setup lets encrypt certificates
shell: "dokku letsencrypt {{ app }}" shell: "dokku letsencrypt {{ dokku.app }}"
args: args:
creates: "/home/dokku/{{ app }}/letsencrypt/certs" creates: "/home/dokku/{{ dokku.app }}/letsencrypt/certs"
- name: Setup lets encrypt certificates renew cron job - name: Setup lets encrypt certificates renew cron job
shell: dokku letsencrypt:cron-job --add shell: dokku letsencrypt:cron-job --add
args: args:
creates: "/home/dokku/{{ app }}/letsencrypt/cron-job" creates: "/home/dokku/{{ dokku.app }}/letsencrypt/cron-job"
- name: Set HTTP 443 port - name: Set HTTP 443 port
dokku_ports: dokku_ports:
app: "{{ app }}" app: "{{ dokku.app }}"
mappings: mappings:
- "https:443:{{ port }}" - "https:443:{{ vars.port }}"
state: present 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 - name: Create nginx customisation directory
become: true become: true
file: file:
path: "/home/dokku/{{ app }}/nginx.conf.d/" path: "/home/dokku/{{ dokku.app }}/nginx.conf.d/"
state: directory state: directory
owner: dokku owner: dokku
group: dokku group: dokku
when: custom_nginx_d.stat.exists
- name: Copy over the nginx custom configuration - name: Copy over the nginx custom configuration
become: true become: true
template: template:
src: "{{ item }}" src: "{{ item }}"
dest: "/home/dokku/{{ app }}/nginx.conf.d/{{ item | basename }}" dest: "/home/dokku/{{ dokku.app }}/nginx.conf.d/{{ item | basename }}"
owner: dokku owner: dokku
group: dokku group: dokku
with_fileglob: with_fileglob:
- "{{ app_config_root }}/nginx.d/*.conf" - "{{ app_config_root }}/nginx.d/*.conf"
when: custom_nginx_d.stat.exists
- name: Reload nginx to enable custom configurations - name: Reload nginx to enable custom configurations
become: true become: true
service: service:
name: nginx name: nginx
state: reloaded state: reloaded
when: custom_nginx_d.stat.exists

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
--- ---
- name: Configure the app environment - name: Configure the app environment
dokku_config: dokku_config:
app: "{{ app }}" app: "{{ dokku.app }}"
restart: false restart: false
config: "{{ env }}" config: "{{ env }}"
when: env is defined 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/domain.yml
- include: ./lib/database.yml - include: ./lib/database.yml
- include: ./lib/volumes.yml - include: ./lib/volumes.yml
- include: ./lib/templates.yml
- include: ./lib/env.yml - include: ./lib/env.yml
- include: ./lib/hooks.yml - include: ./lib/hooks.yml