diff --git a/plays/commonlib/vars.yml b/plays/commonlib/vars.yml index 4fede34..fbca40f 100644 --- a/plays/commonlib/vars.yml +++ b/plays/commonlib/vars.yml @@ -14,16 +14,6 @@ include_vars: file: "{{ plugin_config_root }}/vars.yml" -- name: Export internal deployment variables - set_fact: - 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: path: "{{ app_config_root }}/config.yml" @@ -35,10 +25,6 @@ include_vars: file: "{{ app_config_root }}/config.yml" -- name: CONFIG DEBUG - debug: - msg: "{{ vars }}" - - name: Check if an application vault directory exists stat: path: "{{ app_config_root }}/vault" @@ -50,11 +36,25 @@ include_vars: ignore_unknown_extensions: true dir: "{{ app_config_root }}/vault" - name: "vault" extensions: - yml register: vault_include -- name: Load vault variables into vault dictionary +- name: Create the variable dictionaries set_fact: - vault: "{{ vault_include.ansible_facts.vault }}" + config: + { + "vars": "{{ lookup('vars', 'vars.vars', default=[]) }}", + "db": "{{ lookup('vars', 'vars.db', default=[]) }}", + "env": "{{ lookup('vars', 'vars.env', default=[]) }}", + "volumes": "{{ lookup('vars', 'vars.volumes', default=[]) }}", + "templates": "{{ lookup('vars', 'vars.templates', default=[]) }}", + "vault": "{{ vault_include.ansible_facts.vault }}", + } + dokku: + { + app: "{{ app }}", + mariadb_addr: "dokku-mariadb-{{ app }}", + mariadb_user: "mariadb", + hostname: "{{ lookup('file', '/home/dokku/HOSTNAME') }}", + } diff --git a/plays/postdelete/lib/database.yml b/plays/postdelete/lib/database.yml index dbee291..e5c79b0 100644 --- a/plays/postdelete/lib/database.yml +++ b/plays/postdelete/lib/database.yml @@ -4,5 +4,5 @@ shell: "dokku {{ item.type }}:destroy {{ dokku.app }} --force" args: removes: "/var/lib/dokku/services/{{ item.type }}/{{ dokku.app }}" - with_items: "{{ db }}" - when: db is defined + with_items: "{{ config.db }}" + when: config.db diff --git a/plays/postdeploy/lib/http.yml b/plays/postdeploy/lib/http.yml index c084fb9..98d46c5 100644 --- a/plays/postdeploy/lib/http.yml +++ b/plays/postdeploy/lib/http.yml @@ -3,5 +3,5 @@ dokku_ports: app: "{{ dokku.app }}" mappings: - - "http:80:{{ vars.port }}" + - "http:80:{{ config.vars.port }}" state: present diff --git a/plays/postdeploy/lib/https.yml b/plays/postdeploy/lib/https.yml index ad6a9d4..48def34 100644 --- a/plays/postdeploy/lib/https.yml +++ b/plays/postdeploy/lib/https.yml @@ -13,5 +13,5 @@ dokku_ports: app: "{{ dokku.app }}" mappings: - - "https:443:{{ vars.port }}" + - "https:443:{{ config.vars.port }}" state: present diff --git a/plays/postdeploy/lib/proxy.yml b/plays/postdeploy/lib/proxy.yml index aea54f2..75377af 100644 --- a/plays/postdeploy/lib/proxy.yml +++ b/plays/postdeploy/lib/proxy.yml @@ -3,5 +3,5 @@ dokku_ports: app: "{{ dokku.app }}" mappings: - - "http:{{ vars.port }}:{{ vars.port }}" + - "http:{{ config.vars.port }}:{{ config.vars.port }}" state: absent diff --git a/plays/predeploy/lib/database.yml b/plays/predeploy/lib/database.yml index b5612c2..dbdf2b7 100644 --- a/plays/predeploy/lib/database.yml +++ b/plays/predeploy/lib/database.yml @@ -1,9 +1,10 @@ --- - name: Set database facts + no_log: true set_fact: mount_map: mariadb: /var/lib/mysql - when: db is defined + when: config.db - name: "Create {{ item.type }} database" no_log: true @@ -16,8 +17,8 @@ " args: creates: "/var/lib/dokku/services/{{ item.type }}/{{ dokku.app }}" - with_items: "{{ db }}" - when: db is defined + with_items: "{{ config.db }}" + when: config.db - name: "Link {{ item.type }} database to application" no_log: true @@ -25,13 +26,14 @@ app: "{{ dokku.app }}" name: "{{ dokku.app }}" service: "{{ item.type }}" - with_items: "{{ db }}" - when: db is defined + with_items: "{{ config.db }}" + when: config.db - name: "Specify {{ item.type }} volume mounts" + no_log: true dokku_storage: app: "{{ dokku.app }}" mounts: - "/var/lib/dokku/services/{{ item.type }}/{{ dokku.app }}:{{ mount_map[item.type] }}" - with_items: "{{ db }}" - when: db is defined + with_items: "{{ config.db }}" + when: config.db diff --git a/plays/predeploy/lib/domain.yml b/plays/predeploy/lib/domain.yml index 45fe974..1dbc99b 100644 --- a/plays/predeploy/lib/domain.yml +++ b/plays/predeploy/lib/domain.yml @@ -1,8 +1,8 @@ --- -- name: "Configure {{ vars.domain }} dedicated domain" +- name: "Configure {{ config.vars.domain }} dedicated domain" dokku_domains: app: "{{ dokku.app }}" domains: - - "{{ vars.domain }}" + - "{{ config.vars.domain }}" state: present - when: vars.domain is defined + when: "'domain' in config.vars" diff --git a/plays/predeploy/lib/env.yml b/plays/predeploy/lib/env.yml index c3dcebc..6a79d8b 100644 --- a/plays/predeploy/lib/env.yml +++ b/plays/predeploy/lib/env.yml @@ -3,5 +3,5 @@ dokku_config: app: "{{ dokku.app }}" restart: false - config: "{{ env }}" - when: env is defined + config: "{{ config.env }}" + when: config.env diff --git a/plays/predeploy/lib/templates.yml b/plays/predeploy/lib/templates.yml index b4dbd6c..0b91185 100644 --- a/plays/predeploy/lib/templates.yml +++ b/plays/predeploy/lib/templates.yml @@ -5,5 +5,5 @@ dest: "{{ item.dest }}" owner: dokku group: dokku - with_items: "{{ templates }}" - when: templates is defined + with_items: "{{ config.templates }}" + when: config.templates diff --git a/plays/predeploy/lib/volumes.yml b/plays/predeploy/lib/volumes.yml index 1a71dd7..d4d4a07 100644 --- a/plays/predeploy/lib/volumes.yml +++ b/plays/predeploy/lib/volumes.yml @@ -6,12 +6,12 @@ state: directory owner: dokku group: dokku - with_items: "{{ mounts }}" - when: mounts is defined + with_items: "{{ config.volumes }}" + when: config.volumes - name: Attach volume mounts dokku_storage: - app: "{{ app }}" + app: "{{ dokku.app }}" mounts: "{{ item }}" - with_items: "{{ mounts }}" - when: mounts is defined + with_items: "{{ config.volumes }}" + when: config.volumes