Restructuring the repo.
[multicloud/k8s.git] / kud / deployment_infra / playbooks / configure-ovn4nfv.yml
1 ---
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2018
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10 - import_playbook: configure-ovn.yml
11 - import_playbook: configure-multus.yml
12
13 - hosts: kube-master:kube-node
14   environment:
15     PATH: "{{ ansible_env.PATH }}:/usr/local/go/bin/"
16   roles:
17     - role: andrewrothstein.go
18   tasks:
19     - name: Load kud variables
20       include_vars:
21         file: kud-vars.yml
22     - name: clone ovn4nfv-k8s-plugin repo
23       git:
24         repo: "{{ ovn4nfv_url }}"
25         dest: "{{ ovn4nfv_dest }}"
26         version: "{{ ovn4nfv_version }}"
27         force: yes
28       when: ovn4nfv_source_type == "source"
29     - name: clean ovn4nfvk8s left over files
30       make:
31         chdir: "{{ ovn4nfv_dest }}"
32         target: clean
33     - name: build ovn4nfvk8s-cni
34       make:
35         chdir: "{{ ovn4nfv_dest }}"
36         target: ovn4nfvk8s-cni
37       become: yes
38       environment:
39         GOPATH: "{{ go_path }}"
40     - name: copy ovn4nfvk8s-cni to cni folder
41       command: "mv {{ ovn4nfv_dest }}/ovn4nfvk8s-cni /opt/cni/bin/ovn4nfvk8s-cni"
42       become: yes
43     - name: create ovn4k8s config file
44       become: yes
45       blockinfile:
46         path: /etc/openvswitch/ovn4nfv_k8s.conf
47         create: yes
48         block: |
49           [logging]
50           loglevel=5
51           logfile=/var/log/openvswitch/ovn4k8s.log
52
53           [cni]
54           conf-dir=/etc/cni/net.d
55           plugin=ovn4nfvk8s-cni
56
57           [kubernetes]
58           kubeconfig=/etc/kubernetes/admin.conf
59     - name: create ovnkube logging directory
60       file:
61         path: /var/log/openvswitch
62         state: directory
63
64 - hosts: kube-master
65   environment:
66     PATH: "{{ ansible_env.PATH }}:/usr/local/go/bin/"
67   become: yes
68   tasks:
69     - name: Load kud variables
70       include_vars:
71         file: kud-vars.yml
72     - name: build ovn4nfvk8s
73       make:
74         chdir: "{{ ovn4nfv_dest }}"
75         target: ovn4nfvk8s
76       environment:
77         GOPATH: "{{ go_path }}"
78     - name: copy ovn4nfvk8s to /usr/bin folder
79       command: "mv {{ ovn4nfv_dest }}/ovn4nfvk8s /usr/bin/ovn4nfvk8s"
80     - name: create ovn4nfvk8s systemd service
81       blockinfile:
82         path: /etc/systemd/system/ovn4nfvk8s.service
83         create: yes
84         block: |
85           [Unit]
86           Description=OVN4NFV Kubernetes Daemon
87
88           [Service]
89           ExecStart=/usr/bin/ovn4nfvk8s \
90                 -k8s-kubeconfig=/etc/kubernetes/admin.conf
91
92           [Install]
93           WantedBy=multi-user.target
94     - name: start ovn4nfvk8s systemd service
95       service:
96         name: ovn4nfvk8s
97         state: started
98         enabled: yes