Enable weave seed mode for kubespray (#1414)

* Enable weave seed mode for kubespray

* fix task Weave seed | Set peers if existing peers

* fix mac address variabilisation

* fix default values

* fix include seed condition

* change weave var to default values

* fix Set peers if existing peers
This commit is contained in:
timtoum
2017-07-26 18:09:34 +02:00
committed by Matthew Mosesohn
parent ee36763f9d
commit 3e457e4edf
8 changed files with 226 additions and 100 deletions

View File

@@ -1,6 +1,9 @@
---
- include: pre-upgrade.yml
- include: seed.yml
when: weave_mode_seed
- name: Weave | enable br_netfilter module
modprobe:
name: br_netfilter

View File

@@ -0,0 +1,50 @@
---
- name: Weave seed | Set seed if first time
set_fact:
seed: '{% for host in groups["k8s-cluster"] %}{{ hostvars[host]["ansible_default_ipv4"]["macaddress"] }}{% if not loop.last %},{% endif %}{% endfor %}'
when: "weave_seed == 'uninitialized'"
run_once: true
tags: confweave
- name: Weave seed | Set seed if not first time
set_fact:
seed: '{{ weave_seed }}'
when: "weave_seed != 'uninitialized'"
run_once: true
tags: confweave
- name: Weave seed | Set peers if fist time
set_fact:
peers: '{{ weave_ip_current_cluster }}'
when: "weave_peers == 'uninitialized'"
run_once: true
tags: confweave
- name: Weave seed | Set peers if existing peers
set_fact:
peers: '{{ weave_peers }}{% for ip in weave_ip_current_cluster.split(" ") %}{% if ip not in weave_peers.split(" ") %} {{ ip }}{% endif %}{% endfor %}'
when: "weave_peers != 'uninitialized'"
run_once: true
tags: confweave
- name: Weave seed | Save seed
lineinfile:
dest: "./inventory/group_vars/k8s-cluster.yml"
state: present
regexp: '^weave_seed:'
line: 'weave_seed: {{ seed }}'
become: no
delegate_to: 127.0.0.1
run_once: true
tags: confweave
- name: Weave seed | Save peers
lineinfile:
dest: "./inventory/group_vars/k8s-cluster.yml"
state: present
regexp: '^weave_peers:'
line: 'weave_peers: {{ peers }}'
become: no
delegate_to: 127.0.0.1
run_once: true
tags: confweave