---

- name: Start and enable consul service
  service: name=consul state=started enabled=True
  register: consul_service_started
  tags: consul

- name: Handle consul-template-consul service
  service:
    name: consul-template-consul
    state: "{{ (consul_vault_secrets.pki.enabled or consul_vault_secrets.tokens.enabled) | ternary('started', 'stopped') }}"
    enabled: "{{ (consul_vault_secrets.pki.enabled or consul_vault_secrets.tokens.enabled) | ternary(True, False) }}"
  tags: consul

