blob: 1d3e90cdb9d50fec5f2f49328d02789830055ed5 [file] [log] [blame]
Hyunsun Moone4848342020-02-16 04:28:55 -08001# Copyright 2020-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15---
16- name: Initialize k8s role
17 set_fact:
18 k8s_roles: ""
19 tags: k8s
20
21- name: Add k8s master role
22 set_fact:
23 k8s_roles: "{{ k8s_roles }} --etcd --controlplane"
24 when: "'kube-master' in group_names"
25 tags: k8s
26
27- name: Add k8s worker role
28 set_fact:
29 k8s_roles: "{{ k8s_roles }} --worker"
30 when: "'kube-worker' in group_names"
31 tags: k8s
32
33- name: Print k8s roles
34 debug:
35 msg: k8s_roles {{ k8s_roles }}
36 tags: k8s
37
Hyunsun Moon6c6db952020-03-04 20:50:51 -080038# TODO: Wait until K8S cluster is ready
Hyunsun Moone4848342020-02-16 04:28:55 -080039- name: Install k8s
40 command: >-
41 docker run -d --privileged --restart=unless-stopped --net=host
42 --volume /etc/kubernetes:/etc/kubernetes
43 --volume /var/run:/var/run
44 rancher/rancher-agent:v2.3.3
Hyunsun Moon04f409e2020-04-23 13:54:39 -070045 --server {{ rancher_server_url }}
Hyunsun Moone4848342020-02-16 04:28:55 -080046 --token {{ rancher_cluster_token }}
47 --ca-checksum {{ rancher_ca_checksum }}
48 {{ k8s_roles }}
Hyunsun Moon6c6db952020-03-04 20:50:51 -080049 changed_when: False
Hyunsun Moone4848342020-02-16 04:28:55 -080050 tags: k8s