Try to use the with_items include syntax correctly again

This commit is contained in:
Luke Murphy 2020-04-13 20:06:36 +02:00
parent 5bf47708a0
commit 95e70fdfdd
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
3 changed files with 11 additions and 15 deletions

View File

@ -1,32 +1,31 @@
--- ---
- name: Run database setup tasks - name: Run database setup tasks
when: db is defined
block: block:
- name: Set database facts - name: Set database facts
set_fact: set_fact:
mount_map: mount_map:
mariadb: /var/lib/mysql mariadb: /var/lib/mysql
- name: "Create {{ item.type }} database" - name: "Create {{ store.type }} database"
no_log: true no_log: true
shell: " shell: "
dokku dokku
{{ item.type }}:create {{ store.type }}:create
{{ app }} {{ app }}
--password {{ item.passwd }} --password {{ store.passwd }}
--root-password {{ item.root_passwd }} --root-password {{ store.root_passwd }}
" "
args: 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: dokku_service_link:
app: "{{ app }}" app: "{{ app }}"
name: "{{ app }}" name: "{{ app }}"
service: "{{ item.type }}" service: "{{ store.type }}"
- name: "Specify {{ item.type }} volume mounts" - name: "Specify {{ store.type }} volume mounts"
dokku_storage: dokku_storage:
app: "{{ app }}" app: "{{ app }}"
mounts: mounts:
- "/var/lib/dokku/services/{{ item.type }}/{{ app }}:{{ mount_map[item.type] }}" - "/var/lib/dokku/services/{{ store.type }}/{{ app }}:{{ mount_map[store.type] }}"

View File

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

View File

@ -17,12 +17,8 @@
- name: Include domain tasks - name: Include domain tasks
include: ./lib/domain.yml 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 - name: Include database tasks
include: ./lib/database.yml datastore={{ item }} include: ./lib/database.yml store={{ item }}
with_items: "{{ db }}" with_items: "{{ db }}"
when: db is defined when: db is defined