---
# tasks file for consul-template

- name: Write install script
  template:
    src=install.j2
    dest={{consul_template_install_script}}
    mode=0755
  tags:
    - consul-template

- name: Check consul-template version
  shell: consul-template --version >> tmp.ver 2>&1 && grep {{consul_template_ver}} tmp.ver
  ignore_errors: true
  register: consul_template_ver_matches
  tags:
    - consul-template

- name: Install consul-template
  shell: "{{consul_template_install_script}}"
  when: consul_template_ver_matches|failed
  tags:
    - consul-template

- name: Verify binary
  stat:
    path: "{{consul_template_bin_path}}//{{consul_template_bin_name}}"
  register: verify_binary

- name: Fail if binary is not present
  fail:
    msg: consul-template binary is not present
  when: not verify_binary.stat.exists

- name: Make templates dir
  file:
    path={{consul_template_templates_dir}}
    state=directory
  tags:
    - consul-template

---
# tasks file for consul-template

- name: Write install script
  template:
    src=install.j2
    dest={{consul_template_install_script}}
    mode=0755
  tags:
    - consul-template

- name: Check consul-template version
  shell: consul-template --version 2>&1 | grep {{consul_template_ver}}
  failed_when: false
  changed_when: false
  register: consul_template_ver_matches
  tags:
    - consul-template

- name: Install consul-template
  shell: "{{consul_template_install_script}}"
  when: consul_template_ver_matches.rc != 0
  tags:
    - consul-template

- name: Verify binary
  stat:
    path: "{{consul_template_bin_path}}//{{consul_template_bin_name}}"
  register: verify_binary

- name: Fail if binary is not present
  fail:
    msg: consul-template binary is not present
  when: not verify_binary.stat.exists

- name: Make templates dir
  file:
    path={{consul_template_templates_dir}}
    state=directory
  tags:
    - consul-template

Check version should not trigger change or failure
Check version should not trigger change or failure
