-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhaproxy.yaml
45 lines (40 loc) · 1.14 KB
/
haproxy.yaml
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
---
- hosts: localhost
tasks:
- name: Authenticate to RHV-M
ovirt_auth:
url: "https://{{ rhvm_addr }}/ovirt-engine/api"
username: "{{ rhv_user }}"
password: "{{ rhv_pass }}"
insecure: true
- name: List vms
ovirt_vm_facts:
auth: "{{ ovirt_auth }}"
pattern: name=iis*
- name: Get VM API info
uri:
url: "https://{{ rhvm_addr }}{{ item.href }}/reporteddevices"
method: GET
return_content: yes
user: "{{ rhv_user }}"
password: "{{ rhv_pass }}"
validate_certs: no
body_format: raw
headers:
Accept: application/json
with_items: "{{ ovirt_vms }}"
register: vmapi
- name: Configure haproxy
blockinfile:
path: /etc/haproxy/haproxy.cfg
state: present
insertafter: EOF
block: |
server iis1 "{{ vmapi.results[0].json.reported_device[0].ips.ip[0].address }}":80 check
server iis2 "{{ vmapi.results[1].json.reported_device[0].ips.ip[0].address }}":80 check
delegate_to: 192.168.2.147
- name: restart haproxy
service:
name: haproxy
state: restarted
delegate_to: 192.168.2.147