-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure_start_stop.yml
68 lines (56 loc) · 1.98 KB
/
azure_start_stop.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
- name: Create a sandbox instance
hosts: localhost
gather_facts: False
connection: local
tags: start
vars:
ssh_cert_path: ~/.azure/azure.pem
server_name: rng-test-large
user_name: ubuntu
image: 'b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-saucy-13_10-amd64-server-20140618-en-us-30GB'
tasks:
# Provision virtual machine example
- name: 'start azure vm'
local_action: azure name={{ server_name }} role_size='Large' image={{image}} location='West Europe' user={{ user_name }} ssh_cert_path={{ ssh_cert_path }} storage_account=matlockxstorage
register: azure
- name: Add new instance to host group
local_action: add_host hostname={{ server_name }} groupname=launched ansible_ssh_host={{item}} ansible_ssh_private_key_file={{ ssh_cert_path }} ansible_ssh_user={{ user_name }}
with_items: azure.public_dns_name
- name: Wait for SSH to come up
local_action: wait_for host={{ item }} port=22 delay=60 timeout=320 state=started
with_items: azure.public_dns_name
- name: Configure instance(s)
hosts: launched:all
sudo: True
gather_facts: True
tags: configure
tasks:
- name: install java 7
apt: name=openjdk-7-jre-headless state=latest update_cache=yes
- name: install haproxy
apt: name=haproxy state=latest update_cache=yes
- name: install socat
apt: name=socat state=latest update_cache=yes
- name: Enable the server in haproxy
shell: echo "enable server spray/{{ ansible_hostname }}" | socat stdio /var/lib/haproxy/stats
#delegate_to: "{{ item }}"
#with_items: "{{ ansible_hostname }}"
roles:
- haproxy
- name: Redeploy
hosts: launched:all
sudo: True
gather_facts: True
tags: redeploy
roles:
- webapp
- name: Terminate instances
hosts: all
connection: local
tags: delete
vars:
server_name: rng-test-large
tasks:
# Terminate virtual machine example
- name: 'delete vm'
local_action: azure name={{ server_name }} state=absent