53cccd449010e543bcd27ea5b029781131718cac
[integration/test.git] / csit / variables / coe / coe_play.yaml
1 ---
2
3 - hosts: coe-hosts
4   vars:
5     gopath: "{{ ansible_env.HOME }}/go"
6     coe_path: "{{ gopath }}/src/git.opendaylight.org/gerrit/p/coe.git"
7   environment:
8     PATH: "{{ ansible_env.HOME }}:/usr/local/go/bin:{{ ansible_env.HOME }}/go/bin:/usr/local/go/bin:/usr/bin:/bin"
9     GOPATH: "{{ gopath }}"
10     GOROOT: /usr/local/go
11   tasks:
12     - name: Make CNI config directory
13       file:
14         path: /etc/cni/net.d
15         state: directory
16       become: true
17     - name: Generate cni config
18       template:
19         src: "{{ conf_path }}"
20         dest: /etc/cni/net.d/odlovs-cni.conf
21       become: true
22     - name: Create $HOME/go/bin
23       file:
24         path: "{{ ansible_env.HOME }}/go/bin"
25         state: directory
26     - name: Install dep
27       shell: curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
28       args:
29         creates: "{{ gopath }}/bin/dep"
30     - name: Fetch COE git repository
31       git:
32         repo: 'https://git.opendaylight.org/gerrit/p/coe.git'
33         dest: "{{ coe_path }}"
34     - name: Fetch odl-cni dependencies with dep
35       shell: dep ensure -vendor-only
36       args:
37         chdir: "{{ coe_path }}/odlCNIPlugin/odlovs-cni"
38         creates: "{{ coe_path }}/odlCNIPlugin/odlovs-cni/vendor"
39     - name: Build odlovs-cni
40       shell: go build
41       args:
42         chdir: "{{ coe_path }}/odlCNIPlugin/odlovs-cni"
43         creates: "{{ coe_path }}/odlCNIPlugin/odlovs-cni/odlovs-cni"
44     - name: Install odlovs-cni
45       copy:
46         src: "{{ coe_path }}/odlCNIPlugin/odlovs-cni/odlovs-cni"
47         dest: "/opt/cni/bin/odlovs-cni"
48         remote_src: true
49         mode: 0755
50       become: true
51
52 - hosts: coe-master
53   vars:
54     gopath: "{{ ansible_env.HOME}}/go"
55     coe_path: "{{ gopath }}/src/git.opendaylight.org/gerrit/p/coe.git"
56   environment:
57     PATH: "{{ ansible_env.PATH }}:/usr/local/go/bin:{{ ansible_env.HOME }}/go/bin:/usr/local/go/bin:{{ gopath }}/bin:/usr/bin:/bin"
58     GOPATH: "{{ gopath }}"
59     GOROOT: /usr/local/go
60   tasks:
61     - name: Fetch watcher dependencies with dep
62       shell: dep ensure -vendor-only
63       args:
64         chdir: "{{ coe_path }}/watcher"
65         creates: "{{ coe_path }}/watcher/vendor"
66     - name: Build watcher
67       shell: go build
68       args:
69         chdir: "{{ coe_path }}/watcher"
70         creates: "{{ coe_path }}/watcher/watcher"
71     - name: Copy watcher to /usr/local/bin
72       copy:
73         src: "{{ coe_path }}/watcher/watcher"
74         dest: /usr/local/bin/watcher
75         mode: 0755
76         remote_src: true
77       become: true
78     - name: Copy coe.yaml to /etc
79       copy:
80         src: "{{ watcher_path }}"
81         dest: /etc
82         mode: 0755
83         remote_src: true
84       become: true
85
86 - hosts: coe-hosts
87   tasks:
88     - name: Set OVS Manager
89       shell: ovs-vsctl set-manager tcp:{{ manager_ip }}:{{ manager_port }} && touch /tmp/ovs-set-manager
90       args:
91         creates: /tmp/ovs-set-manager
92       become: true
93     - name: Enable auto-tunnelling
94       shell: ovs-vsctl set O . other_config:local_ip={{ overlay_ip }} && touch /tmp/enable-auto-tunnel
95       args:
96         creates: /tmp/enable-auto-tunnel
97       become: true
98     - name: Enable docker in systemd
99       systemd:
100         name: docker
101         daemon_reload: true
102         enabled: true
103         state: started
104       become: true
105
106
107 - hosts: coe-master
108   tasks:
109     - name: Disable swapfile
110       shell: swapoff -a
111       become: true
112     - name: Run kubeadm init
113       shell: kubeadm init --apiserver-advertise-address={{ k8s_advertise_address }} > /tmp/k8s-output
114       args:
115         creates: /tmp/k8s-output
116       become: true
117     - name: Create join script
118       shell: echo "#!/bin/sh" > /tmp/join-k8s.sh && cat /tmp/k8s-output | grep "kubeadm join" | sed -e 's/^[[:space:]]*//g' >> /tmp/join-k8s.sh
119       args:
120         creates: /tmp/join-k8s.sh
121     - name: Fetch join script
122       fetch:
123         src: /tmp/join-k8s.sh
124         dest: /tmp/join-k8s.sh
125         flat: true
126     - name: Make kube directory
127       file:
128         path: "{{ ansible_env.HOME }}/.kube"
129         state: directory
130     - name: Copy kubeconfig
131       copy:
132         src: /etc/kubernetes/admin.conf
133         dest: "{{ ansible_env.HOME }}/.kube/config"
134         remote_src: true
135       become: true
136
137 - hosts: coe-master
138   tasks:
139     - name: Run watcher
140       shell: nohup watcher odl </dev/null >/tmp/watcher.out 2>&1 &
141       args:
142         creates: /tmp/watcher.out
143
144 - hosts: coe-minions
145   tasks:
146     - name: Disable swapfile
147       shell: swapoff -a
148       become: true
149     - name: Copy join file
150       copy:
151         src: /tmp/join-k8s.sh
152         dest: /tmp/join-k8s.sh
153         mode: 0700
154       become: true
155     - name: Join cluster
156       shell: /tmp/join-k8s.sh
157       become: true