Check Pod connectivity in COE
[integration/test.git] / csit / variables / coe / coe_play.yaml
diff --git a/csit/variables/coe/coe_play.yaml b/csit/variables/coe/coe_play.yaml
new file mode 100644 (file)
index 0000000..32c9f09
--- /dev/null
@@ -0,0 +1,157 @@
+---
+
+- hosts: coe-master:coe-minion1:coe-minion2
+  vars:
+    gopath: "{{ ansible_env.HOME }}/go"
+    coe_path: "{{ gopath }}/src/git.opendaylight.org/gerrit/p/coe.git"
+  environment:
+    PATH: "{{ ansible_env.HOME }}:/usr/local/go/bin:{{ ansible_env.HOME }}/go/bin:/usr/local/go/bin:/usr/bin:/bin"
+    GOPATH: "{{ gopath }}"
+    GOROOT: /usr/local/go
+  tasks:
+    - name: Make CNI config directory
+      file:
+        path: /etc/cni/net.d
+        state: directory
+      become: true
+    - name: Generate cni config
+      template:
+        src: "{{ conf_path }}"
+        dest: /etc/cni/net.d/odlovs-cni.conf
+      become: true
+    - name: Create $HOME/go/bin
+      file:
+        path: "{{ ansible_env.HOME }}/go/bin"
+        state: directory
+    - name: Install glide
+      shell: curl https://glide.sh/get | sh
+      args:
+        creates: "{{ gopath }}/bin/glide"
+    - name: Fetch COE git repository
+      git:
+        repo: 'https://git.opendaylight.org/gerrit/p/coe.git'
+        dest: "{{ coe_path }}"
+    - name: Fetch odl-cni dependencies with glide
+      shell: glide install -v
+      args:
+        chdir: "{{ coe_path }}/odlCNIPlugin/odlovs-cni"
+        creates: "{{ coe_path }}/odlCNIPlugin/odlovs-cni/vendor"
+    - name: Build odlovs-cni
+      shell: go build
+      args:
+        chdir: "{{ coe_path }}/odlCNIPlugin/odlovs-cni"
+        creates: "{{ coe_path }}/odlCNIPlugin/odlovs-cni/odlovs-cni"
+    - name: Install odlovs-cni
+      copy:
+        src: "{{ coe_path }}/odlCNIPlugin/odlovs-cni/odlovs-cni"
+        dest: "/opt/cni/bin/odlovs-cni"
+        remote_src: true
+        mode: 0755
+      become: true
+
+- hosts: coe-master
+  vars:
+    gopath: "{{ ansible_env.HOME}}/go"
+    coe_path: "{{ gopath }}/src/git.opendaylight.org/gerrit/p/coe.git"
+  environment:
+    PATH: "{{ ansible_env.PATH }}:/usr/local/go/bin:{{ ansible_env.HOME }}/go/bin:/usr/local/go/bin:{{ gopath }}/bin:/usr/bin:/bin"
+    GOPATH: "{{ gopath }}"
+    GOROOT: /usr/local/go
+  tasks:
+    - name: Fetch watcher dependencies with glide
+      shell: glide install -v
+      args:
+        chdir: "{{ coe_path }}/watcher"
+        creates: "{{ coe_path }}/watcher/vendor"
+    - name: Build watcher
+      shell: go build
+      args:
+        chdir: "{{ coe_path }}/watcher"
+        creates: "{{ coe_path }}/watcher/watcher"
+    - name: Copy watcher to /usr/local/bin
+      copy:
+        src: "{{ coe_path }}/watcher/watcher"
+        dest: /usr/local/bin/watcher
+        mode: 0755
+        remote_src: true
+      become: true
+    - name: Copy coe.yaml to /etc
+      copy:
+        src: "{{ watcher_path }}"
+        dest: /etc
+        mode: 0755
+        remote_src: true
+      become: true
+
+- hosts: coe-master:coe-minion1:coe-minion2
+  tasks:
+    - name: Set OVS Manager
+      shell: ovs-vsctl set-manager tcp:{{ manager_ip }}:{{ manager_port }} && touch /tmp/ovs-set-manager
+      args:
+        creates: /tmp/ovs-set-manager
+      become: true
+    - name: Enable auto-tunnelling
+      shell: ovs-vsctl set O . other_config:local_ip={{ overlay_ip }} && touch /tmp/enable-auto-tunnel
+      args:
+        creates: /tmp/enable-auto-tunnel
+      become: true
+    - name: Enable docker in systemd
+      systemd:
+        name: docker
+        daemon_reload: true
+        enabled: true
+        state: started
+      become: true
+
+
+- hosts: coe-master
+  tasks:
+    - name: Disable swapfile
+      shell: swapoff -a
+      become: true
+    - name: Run kubeadm init
+      shell: kubeadm init --apiserver-advertise-address={{ k8s_advertise_address }} > /tmp/k8s-output
+      args:
+        creates: /tmp/k8s-output
+      become: true
+    - name: Create join script
+      shell: echo "#!/bin/sh" > /tmp/join-k8s.sh && cat /tmp/k8s-output | grep "kubeadm join" | sed -e 's/^[[:space:]]*//g' >> /tmp/join-k8s.sh
+      args:
+        creates: /tmp/join-k8s.sh
+    - name: Fetch join script
+      fetch:
+        src: /tmp/join-k8s.sh
+        dest: /tmp/join-k8s.sh
+        flat: true
+    - name: Make kube directory
+      file:
+        path: "{{ ansible_env.HOME }}/.kube"
+        state: directory
+    - name: Copy kubeconfig
+      copy:
+        src: /etc/kubernetes/admin.conf
+        dest: "{{ ansible_env.HOME }}/.kube/config"
+        remote_src: true
+      become: true
+
+- hosts: coe-master
+  tasks:
+    - name: Run watcher
+      shell: nohup watcher odl </dev/null >/tmp/watcher.out 2>&1 &
+      args:
+        creates: /tmp/watcher.out
+
+- hosts: coe-minion1:coe-minion2
+  tasks:
+    - name: Disable swapfile
+      shell: swapoff -a
+      become: true
+    - name: Copy join file
+      copy:
+        src: /tmp/join-k8s.sh
+        dest: /tmp/join-k8s.sh
+        mode: 0700
+      become: true
+    - name: Join cluster
+      shell: /tmp/join-k8s.sh
+      become: true