From 177f3ad2447485384ece4270dd3e11f298dfb1a6 Mon Sep 17 00:00:00 2001 From: Trevor Robinson Date: Mon, 29 Aug 2016 09:57:14 -0500 Subject: [PATCH] Make Upstart start/stop conditions configurable and fix RedHat values --- defaults/main.yml | 4 ++++ tasks/main.yml | 5 +++++ templates/consul.conf.j2 | 4 ++-- vars/Debian.yml | 2 ++ vars/RedHat.yml | 2 ++ 5 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 vars/Debian.yml create mode 100644 vars/RedHat.yml diff --git a/defaults/main.yml b/defaults/main.yml index 4be8f6a..dc03721 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -60,6 +60,10 @@ consul_use_systemd: false consul_use_upstart: true consul_use_initd: false +# Upstart start/stop conditions can vary by distribution and environment +consul_upstart_start_on: start on runlevel [345] +consul_upstart_stop_on: stop on runlevel [!345] + consul_is_server: false consul_domain: consul. diff --git a/tasks/main.yml b/tasks/main.yml index 4f9d4df..29cd62f 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,4 +1,9 @@ --- +- name: gather OS specific variables + include_vars: "{{ item }}" + with_first_found: + - "{{ ansible_os_family }}-{{ ansible_distribution_major_version}}.yml" + - "{{ ansible_os_family }}.yml" - include: install.yml - { include: install-ui.yml, when: consul_is_ui == true } - { include: install-cli.yml, when: consul_install_consul_cli == true } diff --git a/templates/consul.conf.j2 b/templates/consul.conf.j2 index 32fd094..d251b1d 100644 --- a/templates/consul.conf.j2 +++ b/templates/consul.conf.j2 @@ -1,8 +1,8 @@ # Consul Agent (Upstart unit) description "Consul Agent" -start on (local-filesystems and net-device-up IFACE!=lo) -stop on runlevel [016] +start on {{ consul_upstart_start_on }} +stop on {{ consul_upstart_stop_on }} script {% if consul_dynamic_bind %} diff --git a/vars/Debian.yml b/vars/Debian.yml new file mode 100644 index 0000000..ba6085d --- /dev/null +++ b/vars/Debian.yml @@ -0,0 +1,2 @@ +consul_upstart_start_on: (local-filesystems and net-device-up IFACE!=lo) +consul_upstart_stop_on: runlevel [016] diff --git a/vars/RedHat.yml b/vars/RedHat.yml new file mode 100644 index 0000000..7b79903 --- /dev/null +++ b/vars/RedHat.yml @@ -0,0 +1,2 @@ +consul_upstart_start_on: (runlevel [345] and started network) +consul_upstart_stop_on: (runlevel [!345] or stopping network)