Skip to content

Instantly share code, notes, and snippets.

@nicusX
Created August 11, 2016 13:00
Show Gist options
  • Save nicusX/31c530a7c35a374be974e8bc5546adf0 to your computer and use it in GitHub Desktop.
Save nicusX/31c530a7c35a374be974e8bc5546adf0 to your computer and use it in GitHub Desktop.
- name: Create etcd config dir
file: path=/etc/etcd state=directory
become: true
- name: Copy certificates
copy:
src: "{{ playbook_dir }}/../cert/{{ item }}"
dest: "/etc/etcd/"
become: true
with_items:
- ca.pem
- kubernetes.pem
- kubernetes-key.pem
- name: Download etcd binaries
get_url:
url: "https://github.com/coreos/etcd/releases/download/v3.0.1/etcd-v3.0.-linux-amd64.tar.gz"
dest: "/usr/local/src"
become: true
- name: Unpack etcd binaries
unarchive:
copy: no
src: "/usr/local/src/etcd-v3.0.-linux-amd64.tar.gz"
dest: "/usr/local/src/"
creates: "/usr/local/src/etcd-v3.0.-linux-amd64/etcd"
become: true
- name: Copy etcd binaries
copy:
remote_src: true
src: "/usr/local/src/etcd-v3.0.-linux-amd64/{{ item }}"
dest: "/usr/bin"
owner: root
group: root
mode: 0755
with_items:
- etcd
- etcdctl
become: true
- name: Create etcd data dir
file: path=/var/lib/etcd state=directory
become: true
- name: Add etcd systemd unit
template:
src: etcd.service.j2
dest: /etc/systemd/system/etcd.service
mode: 700
become: true
- name: Reload systemd
command: systemctl daemon-reload
become: true
- name: Enable etcd service
command: systemctl enable etcd
become: true
- name: Restart etcd
service:
name: etcd
state: restarted
enabled: yes
become: true
- name: Wait for etcd listening
wait_for: port=2379 timeout=60
- name: Verify etcd cluster health
shell: etcdctl --ca-file=/etc/etcd/ca.pem cluster-health
register: cmd_result
until: cmd_result.stdout.find("cluster is healthy") != -1
retries: 5
delay: 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment