diff --git a/plays/lib/database.yml b/plays/lib/database.yml index a47aa1d..f5086f5 100644 --- a/plays/lib/database.yml +++ b/plays/lib/database.yml @@ -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" - no_log: true - shell: " - dokku - {{ db_type }}:create - {{ app }} - --password {{ db_passwd }} - --root-password {{ root_db_passwd }} - " - args: - creates: "/var/lib/dokku/services/{{ db_type }}/{{ app }}" +- name: Run database setup tasks + when: db is defined + block: + - name: Setup preparatory facts + set_fact: + db_type: "{{ db.type }}" + mount_map: + mariadb: /var/lib/mysql -- name: Link mariadb database to application - dokku_service_link: - app: "{{ app }}" - name: "{{ app }}" - service: "{{ db_type }}" + - name: "Create {{ db_type }} database" + no_log: true + shell: " + dokku + {{ 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" - dokku_storage: - app: "{{ app }}" - mounts: - - "/var/lib/dokku/services/{{ db_type }}/{{ app }}:{{ mount_map[db_type] }}" + - name: Link mariadb database to application + dokku_service_link: + app: "{{ app }}" + name: "{{ app }}" + 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] }}" diff --git a/plays/lib/domain.yml b/plays/lib/domain.yml index 6709eba..7b7b2d6 100644 --- a/plays/lib/domain.yml +++ b/plays/lib/domain.yml @@ -1,8 +1,23 @@ --- -- name: "Configure {{ domain }} domain with Dokku" +- name: "Configure {{ domain }} dedicated domain" dokku_domains: app: "{{ app }}" domains: - "{{ domain }}" state: present 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 diff --git a/plays/lib/prepare.yml b/plays/lib/prepare.yml new file mode 100644 index 0000000..8dbefcb --- /dev/null +++ b/plays/lib/prepare.yml @@ -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') }}" diff --git a/plays/lib/vars.yml b/plays/lib/vars.yml index e3d2c2c..2e18be3 100644 --- a/plays/lib/vars.yml +++ b/plays/lib/vars.yml @@ -8,5 +8,5 @@ - yaml with_items: - "{{ plugin_config_root }}" - # - "{{ app_config_root }}" - # - "{{ app_config_root }}/vault" + - "{{ app_config_root }}/vault" + - "{{ app_config_root }}" diff --git a/plays/post_deploy.yml b/plays/post_deploy.yml index e452b32..3ba6c38 100644 --- a/plays/post_deploy.yml +++ b/plays/post_deploy.yml @@ -2,15 +2,22 @@ - hosts: all gather_facts: false tasks: - - name: Include vars tasks - include: ./lib/vars.yml + # Note(decentral1se): internal debugging. Please `debug: true` in the + # /var/lib/dokku/data/deploy.d/vars.yml file to activate a debug vars dump - name: Include debug tasks include: ./lib/debug.yml - # - name: Include http tasks - # include: ./lib/http.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 + + - name: Include vars tasks + include: ./lib/vars.yml + + - name: Include http tasks + include: ./lib/http.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 diff --git a/plays/pre_deploy.yml b/plays/pre_deploy.yml index c6dfc1c..1cd0f21 100644 --- a/plays/pre_deploy.yml +++ b/plays/pre_deploy.yml @@ -2,11 +2,22 @@ - hosts: all gather_facts: false tasks: - - name: Include vars tasks - include: ./lib/vars.yml + # Note(decentral1se): internal debugging. Please `debug: true` in the + # /var/lib/dokku/data/deploy.d/vars.yml file to activate a debug vars dump - name: Include debug tasks include: ./lib/debug.yml - # - name: Include domain tasks - # include: ./lib/domain.yml - # - name: Include env tasks - # include: ./lib/env.yml + + - name: Include prepare tasks + include: ./lib/prepare.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