2017-12-25 01:04:41 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: Install required packages
|
|
|
|
apt:
|
|
|
|
name: "{{ item }}"
|
|
|
|
with_items: '{{ instance_status_apt_required }}'
|
|
|
|
|
|
|
|
- name: Set up checks file for ELB Instance Status
|
|
|
|
template:
|
|
|
|
src: templates/checks.yml
|
2018-04-26 12:00:31 +00:00
|
|
|
dest: '{{ instance_status_checks_file }}'
|
2017-12-25 01:04:41 +00:00
|
|
|
register: instance_status_config
|
2018-04-26 12:00:31 +00:00
|
|
|
when: "'http://' not in instance_status_checks_file and 'https://' not in instance_status_checks_file"
|
2017-12-25 01:04:41 +00:00
|
|
|
|
2017-12-25 01:16:26 +00:00
|
|
|
- name: Get current elb-instance-status version
|
2017-12-25 01:19:35 +00:00
|
|
|
shell: "/usr/local/bin/elb-instance-status --version || true"
|
|
|
|
check_mode: no
|
2017-12-25 01:16:26 +00:00
|
|
|
register: instance_status_version_cmd
|
|
|
|
|
2017-12-25 01:04:41 +00:00
|
|
|
- name: Download elb-instance-status release
|
|
|
|
get_url:
|
2017-12-25 01:16:26 +00:00
|
|
|
url: 'https://github.com/Luzifer/elb-instance-status/releases/download/{{ instance_status_version }}/elb-instance-status_linux_amd64'
|
2017-12-25 01:04:41 +00:00
|
|
|
dest: /usr/local/bin/elb-instance-status
|
2017-12-25 01:43:23 +00:00
|
|
|
force: yes
|
2017-12-25 01:16:26 +00:00
|
|
|
mode: 0755
|
2017-12-25 01:19:35 +00:00
|
|
|
when: instance_status_version not in instance_status_version_cmd.stdout
|
2017-12-25 01:16:26 +00:00
|
|
|
register: instance_status_binary
|
2017-12-25 01:04:41 +00:00
|
|
|
|
|
|
|
- name: Install system.d service
|
|
|
|
copy:
|
|
|
|
content: |
|
|
|
|
[Unit]
|
|
|
|
Description=Machine health checking service
|
|
|
|
After=network-online.target
|
|
|
|
Requires=network-online.target
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
TimeoutStartSec=0
|
|
|
|
TimeoutStopSec=0
|
|
|
|
Restart=on-failure
|
2018-04-26 12:00:31 +00:00
|
|
|
RestartSec=10
|
2017-12-25 01:04:41 +00:00
|
|
|
SyslogIdentifier=elb-instance-status
|
|
|
|
ExecStart=/usr/local/bin/elb-instance-status \
|
2018-04-26 12:00:31 +00:00
|
|
|
--check-definitions-file={{ instance_status_checks_file }} \
|
|
|
|
--check-interval={{ instance_status_check_interval }} \
|
|
|
|
--config-refresh={{ instance_status_config_refresh }} \
|
|
|
|
--listen=:{{ instance_status_port }} \
|
|
|
|
--unhealthy-threshold={{ instance_status_unhealthy_threshold }} \
|
|
|
|
--verbose={{ instance_status_verbose | to_json }}
|
2017-12-25 01:04:41 +00:00
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
dest: /etc/systemd/system/elb-instance-status.service
|
|
|
|
register: instance_status_service
|
|
|
|
|
2018-04-26 12:00:31 +00:00
|
|
|
- name: Ensure elb-instance-status is enabled
|
|
|
|
systemd:
|
|
|
|
name: elb-instance-status
|
|
|
|
daemon_reload: true
|
|
|
|
enabled: true
|
|
|
|
|
2017-12-25 01:04:41 +00:00
|
|
|
- name: Ensure elb-instance-status is restarted on changes
|
|
|
|
systemd:
|
|
|
|
name: elb-instance-status
|
|
|
|
state: restarted
|
2018-04-26 12:00:31 +00:00
|
|
|
when: (instance_status_config.changed or instance_status_binary.changed or instance_status_service.changed) and packer_build_name is not defined
|