Move to dictionary vars strategy
This commit is contained in:
parent
618ae495b2
commit
5e9cc84e8b
@ -14,16 +14,6 @@
|
|||||||
include_vars:
|
include_vars:
|
||||||
file: "{{ plugin_config_root }}/vars.yml"
|
file: "{{ plugin_config_root }}/vars.yml"
|
||||||
|
|
||||||
- name: Export internal deployment variables
|
|
||||||
set_fact:
|
|
||||||
dokku:
|
|
||||||
{
|
|
||||||
app: "{{ app }}",
|
|
||||||
mariadb_addr: "dokku-mariadb-{{ app }}",
|
|
||||||
mariadb_user: "mariadb",
|
|
||||||
hostname: "{{ lookup('file', '/home/dokku/HOSTNAME') }}",
|
|
||||||
}
|
|
||||||
|
|
||||||
- name: Check if the application config file exists
|
- name: Check if the application config file exists
|
||||||
stat:
|
stat:
|
||||||
path: "{{ app_config_root }}/config.yml"
|
path: "{{ app_config_root }}/config.yml"
|
||||||
@ -35,10 +25,6 @@
|
|||||||
include_vars:
|
include_vars:
|
||||||
file: "{{ app_config_root }}/config.yml"
|
file: "{{ app_config_root }}/config.yml"
|
||||||
|
|
||||||
- name: CONFIG DEBUG
|
|
||||||
debug:
|
|
||||||
msg: "{{ vars }}"
|
|
||||||
|
|
||||||
- name: Check if an application vault directory exists
|
- name: Check if an application vault directory exists
|
||||||
stat:
|
stat:
|
||||||
path: "{{ app_config_root }}/vault"
|
path: "{{ app_config_root }}/vault"
|
||||||
@ -50,11 +36,25 @@
|
|||||||
include_vars:
|
include_vars:
|
||||||
ignore_unknown_extensions: true
|
ignore_unknown_extensions: true
|
||||||
dir: "{{ app_config_root }}/vault"
|
dir: "{{ app_config_root }}/vault"
|
||||||
name: "vault"
|
|
||||||
extensions:
|
extensions:
|
||||||
- yml
|
- yml
|
||||||
register: vault_include
|
register: vault_include
|
||||||
|
|
||||||
- name: Load vault variables into vault dictionary
|
- name: Create the variable dictionaries
|
||||||
set_fact:
|
set_fact:
|
||||||
vault: "{{ vault_include.ansible_facts.vault }}"
|
config:
|
||||||
|
{
|
||||||
|
"vars": "{{ lookup('vars', 'vars.vars', default=[]) }}",
|
||||||
|
"db": "{{ lookup('vars', 'vars.db', default=[]) }}",
|
||||||
|
"env": "{{ lookup('vars', 'vars.env', default=[]) }}",
|
||||||
|
"volumes": "{{ lookup('vars', 'vars.volumes', default=[]) }}",
|
||||||
|
"templates": "{{ lookup('vars', 'vars.templates', default=[]) }}",
|
||||||
|
"vault": "{{ vault_include.ansible_facts.vault }}",
|
||||||
|
}
|
||||||
|
dokku:
|
||||||
|
{
|
||||||
|
app: "{{ app }}",
|
||||||
|
mariadb_addr: "dokku-mariadb-{{ app }}",
|
||||||
|
mariadb_user: "mariadb",
|
||||||
|
hostname: "{{ lookup('file', '/home/dokku/HOSTNAME') }}",
|
||||||
|
}
|
||||||
|
@ -4,5 +4,5 @@
|
|||||||
shell: "dokku {{ item.type }}:destroy {{ dokku.app }} --force"
|
shell: "dokku {{ item.type }}:destroy {{ dokku.app }} --force"
|
||||||
args:
|
args:
|
||||||
removes: "/var/lib/dokku/services/{{ item.type }}/{{ dokku.app }}"
|
removes: "/var/lib/dokku/services/{{ item.type }}/{{ dokku.app }}"
|
||||||
with_items: "{{ db }}"
|
with_items: "{{ config.db }}"
|
||||||
when: db is defined
|
when: config.db
|
||||||
|
@ -3,5 +3,5 @@
|
|||||||
dokku_ports:
|
dokku_ports:
|
||||||
app: "{{ dokku.app }}"
|
app: "{{ dokku.app }}"
|
||||||
mappings:
|
mappings:
|
||||||
- "http:80:{{ vars.port }}"
|
- "http:80:{{ config.vars.port }}"
|
||||||
state: present
|
state: present
|
||||||
|
@ -13,5 +13,5 @@
|
|||||||
dokku_ports:
|
dokku_ports:
|
||||||
app: "{{ dokku.app }}"
|
app: "{{ dokku.app }}"
|
||||||
mappings:
|
mappings:
|
||||||
- "https:443:{{ vars.port }}"
|
- "https:443:{{ config.vars.port }}"
|
||||||
state: present
|
state: present
|
||||||
|
@ -3,5 +3,5 @@
|
|||||||
dokku_ports:
|
dokku_ports:
|
||||||
app: "{{ dokku.app }}"
|
app: "{{ dokku.app }}"
|
||||||
mappings:
|
mappings:
|
||||||
- "http:{{ vars.port }}:{{ vars.port }}"
|
- "http:{{ config.vars.port }}:{{ config.vars.port }}"
|
||||||
state: absent
|
state: absent
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
---
|
---
|
||||||
- name: Set database facts
|
- name: Set database facts
|
||||||
|
no_log: true
|
||||||
set_fact:
|
set_fact:
|
||||||
mount_map:
|
mount_map:
|
||||||
mariadb: /var/lib/mysql
|
mariadb: /var/lib/mysql
|
||||||
when: db is defined
|
when: config.db
|
||||||
|
|
||||||
- name: "Create {{ item.type }} database"
|
- name: "Create {{ item.type }} database"
|
||||||
no_log: true
|
no_log: true
|
||||||
@ -16,8 +17,8 @@
|
|||||||
"
|
"
|
||||||
args:
|
args:
|
||||||
creates: "/var/lib/dokku/services/{{ item.type }}/{{ dokku.app }}"
|
creates: "/var/lib/dokku/services/{{ item.type }}/{{ dokku.app }}"
|
||||||
with_items: "{{ db }}"
|
with_items: "{{ config.db }}"
|
||||||
when: db is defined
|
when: config.db
|
||||||
|
|
||||||
- name: "Link {{ item.type }} database to application"
|
- name: "Link {{ item.type }} database to application"
|
||||||
no_log: true
|
no_log: true
|
||||||
@ -25,13 +26,14 @@
|
|||||||
app: "{{ dokku.app }}"
|
app: "{{ dokku.app }}"
|
||||||
name: "{{ dokku.app }}"
|
name: "{{ dokku.app }}"
|
||||||
service: "{{ item.type }}"
|
service: "{{ item.type }}"
|
||||||
with_items: "{{ db }}"
|
with_items: "{{ config.db }}"
|
||||||
when: db is defined
|
when: config.db
|
||||||
|
|
||||||
- name: "Specify {{ item.type }} volume mounts"
|
- name: "Specify {{ item.type }} volume mounts"
|
||||||
|
no_log: true
|
||||||
dokku_storage:
|
dokku_storage:
|
||||||
app: "{{ dokku.app }}"
|
app: "{{ dokku.app }}"
|
||||||
mounts:
|
mounts:
|
||||||
- "/var/lib/dokku/services/{{ item.type }}/{{ dokku.app }}:{{ mount_map[item.type] }}"
|
- "/var/lib/dokku/services/{{ item.type }}/{{ dokku.app }}:{{ mount_map[item.type] }}"
|
||||||
with_items: "{{ db }}"
|
with_items: "{{ config.db }}"
|
||||||
when: db is defined
|
when: config.db
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
- name: "Configure {{ vars.domain }} dedicated domain"
|
- name: "Configure {{ config.vars.domain }} dedicated domain"
|
||||||
dokku_domains:
|
dokku_domains:
|
||||||
app: "{{ dokku.app }}"
|
app: "{{ dokku.app }}"
|
||||||
domains:
|
domains:
|
||||||
- "{{ vars.domain }}"
|
- "{{ config.vars.domain }}"
|
||||||
state: present
|
state: present
|
||||||
when: vars.domain is defined
|
when: "'domain' in config.vars"
|
||||||
|
@ -3,5 +3,5 @@
|
|||||||
dokku_config:
|
dokku_config:
|
||||||
app: "{{ dokku.app }}"
|
app: "{{ dokku.app }}"
|
||||||
restart: false
|
restart: false
|
||||||
config: "{{ env }}"
|
config: "{{ config.env }}"
|
||||||
when: env is defined
|
when: config.env
|
||||||
|
@ -5,5 +5,5 @@
|
|||||||
dest: "{{ item.dest }}"
|
dest: "{{ item.dest }}"
|
||||||
owner: dokku
|
owner: dokku
|
||||||
group: dokku
|
group: dokku
|
||||||
with_items: "{{ templates }}"
|
with_items: "{{ config.templates }}"
|
||||||
when: templates is defined
|
when: config.templates
|
||||||
|
@ -6,12 +6,12 @@
|
|||||||
state: directory
|
state: directory
|
||||||
owner: dokku
|
owner: dokku
|
||||||
group: dokku
|
group: dokku
|
||||||
with_items: "{{ mounts }}"
|
with_items: "{{ config.volumes }}"
|
||||||
when: mounts is defined
|
when: config.volumes
|
||||||
|
|
||||||
- name: Attach volume mounts
|
- name: Attach volume mounts
|
||||||
dokku_storage:
|
dokku_storage:
|
||||||
app: "{{ app }}"
|
app: "{{ dokku.app }}"
|
||||||
mounts: "{{ item }}"
|
mounts: "{{ item }}"
|
||||||
with_items: "{{ mounts }}"
|
with_items: "{{ config.volumes }}"
|
||||||
when: mounts is defined
|
when: config.volumes
|
||||||
|
Reference in New Issue
Block a user