blob: 87396bf003b34d64e4adbd821e5d3762224265e2 (
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
##############################################################################
# Copyright (c) 2016 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: get image http server
shell: awk -F'=' '/compass_server/ {print $2}' /etc/compass.conf
register: http_server
- name: download onos driver packages
get_url:
url: "http://{{ http_server.stdout_lines[0] }}/packages/onos/{{ onos_driver }}"
dest: /opt/
- name: unarchive onos driver package
command: su -s /bin/sh -c "tar xvf /opt/networking-onos.tar -C /opt/"
- name: install onos driver
command: su -s /bin/sh -c "/opt/networking-onos/install_driver.sh"
- name: download oracle-jdk8 package file
get_url:
url: "http://{{ http_server.stdout_lines[0] }}/packages/java/{{ jdk8_pkg_name }}"
dest: /opt/{{ jdk8_pkg_name }}
- name: install onos required packages
action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
with_items: "{{ packages }}"
- name: download oracle-jdk8 script file
get_url:
url: "http://{{ http_server.stdout_lines[0] }}/packages/java/{{ jdk8_script_name }}"
dest: /opt/
- name: unarchive onos driver package
command: su -s /bin/sh -c "tar xvf /opt/install_jdk8.tar -C /opt/"
- name: install install_jdk8 package
command: su -s /bin/sh -c "/opt/install_jdk8/install_jdk8.sh"
- name: create JAVA_HOME environment variable
shell: >
export J2SDKDIR=/usr/lib/jvm/java-8-oracle;
export J2REDIR=/usr/lib/jvm/java-8-oracle/jre;
export PATH=$PATH:/usr/lib/jvm/java-8-oracle/bin;
export PATH=$PATH:/usr/lib/jvm/java-8-oracle/db/bin;
export PATH=$PATH:/usr/lib/jvm/java-8-oracle/jre/bin;
export JAVA_HOME=/usr/lib/jvm/java-8-oracle;
export DERBY_HOME=/usr/lib/jvm/java-8-oracle/db;
- name: create onos group
group: name=onos system=yes state=present
- name: create onos user
user:
name: onos
group: onos
home: "{{ onos_home }}"
createhome: "yes"
system: "yes"
shell: "/bin/false"
- name: download onos package
get_url:
url: "http://{{ http_server.stdout_lines[0] }}/packages/onos/{{ onos_pkg_name }}"
dest: /opt/{{ onos_pkg_name }}
- name: create new jar repository
command: su -s /bin/sh -c "mkdir ~/.m2"
ignore_errors: "True"
- name: download jar repository
get_url:
url: "http://{{ http_server.stdout_lines[0] }}/packages/onos/{{ repository }}"
dest: ~/.m2/
- name: extract jar repository
command: su -s /bin/sh -c "tar xvf ~/.m2/repository.tar -C ~/.m2/"
- name: extract onos package
command: |
su -s /bin/sh -c "tar xzf /opt/{{ onos_pkg_name }} -C {{ onos_home }} \
--strip-components 1 --no-overwrite-dir -k --skip-old-files" onos
- name: copy onos.service
copy:
src: "{{ onos_service_file.src }}"
dest: "{{ onos_service_file.dst }}"
mode: 0755
- name: configure onos service
shell: >
echo 'export ONOS_OPTS=debug' > {{ onos_home }}/options;
echo 'export ONOS_USER=root' >> {{ onos_home }}/options;
mkdir {{ onos_home }}/var;
mkdir {{ onos_home }}/config;
- name: create karaf config
template:
src: org.apache.karaf.features.cfg
dest: "{{ onos_home }}/{{ karaf_dist }}/etc/org.apache.karaf.features.cfg"
owner: onos
group: onos
mode: 0775
- name: wait for config time
shell: "sleep 10"
- name: chown onos directory and files
shell: >
chown -R onos:onos "{{ onos_home }}";
chown onos:onos "{{ onos_service_file.dst }}";
- name: start onos service
service: name=onos state=started enabled=yes
- name: wait for onos start time
shell: "sleep 200"
- name: add onos auto start
shell: >
echo "onos">>/opt/service
- name: Configure Neutron1
shell: >
crudini --set /etc/neutron/neutron.conf DEFAULT service_plugins onos_router;
crudini --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 \
mechanism_drivers onos_ml2;
crudini --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 \
tenant_network_types vxlan;
crudini --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 type_drivers vxlan
- name: configure metadata
shell: |
crudini --set /etc/neutron/dhcp_agent.ini DEFAULT \
enable_isolated_metadata "True";
- name: force metadata
shell: |
crudini --set /etc/neutron/dhcp_agent.ini DEFAULT \
force_metadata "True";
- name: configure vsctl for dhcp agent
shell: |
crudini --set /etc/neutron/dhcp_agent.ini OVS \
ovsdb_interface vsctl;
- name: Create ML2 Configuration File
template:
src: ml2_conf.sh
dest: "/opt/ml2_conf.sh"
mode: 0777
- name: Configure Neutron2
command: su -s /bin/sh -c "/opt/ml2_conf.sh;"
- name: Configure Neutron3
shell: >
mysql -e "drop database if exists neutron_ml2;";
mysql -e "create database neutron_ml2 character set utf8;";
mysql -e "grant all on neutron_ml2.* to 'neutron'@'%';";
su -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf \
--config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" \
neutron;
- name: Restart neutron-dhcp-agent
service: name=neutron-dhcp-agent state=restarted
- name: Restart neutron-server
service: name=neutron-server state=restarted
|