-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.yml
101 lines (101 loc) · 3.48 KB
/
setup.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
---
- name: Setup AWS infrastructure
hosts: localhost
connection: local
gather_facts: False
vars_files:
- vars/aws.yml
- vars/aws_secrets.yml
tasks:
- name: generate cloudformation template.
shell: python scripts/make_cf_template.py > files/cf_template.json
- name: Launch cloudformation to create ec2, security group, and EIP.
cloudformation:
aws_access_key: "{{ cloudformation_access_key }}"
aws_secret_key: "{{ cloudformation_secret_key }}"
stack_name: "{{ stack_name }}"
state: present
region: "{{ aws_region }}"
template: files/cf_template.json
template_parameters:
KeyName: "{{ key_name }}"
Name: "{{ stack_name }}"
SSHLocation: "0.0.0.0/0"
register: cloudformation
- name: "Setup route53 {{ dokku_host }}"
route53:
aws_access_key: "{{ route53_access_key }}"
aws_secret_key: "{{ route53_secret_key }}"
command: create
overwrite: true
zone: "{{ zone }}"
record: "{{ dokku_host }}"
type: A
value: "{{ cloudformation.stack_outputs.InstanceIPAddress }}"
- name: Wildcard subdomains for stack {{ wildcard_host }}
route53:
aws_access_key: "{{ route53_access_key }}"
aws_secret_key: "{{ route53_secret_key }}"
command: create
overwrite: true
zone: "{{ zone }}"
record: "{{ wildcard_host }}"
type: A
value: "{{ cloudformation.stack_outputs.InstanceIPAddress }}"
- name: Add instance to in-memory host group
add_host:
hostname: "{{ cloudformation.stack_outputs.InstanceIPAddress }}"
groups: cloud_formation
- name: Wait for SSH
wait_for:
host: "{{ cloudformation.stack_outputs.InstanceIPAddress }}"
port: 22
delay: 5
timeout: 300
state: started
- name: Setup ansible dependencies
hosts: cloud_formation
become: yes
gather_facts: False
vars_files:
- vars/aws.yml
- vars/aws_secrets.yml
vars:
ansible_ssh_private_key_file: "{{ ssh_private_key }}"
ansible_host_key_checking: false
pre_tasks:
# If there is no python, install it before using other ansible packages
- name: setup python symlink for ansible
raw: which python || ln -s `which python3` /usr/bin/python
- name: Configure ec2 instance
hosts: cloud_formation
become: yes
gather_facts: True
vars_files:
- vars/aws.yml
- vars/aws_secrets.yml
vars:
ansible_ssh_private_key_file: "{{ ssh_private_key }}"
ansible_host_key_checking: false
roles:
- role: swapfile
swapfile_size: 3GB
swapfile_swappiness: 10
- role: tequila-common
env_name: no_env_set
project_name: dokku-stack
- role: tequila-dokku
dokku_hostname: "{{ zone }}"
tasks:
- name: Install Dokku plugins
shell: "dokku plugin:install {{ item.url }}"
args:
creates: "/var/lib/dokku/plugins/enabled/{{ item.name }}"
loop:
- { name: "letsencrypt", url: "https://github.com/dokku/dokku-letsencrypt.git" }
- { name: "logspout", url: "https://github.com/michaelshobbs/dokku-logspout.git" }
- { name: "postgres", url: "https://github.com/dokku/dokku-postgres.git" }
- { name: "mysql", url: "https://github.com/dokku/dokku-mysql.git" }
- { name: "redis", url: "https://github.com/dokku/dokku-redis.git" }
- { name: "redirect", url: "https://github.com/dokku/dokku-redirect.git" }
- { name: "dockerfile", url: "https://github.com/mimischi/dokku-dockerfile.git" }