-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject.yml
59 lines (51 loc) · 2.1 KB
/
project.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
---
# http://dokku.viewdocs.io/dokku/application-deployment/
- name: Setup Project
hosts: dokku
vars:
projects:
- {name: python-getting-started, url: "https://github.com/heroku/python-getting-started.git", dbname: 'appdb', env: [key=value, foo=bar]}
- {name: ruby-rails-sample, url: "https://github.com/heroku/ruby-rails-sample.git", dbname: 'mydb', env: [key=value, foo=bar]}
databases:
- {engine: 'postgres', name: 'appdb'}
- {engine: 'mariadb', name: 'mydb'}
tasks:
- name: Get current directory
local_action: shell pwd
register: current_dir
- name: Checkout project to apps directory
local_action: git repo={{ item.url }} dest={{ current_dir.stdout }}/apps/{{ item.name }} accept_hostkey=True
with_items: "{{ projects }}"
- name: Create Dokku project
shell: dokku apps:create {{ item.name }}
become: yes
become_user: dokku
with_items: "{{ projects }}"
ignore_errors: yes
- name: Create Databases for project
shell: dokku {{ item.engine }}:create {{ item.name }}
become: yes
become_user: dokku
with_items: "{{ databases }}"
ignore_errors: yes
- name: Add ENV variables into project
shell: dokku config:set {{ item.name }} {{ " ".join(item.env) }}
become: yes
become_user: dokku
with_items: "{{ projects }}"
- name: Add Dokku as remote repository
local_action: command chdir={{ current_dir.stdout }}/apps/{{ item.name }} git remote add {{ git_remote_name }} dokku@{{ inventory_hostname }}:{{ item.name }}
with_items: "{{ projects }}"
ignore_errors: yes
- name: Link Database with project
shell: dokku {{ item[0].engine }}:link {{ item[1].dbname }} {{ item[1].name }}
when: item[0].name == item[1].dbname
become: yes
become_user: dokku
with_nested:
- "{{ databases }}"
- "{{ projects }}"
ignore_errors: yes
- name: Push project to Dokku
local_action: command chdir={{ current_dir.stdout }}/apps/{{ item.name }} git push {{ git_remote_name }} master
with_items: "{{ projects }}"