Group plays to hooks
This commit is contained in:
36
plays/predeploy/lib/database.yml
Normal file
36
plays/predeploy/lib/database.yml
Normal file
@ -0,0 +1,36 @@
|
||||
---
|
||||
- name: Set database facts
|
||||
set_fact:
|
||||
mount_map:
|
||||
mariadb: /var/lib/mysql
|
||||
when: db is defined
|
||||
|
||||
- name: "Create {{ item.type }} database"
|
||||
no_log: true
|
||||
shell: "
|
||||
dokku
|
||||
{{ item.type }}:create
|
||||
{{ app }}
|
||||
--password {{ item.passwd }}
|
||||
--root-password {{ item.root_passwd }}
|
||||
"
|
||||
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:
|
||||
app: "{{ app }}"
|
||||
name: "{{ app }}"
|
||||
service: "{{ item.type }}"
|
||||
with_items: "{{ db }}"
|
||||
when: db is defined
|
||||
|
||||
- name: "Specify {{ item.type }} volume mounts"
|
||||
dokku_storage:
|
||||
app: "{{ app }}"
|
||||
mounts:
|
||||
- "/var/lib/dokku/services/{{ item.type }}/{{ app }}:{{ mount_map[item.type] }}"
|
||||
with_items: "{{ db }}"
|
||||
when: db is defined
|
8
plays/predeploy/lib/domain.yml
Normal file
8
plays/predeploy/lib/domain.yml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
- name: "Configure {{ domain }} dedicated domain"
|
||||
dokku_domains:
|
||||
app: "{{ app }}"
|
||||
domains:
|
||||
- "{{ domain }}"
|
||||
state: present
|
||||
when: domain is defined
|
7
plays/predeploy/lib/env.yml
Normal file
7
plays/predeploy/lib/env.yml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
- name: Configure the app environment
|
||||
dokku_config:
|
||||
app: "{{ app }}"
|
||||
restart: false
|
||||
config: "{{ env }}"
|
||||
when: env is defined
|
17
plays/predeploy/lib/volumes.yml
Normal file
17
plays/predeploy/lib/volumes.yml
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
- name: Create volume mount directories
|
||||
become: true
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
owner: dokku
|
||||
group: dokku
|
||||
with_items: "{{ mounts }}"
|
||||
when: mounts is defined
|
||||
|
||||
- name: Attach volume mounts
|
||||
dokku_storage:
|
||||
app: "{{ app }}"
|
||||
mounts: "{{ item }}"
|
||||
with_items: "{{ mounts }}"
|
||||
when: mounts is defined
|
9
plays/predeploy/predeploy.yml
Normal file
9
plays/predeploy/predeploy.yml
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
- hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- include: ../commonlib/vars.yml
|
||||
- include: ./lib/domain.yml
|
||||
- include: ./lib/database.yml
|
||||
- include: ./lib/volumes.yml
|
||||
- include: ./lib/env.yml
|
Reference in New Issue
Block a user