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