2016-12-09 00:48:54 +08:00
|
|
|
---
|
|
|
|
# Required from inventory:
|
|
|
|
# calico_rr_ip - which specific IP to use for RR, defaults to
|
|
|
|
# "ip" from inventory or "ansible_default_ipv4.address"
|
|
|
|
|
|
|
|
- name: Calico-rr | Set IP fact
|
|
|
|
set_fact:
|
2019-03-05 19:04:39 +08:00
|
|
|
rr_ip: "{{ calico_rr_ip | default(ip) | default(fallback_ips[inventory_hostname]) }}"
|
2016-12-09 00:48:54 +08:00
|
|
|
|
2016-12-24 00:25:37 +08:00
|
|
|
- name: Calico-rr | Create calico certs directory
|
2016-12-09 00:48:54 +08:00
|
|
|
file:
|
|
|
|
dest: "{{ calico_cert_dir }}"
|
|
|
|
state: directory
|
|
|
|
mode: 0750
|
2017-02-06 20:58:54 +08:00
|
|
|
owner: root
|
|
|
|
group: root
|
2016-12-09 00:48:54 +08:00
|
|
|
|
2016-12-24 00:25:37 +08:00
|
|
|
- name: Calico-rr | Link etcd certificates for calico-node
|
2016-12-09 00:48:54 +08:00
|
|
|
file:
|
2016-12-24 00:25:37 +08:00
|
|
|
src: "{{ etcd_cert_dir }}/{{ item.s }}"
|
2016-12-09 00:48:54 +08:00
|
|
|
dest: "{{ calico_cert_dir }}/{{ item.d }}"
|
|
|
|
state: hard
|
|
|
|
force: yes
|
|
|
|
with_items:
|
2019-04-19 21:01:54 +08:00
|
|
|
- {s: "{{ kube_etcd_cacert_file }}", d: "ca_cert.crt"}
|
|
|
|
- {s: "{{ kube_etcd_cert_file }}", d: "cert.crt"}
|
|
|
|
- {s: "{{ kube_etcd_key_file }}", d: "key.pem"}
|
2016-12-09 00:48:54 +08:00
|
|
|
|
|
|
|
- name: Calico-rr | Create dir for logs
|
|
|
|
file:
|
|
|
|
path: /var/log/calico-rr
|
|
|
|
state: directory
|
|
|
|
mode: 0755
|
2017-02-06 20:58:54 +08:00
|
|
|
owner: root
|
|
|
|
group: root
|
2016-12-09 00:48:54 +08:00
|
|
|
|
|
|
|
- name: Calico-rr | Write calico-rr.env for systemd init file
|
2017-02-18 05:22:34 +08:00
|
|
|
template:
|
|
|
|
src: calico-rr.env.j2
|
|
|
|
dest: /etc/calico/calico-rr.env
|
2016-12-09 00:48:54 +08:00
|
|
|
notify: restart calico-rr
|
|
|
|
|
|
|
|
- name: Calico-rr | Write calico-rr systemd init file
|
2017-02-18 05:22:34 +08:00
|
|
|
template:
|
|
|
|
src: calico-rr.service.j2
|
|
|
|
dest: /etc/systemd/system/calico-rr.service
|
2016-12-09 00:48:54 +08:00
|
|
|
notify: restart calico-rr
|
|
|
|
|
|
|
|
- name: Calico-rr | Configure route reflector
|
2018-09-19 22:22:52 +08:00
|
|
|
command: |-
|
|
|
|
{{ bin_dir }}/etcdctl \
|
|
|
|
--endpoints={{ etcd_access_addresses }} \
|
|
|
|
put /calico/bgp/v1/rr_v4/{{ rr_ip }} \
|
|
|
|
'{
|
|
|
|
"ip": "{{ rr_ip }}",
|
|
|
|
"cluster_id": "{{ cluster_id }}"
|
|
|
|
}'
|
|
|
|
environment:
|
|
|
|
ETCDCTL_API: 3
|
2018-09-20 01:32:16 +08:00
|
|
|
ETCDCTL_CERT: "{{ etcd_cert_dir }}/admin-{{ groups['etcd'][0] }}.pem"
|
|
|
|
ETCDCTL_KEY: "{{ etcd_cert_dir }}/admin-{{ groups['etcd'][0] }}-key.pem"
|
2018-09-19 22:22:52 +08:00
|
|
|
retries: 4
|
|
|
|
delay: "{{ retry_stagger | random + 3 }}"
|
|
|
|
delegate_to: "{{groups['etcd'][0]}}"
|
|
|
|
when:
|
2018-10-17 06:33:30 +08:00
|
|
|
- calico_version is version("v3.0.0", ">=")
|
2018-09-19 22:22:52 +08:00
|
|
|
|
|
|
|
- name: Calico-rr | Configure route reflector (legacy)
|
2016-12-09 00:48:54 +08:00
|
|
|
command: |-
|
2018-02-27 22:34:07 +08:00
|
|
|
{{ bin_dir }}/etcdctl \
|
|
|
|
--peers={{ etcd_access_addresses }} \
|
2016-12-09 00:48:54 +08:00
|
|
|
set /calico/bgp/v1/rr_v4/{{ rr_ip }} \
|
|
|
|
'{
|
|
|
|
"ip": "{{ rr_ip }}",
|
|
|
|
"cluster_id": "{{ cluster_id }}"
|
|
|
|
}'
|
2018-09-20 01:32:16 +08:00
|
|
|
environment:
|
|
|
|
ETCDCTL_CERT_FILE: "{{ etcd_cert_dir }}/admin-{{ groups['etcd'][0] }}.pem"
|
|
|
|
ETCDCTL_KEY_FILE: "{{ etcd_cert_dir }}/admin-{{ groups['etcd'][0] }}-key.pem"
|
2017-11-29 00:39:55 +08:00
|
|
|
retries: 4
|
|
|
|
delay: "{{ retry_stagger | random + 3 }}"
|
2016-12-09 00:48:54 +08:00
|
|
|
delegate_to: "{{groups['etcd'][0]}}"
|
2018-09-19 22:22:52 +08:00
|
|
|
when:
|
2018-10-17 06:33:30 +08:00
|
|
|
- calico_version is version("v3.0.0", "<")
|
2016-12-09 00:48:54 +08:00
|
|
|
|
|
|
|
- meta: flush_handlers
|
|
|
|
|
|
|
|
- name: Calico-rr | Enable calico-rr
|
|
|
|
service:
|
|
|
|
name: calico-rr
|
|
|
|
state: started
|
|
|
|
enabled: yes
|