-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathuclalib_haproxy.yml
111 lines (98 loc) · 2.92 KB
/
uclalib_haproxy.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
102
103
104
105
106
107
108
109
110
111
---
# 2020-04-09 jhriv
# A simple playbook to put UCLA Library test/prod HAProxy under
# Ansible / version control.
- name: HAProxy (Prod/Test) Install/Configure
hosts: all
tasks:
- name: Install HAProxy
dnf:
name: haproxy
state: present
disable_excludes: all
become: true
when: ansible_facts['os_family'] == "RedHat" and ansible_facts['distribution_major_version'] == "8"
- name: Install sysctl if not present
dnf:
name: procps-ng
state: present
disable_excludes: all
become: true
when: ansible_facts['os_family'] == "RedHat" and ansible_facts['distribution_major_version'] == "8"
- name: Start HAProxy on boot
service:
name: haproxy
enabled: true
become: true
- name: Allow bind to non-local IPs (keepalived)
sysctl:
name: net.ipv4.ip_nonlocal_bind
value: '1'
state: present
sysctl_set: true
reload: true
become: true
- name: Get the directories
# -printf is a GNU extension
# command: find . -type d -printf '%P\n'
command: find . -type d -print
args:
chdir: "files/{{ haproxy_local_file_path }}"
connection: local
changed_when: false
check_mode: false
register: haproxy_conf_directories
- name: Get the files
# -printf is a GNU extension
# command: find . -type f -not -name haproxy.cfg -printf '%P\n'
command: find . -type f -not -name haproxy.cfg -print
args:
chdir: "files/{{ haproxy_local_file_path }}"
connection: local
changed_when: false
check_mode: false
register: haproxy_conf_files
- name: Create Directories
file:
name: "{{ haproxy_config_dir }}/{{ item }}"
state: directory
become: true
loop:
"{{ haproxy_conf_directories.stdout_lines }}"
- name: Copy Files
copy:
src: "{{ haproxy_local_file_path }}/{{ item }}"
dest: "{{ haproxy_config_dir }}/{{ item | regex_replace ('\\.vault(|\\..*)$', '\\1' ) }}"
become: true
loop:
"{{ haproxy_conf_files.stdout_lines }}"
notify:
- Restart HAProxy
- name: Deploy ACL sources
copy:
content: "{{ hostvars[inventory_hostname][item] | join('\n') }}\n"
dest: "{{ haproxy_config_dir }}/{{ item }}"
owner: "root"
group: "root"
mode: 0644
become: true
loop:
- ucla_vpn_networks
- ucla_library_staff_networks
- rancher_agent_acl
notify:
- Restart HAProxy
- name: Copy Config
copy:
src: "{{ haproxy_local_file_path }}/haproxy.cfg"
dest: "{{ haproxy_config_dir }}/haproxy.cfg"
validate: haproxy -c -f %s
become: true
notify:
- Restart HAProxy
handlers:
- name: Restart HAProxy
service:
name: haproxy
state: restarted
become: true