instance-status/tasks/main.yml
Knut Ahlers 18bfd7f81f
Update version, adjust tasks for new version
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2018-04-27 12:10:33 +02:00

65 lines
2.3 KiB
YAML

---
- 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
dest: '{{ instance_status_checks_file }}'
register: instance_status_config
when: "'http://' not in instance_status_checks_file and 'https://' not in instance_status_checks_file"
- name: Get current elb-instance-status version
shell: "/usr/local/bin/elb-instance-status_linux_amd64 --version || true"
check_mode: no
register: instance_status_version_cmd
- name: Download elb-instance-status release
unarchive:
src: 'https://github.com/Luzifer/elb-instance-status/releases/download/{{ instance_status_version }}/elb-instance-status_linux_amd64.tar.gz'
remote_src: true
dest: /usr/local/bin
when: instance_status_version not in instance_status_version_cmd.stdout
register: instance_status_binary
- 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
RestartSec=10
SyslogIdentifier=elb-instance-status
ExecStart=/usr/local/bin/elb-instance-status_linux_amd64 \
--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 }}
[Install]
WantedBy=multi-user.target
dest: /etc/systemd/system/elb-instance-status.service
register: instance_status_service
- name: Ensure elb-instance-status is enabled
systemd:
name: elb-instance-status
daemon_reload: true
enabled: true
- name: Ensure elb-instance-status is restarted on changes
systemd:
name: elb-instance-status
state: restarted
when: (instance_status_config.changed or instance_status_binary.changed or instance_status_service.changed) and packer_build_name is not defined