aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/dpdk/roles/ins_ovs/tasks/ovs.yml
blob: 64475c6a6e1073c754a5f8596b69e013dbfacf58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
##############################################################################
# Copyright (c) 2017 HUAWEI TECHNOLOGIES CO.,LTD and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
---
- name: install prerequisites package
  apt:
    name: "{{ item }}"
    state: present
  with_items:
    - git
    - libnuma-dev
    - dh-autoreconf
    - python-pip

- name: git clone open-vswitch code
  git:
    repo: "{{ ovs_repo }}"
    dest: "{{ ovs_dir }}"
    version: "{{ ovs_version }}"

- name: install prerequisites package
  pip:
    name: six

- name: Check if OVS configure script exists
  stat: path={{ ovs_dir }}/configure
  register: ovs_config_status

- name: Bootstrap OVS if required
  command: ./boot.sh chdir={{ ovs_dir }}
  when: ovs_config_status.stat.exists == false or (ovs_rebuild is defined) or ovs_changed.changed

- name: Check if OVS Makefile exists
  stat: path={{ ovs_dir }}/Makefile
  register: ovs_makefile_status

# yamllint disable rule:line-length
- name: Configure OVS
  command: ./configure --with-dpdk={{ dpdk_build }} CFLAGS="-g -O2 -Wno-cast-align" chdir={{ ovs_dir }}
  when: ovs_makefile_status.stat.exists == false or (ovs_rebuild is defined) or ovs_changed.changed
# yamllint enable rule:line-length

- name: Check if OVS distribution files exists
  stat: path={{ ovs_dir }}/distfiles
  register: ovs_distfiles_status

- name: Build OVS
  command: make CFLAGS='-O3 -march=native' chdir={{ ovs_dir }}
  when: ovs_distfiles_status.stat.exists == false or (ovs_rebuild is defined) or ovs_changed.changed

- name: Check if OVS tools are installed
  stat: path=/usr/local/bin/ovsdb-tool
  register: ovs_tools_status

- name: Install OVS tools
  command: make install chdir={{ ovs_dir }}
  when: ovs_tools_status.stat.exists == false or (ovs_rebuild is defined) or ovs_changed.changed

- name: Create OVS scripts
  template:
    src: "templates/{{ item }}.j2"
    dest: "/opt/{{ item }}"
    mode: 0755
  with_items:
    - start_ovs_vswitchd.sh

- name: Create folders
  file: path={{ item }} state=directory
  with_items:
    - /usr/local/etc/openvswitch
    - /usr/local/var/run/openvswitch

- name: Clear database configuration if required
  file: path=/usr/local/etc/openvswitch/conf.db state=absent
  when: ovs_rebuild is defined or ovs_changed.changed

- name: Check if database configuration exists
  stat: path=/usr/local/etc/openvswitch/conf.db
  register: ovs_dbconfig_status

# yamllint disable rule:line-length
- name: Create database configuration
  command: ovsdb-tool create /usr/local/etc/openvswitch/conf.db /usr/local/share/openvswitch/vswitch.ovsschema
  when: ovs_dbconfig_status.stat.exists == false
# yamllint enable rule:line-length

- name: Start OVS vswitchd with DPDK support enabled
  command: /opt/start_ovs_vswitchd.sh