c12s-kubespray/roles/network_plugin/weave/tasks/seed.yml
timtoum 3e457e4edf 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
2017-07-26 19:09:34 +03:00

50 lines
No EOL
1.4 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
- 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