42 lines
1.1 KiB
YAML
42 lines
1.1 KiB
YAML
---
|
|
#This playbook will install haproxy and configure for rails servers
|
|
#
|
|
- name: Add haproxy repo
|
|
apt_repository: repo='ppa:vbernat/haproxy-1.5' state=present
|
|
|
|
- name: update apt cache
|
|
apt: update_cache=yes cache_valid_time=3600
|
|
|
|
- name: install haproxy
|
|
apt: name=haproxy state=present
|
|
|
|
- name: Create haproxy config file
|
|
template: src=../roles/proxy/templates/haproxy.cfg.j2 dest=/etc/haproxy/haproxy.cfg
|
|
|
|
- name: Does does haproxy init exist
|
|
stat: path=/default/haproxy
|
|
register: haproxy_init
|
|
ignore_errors: yes
|
|
|
|
- name: Enable init script
|
|
replace: dest='/etc/default/haproxy'
|
|
regexp='ENABLED=0'
|
|
replace='ENABLED=1'
|
|
when: not haproxy_init.exists
|
|
|
|
- name: ssl key exits
|
|
stat: path=/root/server.pem
|
|
register: ssl
|
|
ignore_errors: yes
|
|
|
|
- name: Generate self signed key
|
|
shell: openssl req -new -newkey rsa:4096 -sha256 -subj '/CN=home/O=home LTD./C=US' -x509 -nodes -keyout /root/server.key -out /root/server.crt
|
|
when: not ssl.exists
|
|
|
|
- name: Create pem file
|
|
shell: cat /root/server.crt /root/server.key > /root/server.pem
|
|
when: not ssl.exists
|
|
|
|
- name: Restart haproxy
|
|
service: name=haproxy state=restarted
|