Only run if {{ db }} is defined

This commit is contained in:
Luke Murphy 2020-04-14 11:16:06 +02:00
parent 584360421b
commit 7c3802fa2c
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
2 changed files with 5 additions and 1 deletions

View File

@ -3,6 +3,7 @@
set_fact:
mount_map:
mariadb: /var/lib/mysql
when: db is defined
- name: "Create {{ item.type }} database"
no_log: true
@ -16,6 +17,7 @@
args:
creates: "/var/lib/dokku/services/{{ item.type }}/{{ app }}"
with_items: "{{ db }}"
when: db is defined
- name: "Link {{ item.type }} database to application"
dokku_service_link:
@ -23,6 +25,7 @@
name: "{{ app }}"
service: "{{ item.type }}"
with_items: "{{ db }}"
when: db is defined
- name: "Specify {{ item.type }} volume mounts"
dokku_storage:
@ -30,3 +33,4 @@
mounts:
- "/var/lib/dokku/services/{{ item.type }}/{{ app }}:{{ mount_map[item.type] }}"
with_items: "{{ db }}"
when: db is defined

View File

@ -13,4 +13,4 @@
args:
removes: "/var/lib/dokku/services/{{ item.type }}/{{ app }}"
with_items: "{{ db }}"
when: db exists
when: db is defined