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