From 584360421bc9ccceb09c4b2b2fffec9e6bfa2aa2 Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Tue, 14 Apr 2020 11:13:06 +0200 Subject: [PATCH] Drop debug, names and use with_items for db tasks --- plays/lib/database.yml | 55 +++++++++++++++++++++--------------------- plays/lib/debug.yml | 5 ---- plays/post_delete.yml | 15 ++---------- plays/post_deploy.yml | 25 ++++--------------- plays/pre_deploy.yml | 31 +++++------------------- 5 files changed, 41 insertions(+), 90 deletions(-) delete mode 100644 plays/lib/debug.yml diff --git a/plays/lib/database.yml b/plays/lib/database.yml index b59ce01..bfe4303 100644 --- a/plays/lib/database.yml +++ b/plays/lib/database.yml @@ -1,31 +1,32 @@ --- -- name: Run database setup tasks - block: - - name: Set database facts - set_fact: - mount_map: - mariadb: /var/lib/mysql +- name: Set database facts + set_fact: + mount_map: + mariadb: /var/lib/mysql - - name: "Create {{ store.type }} database" - no_log: true - shell: " - dokku - {{ store.type }}:create - {{ app }} - --password {{ store.passwd }} - --root-password {{ store.root_passwd }} - " - args: - creates: "/var/lib/dokku/services/{{ store.type }}/{{ app }}" +- name: "Create {{ item.type }} database" + no_log: true + shell: " + dokku + {{ item.type }}:create + {{ app }} + --password {{ item.passwd }} + --root-password {{ item.root_passwd }} + " + args: + creates: "/var/lib/dokku/services/{{ item.type }}/{{ app }}" + with_items: "{{ db }}" - - name: "Link {{ store.type }} database to application" - dokku_service_link: - app: "{{ app }}" - name: "{{ app }}" - service: "{{ store.type }}" +- name: "Link {{ item.type }} database to application" + dokku_service_link: + app: "{{ app }}" + name: "{{ app }}" + service: "{{ item.type }}" + with_items: "{{ db }}" - - name: "Specify {{ store.type }} volume mounts" - dokku_storage: - app: "{{ app }}" - mounts: - - "/var/lib/dokku/services/{{ store.type }}/{{ app }}:{{ mount_map[store.type] }}" +- name: "Specify {{ item.type }} volume mounts" + dokku_storage: + app: "{{ app }}" + mounts: + - "/var/lib/dokku/services/{{ item.type }}/{{ app }}:{{ mount_map[item.type] }}" + with_items: "{{ db }}" diff --git a/plays/lib/debug.yml b/plays/lib/debug.yml deleted file mode 100644 index 9d238ed..0000000 --- a/plays/lib/debug.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- name: Debug all variables - debug: - msg: "{{ vars }}" - when: debug diff --git a/plays/post_delete.yml b/plays/post_delete.yml index cb02a9e..59d417d 100644 --- a/plays/post_delete.yml +++ b/plays/post_delete.yml @@ -2,23 +2,12 @@ - hosts: all gather_facts: false tasks: - - name: Include prepare tasks - include: ./lib/prepare.yml - - - 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 - when: debug is defined - + - include: ./lib/prepare.yml + - include: ./lib/vars.yml - name: Remove deploy.d folder file: path: "{{ app_config_root }}" state: absent - - name: Remove database(s) shell: "dokku {{ item.type }}:destroy {{ app }} --force" args: diff --git a/plays/post_deploy.yml b/plays/post_deploy.yml index f3d0de0..0322d3a 100644 --- a/plays/post_deploy.yml +++ b/plays/post_deploy.yml @@ -2,23 +2,8 @@ - hosts: all gather_facts: false tasks: - - name: Include prepare tasks - include: ./lib/prepare.yml - - - 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 - when: debug is defined - - - name: Include http tasks - include: ./lib/http.yml - - - name: Include https tasks - include: ./lib/https.yml - - - name: Include proxy tasks - include: ./lib/proxy.yml + - include: ./lib/prepare.yml + - include: ./lib/vars.yml + - include: ./lib/http.yml + - include: ./lib/https.yml + - include: ./lib/proxy.yml diff --git a/plays/pre_deploy.yml b/plays/pre_deploy.yml index 176f08c..ae67d59 100644 --- a/plays/pre_deploy.yml +++ b/plays/pre_deploy.yml @@ -2,28 +2,9 @@ - hosts: all gather_facts: false tasks: - - name: Include prepare tasks - include: ./lib/prepare.yml - - - 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 - when: debug is defined - - - name: Include domain tasks - include: ./lib/domain.yml - - - name: Include database tasks - include: ./lib/database.yml store={{ item }} - with_items: "{{ db }}" - when: db is defined - - - name: Include volume tasks - include: ./lib/volumes.yml - - - name: Include env tasks - include: ./lib/env.yml + - include: ./lib/prepare.yml + - include: ./lib/vars.yml + - include: ./lib/domain.yml + - include: ./lib/database.yml + - include: ./lib/volumes.yml + - include: ./lib/env.yml