From 95e70fdfdd985e05a15e9c62592a0312298572c0 Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Mon, 13 Apr 2020 20:06:36 +0200 Subject: [PATCH] Try to use the with_items include syntax correctly again --- plays/lib/database.yml | 19 +++++++++---------- plays/post_delete.yml | 1 + plays/pre_deploy.yml | 6 +----- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/plays/lib/database.yml b/plays/lib/database.yml index e9d09d3..b59ce01 100644 --- a/plays/lib/database.yml +++ b/plays/lib/database.yml @@ -1,32 +1,31 @@ --- - name: Run database setup tasks - when: db is defined block: - name: Set database facts set_fact: mount_map: mariadb: /var/lib/mysql - - name: "Create {{ item.type }} database" + - name: "Create {{ store.type }} database" no_log: true shell: " dokku - {{ item.type }}:create + {{ store.type }}:create {{ app }} - --password {{ item.passwd }} - --root-password {{ item.root_passwd }} + --password {{ store.passwd }} + --root-password {{ store.root_passwd }} " args: - creates: "/var/lib/dokku/services/{{ item.type }}/{{ app }}" + creates: "/var/lib/dokku/services/{{ store.type }}/{{ app }}" - - name: "Link {{ item.type }} database to application" + - name: "Link {{ store.type }} database to application" dokku_service_link: app: "{{ app }}" name: "{{ app }}" - service: "{{ item.type }}" + service: "{{ store.type }}" - - name: "Specify {{ item.type }} volume mounts" + - name: "Specify {{ store.type }} volume mounts" dokku_storage: app: "{{ app }}" mounts: - - "/var/lib/dokku/services/{{ item.type }}/{{ app }}:{{ mount_map[item.type] }}" + - "/var/lib/dokku/services/{{ store.type }}/{{ app }}:{{ mount_map[store.type] }}" diff --git a/plays/post_delete.yml b/plays/post_delete.yml index 2aba0fd..cb02a9e 100644 --- a/plays/post_delete.yml +++ b/plays/post_delete.yml @@ -24,3 +24,4 @@ args: removes: "/var/lib/dokku/services/{{ item.type }}/{{ app }}" with_items: "{{ db }}" + when: db exists diff --git a/plays/pre_deploy.yml b/plays/pre_deploy.yml index ca6afe3..2bb4a54 100644 --- a/plays/pre_deploy.yml +++ b/plays/pre_deploy.yml @@ -17,12 +17,8 @@ - name: Include domain tasks include: ./lib/domain.yml - # Note(decentral1se): in order to iterate through the end-user defined `db` - # stanza in the config.yml, we need to pass them into the include / block - # using `with_items` because Ansible decides that is the only way we can do - # that - name: Include database tasks - include: ./lib/database.yml datastore={{ item }} + include: ./lib/database.yml store={{ item }} with_items: "{{ db }}" when: db is defined