Move to dictionary vars strategy

This commit is contained in:
Luke Murphy
2020-04-14 13:44:09 +02:00
parent 618ae495b2
commit 5e9cc84e8b
10 changed files with 43 additions and 41 deletions

View File

@ -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

View File

@ -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"

View File

@ -3,5 +3,5 @@
dokku_config:
app: "{{ dokku.app }}"
restart: false
config: "{{ env }}"
when: env is defined
config: "{{ config.env }}"
when: config.env

View File

@ -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

View File

@ -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