Take another pass at wiring up steps

This commit is contained in:
Luke Murphy 2020-04-13 15:02:55 +02:00
parent 010b3fa863
commit ccaf036248
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
6 changed files with 91 additions and 45 deletions

View File

@ -1,30 +1,34 @@
--- ---
- name: Setup preparatory facts
set_fact:
db_type: "{{ db['type'] }}"
mount_map:
mariadb: /var/lib/mysql
- name: "Create {{ db_type }} database" - name: Run database setup tasks
no_log: true when: db is defined
shell: " block:
dokku - name: Setup preparatory facts
{{ db_type }}:create set_fact:
{{ app }} db_type: "{{ db.type }}"
--password {{ db_passwd }} mount_map:
--root-password {{ root_db_passwd }} mariadb: /var/lib/mysql
"
args:
creates: "/var/lib/dokku/services/{{ db_type }}/{{ app }}"
- name: Link mariadb database to application - name: "Create {{ db_type }} database"
dokku_service_link: no_log: true
app: "{{ app }}" shell: "
name: "{{ app }}" dokku
service: "{{ db_type }}" {{ db_type }}:create
{{ app }}
--password {{ db_passwd }}
--root-password {{ root_db_passwd }}
"
args:
creates: "/var/lib/dokku/services/{{ db_type }}/{{ app }}"
- name: "Specify {{ db_type }} volume mounts" - name: Link mariadb database to application
dokku_storage: dokku_service_link:
app: "{{ app }}" app: "{{ app }}"
mounts: name: "{{ app }}"
- "/var/lib/dokku/services/{{ db_type }}/{{ app }}:{{ mount_map[db_type] }}" service: "{{ db_type }}"
- name: "Specify {{ db_type }} volume mounts"
dokku_storage:
app: "{{ app }}"
mounts:
- "/var/lib/dokku/services/{{ db_type }}/{{ app }}:{{ mount_map[db_type] }}"

View File

@ -1,8 +1,23 @@
--- ---
- name: "Configure {{ domain }} domain with Dokku" - name: "Configure {{ domain }} dedicated domain"
dokku_domains: dokku_domains:
app: "{{ app }}" app: "{{ app }}"
domains: domains:
- "{{ domain }}" - "{{ domain }}"
state: present state: present
when: domain is defined when: domain is defined
- name: Provide information on domain configuration
debug:
msg:
- "Dedicated domain discovered for the deployment of {{ app }}"
- "Your application will be available at https://{{ domain }}"
when: domain is defined
- name: Provide information on sub-domain configuration
debug:
msg:
- "No dedicated domain configured for the deployment of {{ app }}"
- "Dokku will provide a sub-domain configuration"
- "Your application will be available at https://{{ app }}.{{ dokku_hostname }}"
when: domain is not defined

9
plays/lib/prepare.yml Normal file
View File

@ -0,0 +1,9 @@
---
# Note(decentral1se): to avoid exploding when we import the config.yml from the
# end-user, we spoof out variables that are referenced there but not populated
# already (due to the order of the tasks we define for our deployment steps)
- name: Export variable placeholders
set_fact:
dokku_db_addr: ""
dokku_db_user: ""
dokku_hostname: "{{ lookup('file', '/home/dokku/HOSTNAME') }}"

View File

@ -8,5 +8,5 @@
- yaml - yaml
with_items: with_items:
- "{{ plugin_config_root }}" - "{{ plugin_config_root }}"
# - "{{ app_config_root }}" - "{{ app_config_root }}/vault"
# - "{{ app_config_root }}/vault" - "{{ app_config_root }}"

View File

@ -2,15 +2,22 @@
- hosts: all - hosts: all
gather_facts: false gather_facts: false
tasks: tasks:
- name: Include vars tasks # Note(decentral1se): internal debugging. Please `debug: true` in the
include: ./lib/vars.yml # /var/lib/dokku/data/deploy.d/vars.yml file to activate a debug vars dump
- name: Include debug tasks - name: Include debug tasks
include: ./lib/debug.yml include: ./lib/debug.yml
# - name: Include http tasks
# include: ./lib/http.yml - name: Include vars tasks
# - name: Include certs tasks include: ./lib/vars.yml
# include: ./lib/certs.yml
# - name: Include proxy tasks - name: Include http tasks
# include: ./lib/proxy.yml include: ./lib/http.yml
# - name: Include https tasks
# include: ./lib/https.yml - name: Include certs tasks
include: ./lib/certs.yml
- name: Include proxy tasks
include: ./lib/proxy.yml
- name: Include https tasks
include: ./lib/https.yml

View File

@ -2,11 +2,22 @@
- hosts: all - hosts: all
gather_facts: false gather_facts: false
tasks: tasks:
- name: Include vars tasks # Note(decentral1se): internal debugging. Please `debug: true` in the
include: ./lib/vars.yml # /var/lib/dokku/data/deploy.d/vars.yml file to activate a debug vars dump
- name: Include debug tasks - name: Include debug tasks
include: ./lib/debug.yml include: ./lib/debug.yml
# - name: Include domain tasks
# include: ./lib/domain.yml - name: Include prepare tasks
# - name: Include env tasks include: ./lib/prepare.yml
# include: ./lib/env.yml
- name: Include vars tasks
include: ./lib/vars.yml
- name: Include domain tasks
include: ./lib/domain.yml
- name: Include database tasks
include: ./lib/db.yml
- name: Include env tasks
include: ./lib/env.yml