-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(install): add service and config template for host install
- Loading branch information
Showing
8 changed files
with
146 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,19 @@ | ||
--- | ||
# handlers file for deploy_haproxy | ||
- name: "Reload systemd file" | ||
ansible.builtin.systemd: | ||
daemon_reload: true | ||
listen: "systemctl-daemon-reload" | ||
|
||
- name: "Enable haproxy service" | ||
ansible.builtin.service: | ||
name: "{{ deploy_haproxy_service_name }}" | ||
enabled: true | ||
listen: "systemctl-enable-haproxy" | ||
|
||
- name: "Start haproxy service" | ||
ansible.builtin.service: | ||
name: "{{ deploy_haproxy_service_name }}" | ||
state: restarted | ||
listen: "systemctl-restart-haproxy" | ||
throttle: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
# task/configure file for deploy_haproxy | ||
- name: "Configure for host installation" | ||
when: deploy_haproxy_deploy_method == 'host' | ||
block: | ||
- name: "Create haproxy.env" | ||
ansible.builtin.template: | ||
src: haproxy.env.j2 | ||
dest: "{{ deploy_haproxy_config_dir }}/haproxy.env" | ||
owner: "{{ deploy_haproxy_user }}" | ||
group: "{{ deploy_haproxy_group }}" | ||
mode: "0600" | ||
|
||
- name: "Copy haproxy.cfg template" | ||
ansible.builtin.template: | ||
src: haproxy.cfg.j2 | ||
dest: "{{ deploy_haproxy_config_dir }}/haproxy.cfg" | ||
owner: "{{ deploy_haproxy_user }}" | ||
group: "{{ deploy_haproxy_group }}" | ||
mode: "0600" | ||
notify: | ||
- "systemctl-enable-haproxy" | ||
- "systemctl-restart-haproxy" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# {{ ansible_managed }} | ||
global | ||
{% for option in deploy_haproxy_global %} | ||
{{ option }} | ||
{% endfor %} | ||
|
||
defaults | ||
{% for option in deploy_haproxy_defaults %} | ||
{{ option }} | ||
{% endfor %} | ||
|
||
{% for frontend in deploy_haproxy_frontends %} | ||
frontend {{ frontend.name }} | ||
{% for option in frontend.options %} | ||
{{ option }} | ||
{% endfor %} | ||
{% endfor %} | ||
|
||
{% for backend in deploy_haproxy_backends %} | ||
backend {{ backend.name }} | ||
{% for option in backend.options%} | ||
{{ option }} | ||
{% endfor %} | ||
{% endfor %} | ||
|
||
{% for listen in deploy_haproxy_listen %} | ||
listen {{ listen.name }} | ||
{% for option in listen.options %} | ||
{{ option }} | ||
{% endfor %} | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# {{ ansible_managed }} | ||
{% for item in deploy_haproxy_env_variables %} | ||
{{ item }}="{{ deploy_haproxy_env_variables[item] }}" | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# {{ ansible_managed }} | ||
[Unit] | ||
Description=HAProxy Load Balancer | ||
Documentation=man:haproxy(1) | ||
Documentation=file:/usr/share/doc/haproxy/configuration.txt.gz | ||
ConditionFileNotEmpty={{ deploy_haproxy_config_dir }}/haproxy.cfg | ||
After=network-online.target rsyslog.service | ||
Wants=network-online.target | ||
|
||
[Service] | ||
EnvironmentFile=-/etc/default/{{ deploy_haproxy_service_name }} | ||
EnvironmentFile=-{{ deploy_haproxy_config_dir }}/haproxy.env | ||
BindReadOnlyPaths=/dev/log:{{ deploy_haproxy_chroot }}/dev/log | ||
Environment="CONFIG={{ deploy_haproxy_config_dir }}/haproxy.cfg" "PIDFILE=/run/haproxy.pid" "EXTRAOPTS=-S /run/haproxy-master.sock" | ||
ExecStart=/usr/sbin/haproxy -Ws -f $CONFIG -p $PIDFILE $EXTRAOPTS | ||
ExecReload=/usr/sbin/haproxy -Ws -f $CONFIG -c $EXTRAOPTS | ||
ExecReload=/bin/kill -USR2 $MAINPID | ||
KillMode=mixed | ||
Restart=always | ||
SuccessExitStatus=143 | ||
Type=notify | ||
|
||
[Install] | ||
WantedBy=multi-user.target |