forked from rosconap/scale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_server.yml
57 lines (50 loc) · 1.41 KB
/
add_server.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
---
- hosts: 127.0.0.1
connection: local
vars_files:
- vars/credentials.yml
gather_facts: False
tasks:
- name: launch server
nova_compute:
state: present
auth_url: "{{ auth_url }}"
login_username: "{{ login_username }}"
login_password: "{{ login_password }}"
login_tenant_name: "{{ login_tenant_name }}"
name: "{{ servername }}"
image_id: b6f54599-47e2-43b6-aa02-880a93a5b5a1
wait_for: 200
flavor_id: 101
nics:
- net-id: 472dd2d5-e163-4d71-899c-f0c7a10ad10d
meta:
hostname: web-extra
group: "{{ servername }}"
register: result
- name: add new server to inventory
lineinfile:
state=present
dest=inventory
insertafter=EOF
line="{{ servername }} ansible_ssh_host={{ result.private_ip }}"
when: result|changed
- name: Add webserver to in-memory inventory
add_host:
name: "{{ servername }}"
groups: webfarm
ansible_ssh_host: "{{ result.private_ip }}"
when: result|changed
- hosts: loadbalancer
gather_facts: False
tasks:
- name: set haproxy template with new server
template:
src=haproxy.cfg.j2
dest=/etc/haproxy/haproxy.cfg
register: result
- name: reload haproxy
service:
name=haproxy
state=reloaded
when: result|changed