- name: download consul
  get_url: >
    url={{consul_ui_download}}
    dest={{consul_download_folder}}
  register: consul_ui_was_downloaded

- name: copy and unpack
  unarchive: >
    src={{ consul_download_folder }}/{{ consul_ui_archive }}
    dest={{ consul_home }}
    copy=no
  when: consul_ui_was_downloaded|changed

- name: set ownership
  file: >
    state=directory
    path={{consul_ui_dir}}
    owner={{consul_user}}
    group={{consul_group}}
    recurse=yes
  when: consul_ui_was_downloaded|changed

- name: consul nginx config
  template: >
    src=consul-nginx.conf.j2
    dest=/etc/nginx/sites-available/consul
    owner=root
    group=root
    mode=0755
  when: consul_is_ui
  notify:
    - restart nginx  

- name: consul nginx config
  file: >
    state=link
    src=/etc/nginx/sites-available/consul
    path=/etc/nginx/sites-enabled/consul
    owner=root
    group=root
    mode=0755
  when: consul_is_ui and consul_enable_nginx_config
  notify:
  - restart nginx

- name: create nginx home
  file: >
    state=directory
    path=/var/www/consul/htdocs
    owner=root
    group=root
    mode=0755
  notify:
    - restart nginx

- name: download consul ui
  get_url: >
    url={{consul_ui_download}}
    dest={{consul_download_folder}}
  register: consul_ui_was_downloaded

- name: copy and unpack ui
  unarchive: >
    src={{ consul_download_folder }}/{{ consul_ui_archive }}
    dest={{ consul_home }}
    copy=no
  when: consul_ui_was_downloaded|changed

- name: set ownership
  file: >
    state=directory
    path={{consul_ui_dir}}
    owner={{consul_user}}
    group={{consul_group}}
    recurse=yes
  when: consul_ui_was_downloaded|changed

- name: consul nginx config
  template: >
    src=consul-nginx.conf.j2
    dest=/etc/nginx/sites-available/consul
    owner=root
    group=root
    mode=0755
  when: consul_is_ui
  notify:
    - restart nginx  

- name: consul nginx config
  file: >
    state=link
    src=/etc/nginx/sites-available/consul
    path=/etc/nginx/sites-enabled/consul
    owner=root
    group=root
    mode=0755
  when: consul_is_ui and consul_enable_nginx_config
  notify:
  - restart nginx

- name: create nginx home
  file: >
    state=directory
    path=/var/www/consul/htdocs
    owner=root
    group=root
    mode=0755
  notify:
    - restart nginx

Make names for consul ui tasks have "ui" in them
Make names for consul ui tasks have "ui" in them
