---
- name: etcd version
  set_fact:
    etcd_version: "v2.2.0"

- name: Create download dir
  file: path="/tmp/.ansible/files" state=directory

- name: Download tar file
  get_url:
    url: "https://github.com/coreos/etcd/releases/download/{{ etcd_version }}/etcd-{{ etcd_version }}-linux-amd64.tar.gz"
    dest: /tmp/.ansible/files
    validate_certs: False
  environment:
    http_proxy: "{{ http_proxy|default('') }}"
    https_proxy: "{{ https_proxy|default('') }}"

- name: Extract tar file
  unarchive:
    src: "/tmp/.ansible/files/etcd-{{ etcd_version }}-linux-amd64.tar.gz"
    dest: /usr/local
    copy: no

- name: Create symlinks
  file:
    src: /usr/local/etcd-{{ etcd_version }}-linux-amd64/{{ item }}
    dest: /usr/local/bin/{{ item }}
    state: link
  with_items:
    - etcd
    - etcdctl

- name: Create upstart script
  copy: src=etcd.upstart dest=/etc/init/etcd.conf

- name: Create config directory
  file: path="/etc/etcd" state=directory

---
- name: etcd version
  set_fact:
    etcd_version: "v2.2.3"

- name: Create download dir
  file: path="/tmp/.ansible/files" state=directory

- name: Download tar file
  get_url:
    url: "https://github.com/coreos/etcd/releases/download/{{ etcd_version }}/etcd-{{ etcd_version }}-linux-amd64.tar.gz"
    dest: /tmp/.ansible/files
    validate_certs: False
  environment:
    http_proxy: "{{ http_proxy|default('') }}"
    https_proxy: "{{ https_proxy|default('') }}"

- name: Extract tar file
  unarchive:
    src: "/tmp/.ansible/files/etcd-{{ etcd_version }}-linux-amd64.tar.gz"
    dest: /usr/local
    copy: no

- name: Create symlinks
  file:
    src: /usr/local/etcd-{{ etcd_version }}-linux-amd64/{{ item }}
    dest: /usr/local/bin/{{ item }}
    state: link
  with_items:
    - etcd
    - etcdctl

- name: Create upstart script
  copy: src=etcd.upstart dest=/etc/init/etcd.conf

- name: Create config directory
  file: path="/etc/etcd" state=directory

Update ansible etcd version to 2.2.3
Update ansible etcd version to 2.2.3