Skip to content
This repository has been archived by the owner on Oct 15, 2018. It is now read-only.

Commit

Permalink
fix consul service start
Browse files Browse the repository at this point in the history
  • Loading branch information
mylokin committed Mar 27, 2018
1 parent 7afb4ea commit 70190ce
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
5 changes: 4 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
---
consul_mode: "client"
consul_dnsmasq: yes
consul_service_enabled: no
consul_service_started: no

consul_dnsmasq: yes
consul_dnsmasq_service_enabled: no
consul_dnsmasq_service_started: no

consul_src: https://releases.hashicorp.com/consul/0.9.3/consul_0.9.3_linux_amd64.zip
consul_dest: /usr/local/bin

Expand Down
5 changes: 3 additions & 2 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
service:
name: dnsmasq
state: restarted
when: lookup('env', 'MOLECULE_DRIVER_NAME') != 'docker'
when: consul_service_started and lookup('env', 'MOLECULE_DRIVER_NAME') != 'docker'


- name: restart consul
service:
name: consul
state: restarted
when: lookup('env', 'MOLECULE_DRIVER_NAME') != 'docker'
when: consul_service_started and lookup('env', 'MOLECULE_DRIVER_NAME') != 'docker'
28 changes: 22 additions & 6 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@
mode: 0644
when: ansible_distribution_release == 'trusty'

- include: dnsmasq.yml
when: consul_dnsmasq
tags:
- dnsmasq

- name: enable consul
service:
name: consul
Expand All @@ -116,15 +121,26 @@
tags:
- service

- name: start consul
- name: start/stop consul service
service:
name: consul
state: started
when: consul_service_started
state: '{{ "started" if consul_service_started else "stopped" }}'
when: lookup('env', 'MOLECULE_DRIVER_NAME') != 'docker'
tags:
- service

- include: dnsmasq.yml
when: consul_dnsmasq
- name: enable dnsmasq
service:
name: dnsmasq
enabled: "{{ consul_dnsmasq_service_enabled }}"
when: consul_dnsmasq and lookup('env', 'MOLECULE_DRIVER_NAME') != 'docker'
tags:
- dnsmasq
- service

- name: start/stop dnsmasq service
service:
name: dnsmasq
state: '{{ "started" if consul_dnsmasq_service_started else "stopped" }}'
when: consul_dnsmasq and lookup('env', 'MOLECULE_DRIVER_NAME') != 'docker'
tags:
- service

0 comments on commit 70190ce

Please sign in to comment.