initial commit for ansible haproxy role
This commit is contained in:
79
roles/haproxy/tasks/main.yaml
Normal file
79
roles/haproxy/tasks/main.yaml
Normal file
@@ -0,0 +1,79 @@
|
||||
---
|
||||
|
||||
- name: install dependencies
|
||||
apt:
|
||||
name:
|
||||
- liblua5.3-0
|
||||
- libpcre3
|
||||
state: latest
|
||||
|
||||
- name: conflicted with haproxy package
|
||||
apt:
|
||||
name:
|
||||
- haproxy
|
||||
state: absent
|
||||
|
||||
|
||||
- name: add user 'haproxy'
|
||||
user:
|
||||
name: haproxy
|
||||
system: yes
|
||||
create_home: no
|
||||
|
||||
- name: create config dir
|
||||
file:
|
||||
path: /etc/haproxy/
|
||||
state: directory
|
||||
|
||||
- name: copy errorcodes
|
||||
copy:
|
||||
src: errorfiles
|
||||
dest: /etc/haproxy/
|
||||
|
||||
- name: copy haproxy binary
|
||||
copy:
|
||||
src: haproxy
|
||||
dest: /usr/local/bin
|
||||
mode: 0755
|
||||
notify:
|
||||
- restart haproxy
|
||||
|
||||
- name: copy scripts
|
||||
copy:
|
||||
src: update_haproxy_certs.sh
|
||||
dest: /usr/local/bin
|
||||
mode: 0755
|
||||
|
||||
- name: create basic HAProxy configs
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "/etc/haproxy/{{ item }}"
|
||||
mode: 0644
|
||||
with_items:
|
||||
- hostname2backend.map
|
||||
- haproxy.cfg
|
||||
notify: reload haproxy
|
||||
|
||||
- name: create domains.txt
|
||||
template:
|
||||
src: domains.txt
|
||||
dest: /etc/haproxy/
|
||||
mode: 0644
|
||||
notify:
|
||||
- update certs
|
||||
|
||||
- name: systemd unit
|
||||
copy:
|
||||
src: haproxy.service
|
||||
dest: /lib/systemd/system/
|
||||
mode: 0644
|
||||
notify:
|
||||
- reload systemd config
|
||||
- reload haproxy
|
||||
|
||||
- name: haproxy service
|
||||
service:
|
||||
name: haproxy
|
||||
enabled: yes
|
||||
state: started
|
||||
|
Reference in New Issue
Block a user