diff --git a/defaults/main.yml b/defaults/main.yml index 695e583..65ec7e8 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,8 +1,16 @@ --- instance_status_apt_required: [] + +instance_status_global_checks: {} instance_status_checks: {} +instance_status_check_interval: 1m +instance_status_checks_file: /etc/host-status.yml +instance_status_config_refresh: 10m +instance_status_port: 9000 +instance_status_unhealthy_threshold: 5 +instance_status_verbose: false instance_status_version: v0.5.2 ... diff --git a/tasks/main.yml b/tasks/main.yml index 0a9005b..149fd99 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -8,8 +8,9 @@ - name: Set up checks file for ELB Instance Status template: src: templates/checks.yml - dest: /etc/elb-instance-status.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 --version || true" @@ -37,20 +38,29 @@ TimeoutStartSec=0 TimeoutStopSec=0 Restart=on-failure - RestartSec=30 + RestartSec=10 SyslogIdentifier=elb-instance-status ExecStart=/usr/local/bin/elb-instance-status \ - --listen=:9001 + --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: - daemon_reload: yes name: elb-instance-status state: restarted - enabled: yes - when: instance_status_config.changed or instance_status_binary.changed or instance_status_service.changed + when: (instance_status_config.changed or instance_status_binary.changed or instance_status_service.changed) and packer_build_name is not defined diff --git a/templates/checks.yml b/templates/checks.yml index 1f1e2fa..375be31 100644 --- a/templates/checks.yml +++ b/templates/checks.yml @@ -1,5 +1,10 @@ --- +# {{ ansible_managed }} +# Global checks +{{ instance_status_global_checks | to_nice_yaml }} + +# Instance checks {{ instance_status_checks | to_nice_yaml }} ...