-
-
Notifications
You must be signed in to change notification settings - Fork 314
/
deploy.yml
71 lines (63 loc) · 2.09 KB
/
deploy.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
---
- hosts: localhost
gather_facts: false
vars_files:
- vars/main.yml
tasks:
- name: Deploy WordPress secrets.
k8s:
definition: '{{ item }}'
kubeconfig: '{{ k8s_kubeconfig }}'
state: present
loop: "{{ lookup('template', 'wordpress/mysql-pass.yml') | from_yaml_all | list }}"
no_log: "{{ k8s_no_log }}"
- name: Deploy MySQL and WordPress.
k8s:
definition: '{{ item }}'
kubeconfig: '{{ k8s_kubeconfig }}'
state: present
loop:
- "{{ lookup('template', 'wordpress/mysql.yml') | from_yaml_all | list }}"
- "{{ lookup('template', 'wordpress/wordpress.yml') | from_yaml_all | list }}"
- name: Get load balancer DNS name.
k8s_info:
kubeconfig: '{{ k8s_kubeconfig }}'
kind: Service
name: wordpress
namespace: default
register: wordpress_svc
- name: Set the load balancer URL as a fact.
set_fact:
wordpress_lb_host: "{{ wordpress_svc['resources'][0]['status']['loadBalancer']['ingress'][0]['hostname'] }}"
when: aws_environment | bool
- name: Wait for Load Balancer to respond.
uri:
url: "http://{{ wordpress_lb_host }}"
register: lb_result
until: lb_result.status == 200
retries: 60
delay: 5
when: aws_environment | bool
- name: Get ELB info.
ec2_elb_info:
region: "{{ aws_region }}"
profile: "{{ aws_profile }}"
names: "{{ wordpress_lb_host.split('-')[0] }}"
register: elb_info
when: aws_environment | bool
- name: Add an A record in Route53 (if configured).
route53:
profile: "{{ aws_profile }}"
zone: '{{ wordpress_route53_zone }}'
record: '{{ wordpress_route53_domain }}'
state: present
type: A
ttl: 300
value: '{{ wordpress_lb_host }}.'
alias: true
alias_hosted_zone_id: "{{ elb_info['elbs'][0]['canonical_hosted_zone_name_id'] }}"
wait: true
when:
- aws_environment | bool
- wordpress_route53_zone != ''
- wordpress_route53_domain != ''