Browse Source

Merge "Fix ansible deployment along with documentation update"

changes/13/562513/1
Zuul 1 year ago
parent
commit
29a6dd665b

+ 180
- 34
doc/source/installation/playbooks.rst View File

@@ -1,66 +1,212 @@
1
-=============================================
2
-Setup development VMs using Ansible playbooks
3
-=============================================
1
+=====================
2
+Setup development VMs
3
+=====================
4 4
 
5
+Playbooks are designed to setup two nodes. The first node
6
+contains Openstack with, among others, keystone, neutron
7
+and neutron-opencontrail plugin as ML2 L3 driver.
8
+Second node contains nightly-build contrail node.
9
+
10
+Step by step instruction is presented below.
11
+
12
+
13
+*************
5 14
 Initial steps
6
--------------
15
+*************
7 16
 
8 17
 Before you run playbooks perform the following steps:
9 18
 
10
-#. Prepare machines for Contrail node and OpenStack node
19
+**1. Prepare machines for Contrail and OpenStack nodes.**
20
+
21
+Let's assume there are two hosts:
22
+
23
++-----------+--------------+----------------+--------------+------------------------------------+
24
+| Node      | OS           | Public IP      | Internal IP  | Notes                              |
25
++===========+==============+================+==============+====================================+
26
+| openstack | Ubuntu 16.04 | 10.100.0.3     | 192.168.0.3  | setup by playbooks                 |
27
++-----------+--------------+----------------+--------------+------------------------------------+
28
+| contrail  | CentOS 7.4   | 10.100.0.2     | 192.168.0.2  | setup by contrail-ansible-deployer |
29
++-----------+--------------+----------------+--------------+------------------------------------+
30
+
31
+**2. Make sure you have key-based SSH access to prepared nodes**
32
+
33
+.. code-block:: console
34
+
35
+    $ ssh 10.100.0.2
36
+    $ ssh 10.100.0.3
37
+
38
+**3. Install Ansible on your host**
39
+
40
+It is required to install Ansible in version 2.5 or higher.
41
+
42
+.. code-block:: console
43
+
44
+    $ sudo add-apt-repository ppa:ansible/ansible
45
+    $ sudo apt update
46
+    $ sudo apt install python-netaddr ansible
47
+
11 48
 
12
-#. Make sure you have key-based SSH access to prepared nodes::
49
+*******************
50
+Configure playbooks
51
+*******************
13 52
 
14
-    ssh contrail-node
15
-    ssh openstack-node
53
+Configuration require editing few files before running any playbook.
16 54
 
17
-#. Install Ansible::
55
+**1. Define nodes by specifying SSH names or IP of machines in ``playbooks/hosts``**
18 56
 
19
-    sudo apt install ansible
57
+.. code-block:: console
20 58
 
21
-Configuring playbooks
22
----------------------
59
+    $ vim playbooks/hosts
23 60
 
24
-Be sure to adjust configuration according to your setup before running
25
-any playbook:
61
+Change ``contrail-node`` and ``openstack-node`` to public IP of your machines.
26 62
 
27
-#. Define nodes by specifying SSH names of their machines in ``playbooks/hosts`` file::
63
+.. code-block:: text
28 64
 
29 65
     [contrail]
30
-    contrail-node
66
+    10.100.0.2
31 67
 
32 68
     [openstack]
33
-    openstack-node
69
+    10.100.0.3
34 70
 
35
-#. Configure deployment by setting ``playbooks/group_vars/all.yml`` variables, for example::
71
+**2. Change deployment variables in ``playbooks/group_vars/all.yml``**
36 72
 
37
-    ---
38
-    # Internal IP addresses of both nodes
73
+.. code-block:: console
74
+
75
+    $ vim playbooks/group_vars/all.yml
76
+
77
+``contrail_ip`` and ``openstack_ip`` should be internal IP addresses.
78
+
79
+``openstack_branch`` should be set to ``stable/ocata``
80
+``contrail_branch`` is currently ignored but it must not be empty.
81
+
82
+Example config:
83
+
84
+.. code-block:: yaml
85
+
86
+    # [Required] IP address for OpenConrail VM.
39 87
     contrail_ip: 192.168.0.2
88
+    # [Required] IP address for Openstack VM.
40 89
     openstack_ip: 192.168.0.3
41 90
 
42
-    # Names of git branches
91
+    # [Required] Openstack branch used on VMs.
43 92
     openstack_branch: stable/ocata
44
-    contrail_branch: R4.0
93
+    # [Required] OpenContrail branch to build on VM.
94
+    contrail_branch: R4.1
95
+
96
+    # [Required] Kernel version supported by OpenContrail branch.
97
+    kernel_version: 4.4.0-112
98
+
99
+**3. Enable networking-opencontrail plugin**
100
+
101
+Update ``openstack_local.conf.j2`` template.
102
+
103
+.. code-block:: console
104
+
105
+    $ vim playbooks/roles/fetch_devstack/templates/openstack_local.conf.j2
106
+
107
+.. warning:: If plugin is already defined,
108
+             make sure URL and branch version is correct.
109
+
110
+At the end of file add new line with ``enable_plugin`` directive.
111
+
112
+.. code-block:: text
113
+
114
+    enable_plugin networking-opencontrail https://github.com/openstack/networking-opencontrail stable/ocata
115
+
116
+.. note:: Plugin branch should be the same as OpenStack.
117
+          For example if openstack_branch is ``stable/ocata``
118
+          plugin also should point to ``stable/ocata`` branch.
119
+
120
+
121
+**********
122
+Deployment
123
+**********
124
+
125
+Openstack node
126
+==============
127
+
128
+.. note:: Before openstack deployment make sure Playbooks are configured.
129
+
130
+Execute ``playbooks/main.yml`` file.
131
+Make sure you are in playbooks directory before executing playbook.
132
+This will make Ansible to use local ``hosts`` file instead of system broad defined hosts.
133
+
134
+.. code-block:: console
135
+
136
+    $ cd playbooks
137
+    $ ./main.yml  --limit openstack
138
+
139
+
140
+Contrail node
141
+=============
142
+
143
+**1. Clone Contrail Ansible Deployer from Github**
144
+
145
+.. code-block:: console
146
+
147
+    $ git clone http://github.com/Juniper/contrail-ansible-deployer
148
+
149
+**2. Define contrail node by specifying SSH name or IP of machine in ``inventory/hosts``**
150
+
151
+.. warning:: If file is not empty. Remove everything and start from scratch.
152
+
153
+Edit hosts file
154
+
155
+.. code-block:: console
156
+
157
+    $ vim inventory/hosts
158
+
159
+Copy and paste snippet at the end of the file and change IP to Contrail machine public IP
160
+
161
+.. code-block:: text
162
+
163
+    container_hosts:
164
+      hosts:
165
+        10.100.0.2:
166
+          ansible_user: centos
167
+
168
+**3. Contrail nightly builds variables**
169
+
170
+Currently, nightly-builds are available in docker hub's opencontrailnightly repo.
171
+At https://hub.docker.com/r/opencontrailnightly/contrail-agent-vrouter/tags/
172
+can be viewed available contrail builds.
45 173
 
46
-    kernel_version: 3.13.0-77
174
+* ``CONTRAIL_VERSION``: container tag for example ``latest``
175
+* ``CONTROLLER_NODES``: internal IP of contrail node
176
+* ``KEYSTONE_AUTH_HOST``: internal IP of openstack node
177
+* roles ``<IP>``: public IP of contrail node
47 178
 
48
-Setup OpenContrail & Devstack VMs
49
----------------------------------
179
+Edit inventory variables:
50 180
 
51
-Run ``main.yml`` playbook (it could take few hours to finish)::
181
+.. code-block:: console
52 182
 
53
-     playbooks/main.yml
183
+    $ vim config/instances.yaml
54 184
 
185
+Example config:
55 186
 
56
-NOTICE
57
-------
187
+.. code-block:: yaml
58 188
 
59
-Use Ubuntu 14.04 and 16.04 for VMs. If you are installing Openstack Ocata
60
-after succesfull deployment be sure to issue command listed below on OpenStack
61
-node, otherwise scheduling VM using Nova won't work.
189
+    provider_config:
190
+      bms:
191
+    instances:
192
+      bms1:
193
+        provider: bms
194
+        ip: 10.100.0.2
195
+    contrail_configuration:
196
+      CONTAINER_REGISTRY: opencontrailnightly
197
+      CONTRAIL_VERSION: latest
198
+      CONTROLLER_NODES: 192.168.0.2  # contrail node internal IP
199
+      CLOUD_ORCHESTRATOR: openstack
200
+      AUTH_MODE: keystone
201
+      KEYSTONE_AUTH_ADMIN_PASSWORD: admin
202
+      KEYSTONE_AUTH_HOST: 192.168.0.3  # openstack node internal IP
203
+      RABBITMQ_NODE_PORT: 5673
204
+      PHYSICAL_INTERFACE: eth1
205
+      VROUTER_GATEWAY: 192.168.0.1
62 206
 
63
-.. code-block:: bash
207
+**4. Run ansible playbook**
64 208
 
65
-     nova-manage cell_v2 simple_cell_setup
209
+.. code-block:: console
66 210
 
211
+    $ ansible-playbook -i inventory/ playbooks/configure_instances.yml
212
+    $ ansible-playbook -i inventory/ -e orchestrator=openstack playbooks/install_contrail.yml

+ 0
- 11
playbooks/deploy_driver.yml View File

@@ -1,15 +1,4 @@
1 1
 ---
2
-- hosts: contrail
3
-  gather_facts: no 
4
-  become: no
5
-  roles:
6
-    - { role: fetch_deps }
7
-
8
-- hosts: openstack 
9
-  gather_facts: no 
10
-  become: no
11
-  roles:
12
-    - { role: deploy_driver }
13 2
 
14 3
 - hosts: contrail
15 4
   gather_facts: no 

+ 1
- 0
playbooks/roles/contrail_vm/files/contrail_patches View File

@@ -1,3 +1,4 @@
1 1
 patch $CONTRAIL_DEST/devstack/plugin.sh < plugin.patch
2
+patch $CONTRAIL_DEST/devstack/plugin.sh < contrail_plugin_diff.patch
2 3
 patch $CONTRAIL_DEST/devstack/lib/contrail_config < contrail_config.patch
3 4
 patch $CONTRAIL_DEST/controller/src/analytics/SConscript < Analytics-SConscript.patch

+ 35
- 0
playbooks/roles/contrail_vm/files/contrail_plugin_diff.patch View File

@@ -0,0 +1,35 @@
1
+--- /opt/stack/contrail/devstack/plugin.sh.orig	2018-01-12 11:52:36.534751974 +0000
2
++++ /opt/stack/contrail/devstack/plugin.sh	2018-01-12 12:15:53.605687810 +0000
3
+@@ -166,21 +166,21 @@
4
+     [ ! -d /var/log/contrail ] && sudo mkdir /var/log/contrail
5
+     sudo chmod 777 /var/log/contrail
6
+
7
+-    run_process vrouter "sudo contrail-vrouter-agent --config_file=/etc/contrail/contrail-vrouter-agent.conf"
8
+-    run_process api-srv "contrail-api --conf_file /etc/contrail/contrail-api.conf"
9
++    run_process vrouter "/usr/bin/contrail-vrouter-agent --config_file=/etc/contrail/contrail-vrouter-agent.conf" ubuntu root
10
++    run_process api-srv "/usr/bin/contrail-api --conf_file /etc/contrail/contrail-api.conf"
11
+     # Wait for api to be ready, as it creates cassandra CF required for disco to start
12
+     is_service_enabled disco && is_service_enabled api-srv && wget --no-proxy --retry-connrefused --no-check-certificate --waitretry=1 -t 60 -q -O /dev/null http://$APISERVER_IP:8082 || true
13
+-    run_process disco "contrail-discovery --conf_file /etc/contrail/contrail-discovery.conf"
14
+-    run_process svc-mon "contrail-svc-monitor --conf_file /etc/contrail/contrail-svc-monitor.conf"
15
+-    run_process schema "contrail-schema --conf_file /etc/contrail/contrail-schema.conf"
16
+-    run_process control "sudo contrail-control --conf_file /etc/contrail/contrail-control.conf"
17
+-    run_process collector "contrail-collector --conf_file /etc/contrail/contrail-collector.conf"
18
+-    run_process analytic-api "contrail-analytics-api --conf_file /etc/contrail/contrail-analytics-api.conf"
19
++    #run_process disco "contrail-discovery --conf_file /etc/contrail/contrail-discovery.conf"
20
++    run_process svc-mon "/usr/bin/contrail-svc-monitor --conf_file /etc/contrail/contrail-svc-monitor.conf"
21
++    run_process schema "/usr/bin/contrail-schema --conf_file /etc/contrail/contrail-schema.conf"
22
++    run_process control "/usr/bin/contrail-control --conf_file /etc/contrail/contrail-control.conf" ubuntu root
23
++    run_process collector "/usr/bin/contrail-collector --conf_file /etc/contrail/contrail-collector.conf"
24
++    run_process analytic-api "/usr/bin/contrail-analytics-api --conf_file /etc/contrail/contrail-analytics-api.conf"
25
+     run_process alarm-gen "/usr/bin/contrail-alarm-gen --conf_file /etc/contrail/contrail-alarm-gen.conf"
26
+-    run_process query-engine "contrail-query-engine --conf_file /etc/contrail/contrail-query-engine.conf"
27
+-    run_process dns "contrail-dns --conf_file /etc/contrail/dns/contrail-dns.conf"
28
++    run_process query-engine "/usr/bin/contrail-query-engine --conf_file /etc/contrail/contrail-query-engine.conf"
29
++    run_process dns "/usr/bin/contrail-dns --conf_file /etc/contrail/dns/contrail-dns.conf"
30
+     #NOTE: contrail-dns checks for '/usr/bin/contrail-named' in /proc/[pid]/cmdline to retrieve bind status
31
+-    run_process named "sudo /usr/bin/contrail-named -g -c /etc/contrail/dns/contrail-named.conf"
32
++    run_process named "/usr/bin/contrail-named -g -c /etc/contrail/dns/contrail-named.conf -u ubuntu" ubuntu root
33
+
34
+     run_process ui-jobs "cd $CONTRAIL_DEST/contrail-web-core; sudo nodejs jobServerStart.js"
35
+     run_process ui-webs "cd $CONTRAIL_DEST/contrail-web-core; sudo nodejs webServerStart.js"

+ 5
- 0
playbooks/roles/contrail_vm/tasks/contrail_patches.yml View File

@@ -10,6 +10,11 @@
10 10
     src: ../files/plugin.patch
11 11
     dest: ~/devstack/plugin.patch
12 12
 
13
+- name: copy contrail_plugin_diff.patch
14
+  copy:
15
+    src: ../files/contrail_plugin_diff.patch
16
+    dest: ~/devstack/contrail_plugin_diff.patch
17
+
13 18
 - name: copy contrail_config.patch
14 19
   copy:
15 20
     src: ../files/contrail_config.patch

+ 1
- 0
playbooks/roles/contrail_vm/tasks/dependencies.yml View File

@@ -17,3 +17,4 @@
17 17
     - 'libvirt-bin'
18 18
     - 'qemu-kvm'
19 19
     - 'libcrypto++-dev'
20
+    - 'libboost-thread1.58-dev'

+ 0
- 31
playbooks/roles/deploy_driver/tasks/install_contrail_libs.yml View File

@@ -1,31 +0,0 @@
1
----
2
-# Copy Contrail libs to Openstack VM and install them
3
-
4
-- name: copy vnc_api && cfgm_common module
5
-  copy:
6
-    src: /tmp/{{ item }}
7
-    dest: ~/devstack
8
-  with_items:
9
-    - 'vnc_api-0.1.dev0.tar.gz'
10
-    - 'cfgm_common-0.1.dev0.tar.gz'
11
-  tags: driver
12
- 
13
-- name: install vnc_api && cfgm_common module
14
-  shell: 'cd ~/devstack && sudo pip install {{ item }}'
15
-  with_items:
16
-    - 'vnc_api-0.1.dev0.tar.gz'
17
-    - 'cfgm_common-0.1.dev0.tar.gz'
18
-  tags: driver
19
-
20
-- name: clone contrail-neutron-plugin to satisfy dependencies
21
-  git: 
22
-    repo: "https://github.com/Juniper/contrail-neutron-plugin.git"
23
-    dest: ~/contrail-neutron-plugin 
24
-    accept_hostkey: yes
25
-  tags: driver
26
-
27
-- name: install contrail-neutron-plugin
28
-  shell: sudo pip install .
29
-  args:
30
-    chdir: ~/contrail-neutron-plugin
31
-  tags: driver

+ 0
- 6
playbooks/roles/deploy_driver/tasks/main.yml View File

@@ -1,6 +0,0 @@
1
----
2
-# Copy networking-opencontrail dependencies from Contrail node to OpenStack node
3
-
4
-- include: install_contrail_libs.yml
5
-
6
-- include: restart_contrail.yml

+ 0
- 0
playbooks/roles/deploy_driver/tasks/restart_contrail.yml View File


+ 0
- 22
playbooks/roles/fetch_deps/tasks/fetch_drv_depend.yml View File

@@ -1,22 +0,0 @@
1
----
2
-# Copy ContrailMechanismDriver dependencies from Contrail VM
3
-- name: create archive for vnc_api module
4
-  command: chdir=/opt/stack/contrail/build/production/api-lib python setup.py sdist
5
-  become: yes
6
-  tags: driver
7
- 
8
-- name: create archive for cfgm_common module
9
-  command: chdir=/opt/stack/contrail/build/production/config/common python setup.py sdist
10
-  become: yes
11
-  tags: driver
12
-
13
-- name: fetch vnc_api && cfgm_common module
14
-  run_once: yes
15
-  fetch:
16
-    src: /opt/stack/contrail/build/production/{{ item }}
17
-    dest: /tmp/
18
-    flat: yes
19
-  with_items:
20
-    - 'api-lib/dist/vnc_api-0.1.dev0.tar.gz'
21
-    - 'config/common/dist/cfgm_common-0.1.dev0.tar.gz'
22
-  tags: driver

+ 0
- 4
playbooks/roles/fetch_deps/tasks/main.yml View File

@@ -1,4 +0,0 @@
1
----
2
-# Create python packages and fetch them
3
-
4
-- include: fetch_drv_depend.yml

+ 2
- 0
playbooks/roles/fetch_devstack/templates/contrail_local.conf.j2 View File

@@ -20,6 +20,8 @@ MYSQL_HOST=$SERVICE_HOST
20 20
 RABBIT_HOST=$SERVICE_HOST
21 21
 Q_HOST=$SERVICE_HOST
22 22
 
23
+USE_SCREEN=True
24
+
23 25
 # starting from Ocata release placement-api is required 
24 26
 # and has to be enabled as well
25 27
 {% if 'newton' in openstack_branch %}

+ 5
- 3
playbooks/roles/fetch_devstack/templates/openstack_local.conf.j2 View File

@@ -19,7 +19,7 @@ KEYSTONE_BRANCH={{ openstack_branch }}
19 19
 NEUTRON_BRANCH={{ openstack_branch }}
20 20
 
21 21
 LOG_COLOR=True
22
-#USE_SCREEN=True
22
+USE_SCREEN=True
23 23
 disable_service n-net n-cpu c-sch c-api c-vol q-dhcp q-agt q-l3 dstat tempest
24 24
 
25 25
 NEUTRON_CREATE_INITIAL_NETWORKS={{ create_initial_networks }}
@@ -28,6 +28,8 @@ Q_PLUGIN=ml2
28 28
 
29 29
 ML2_L3_PLUGIN=opencontrail-router
30 30
 
31
-CONTRAIL_DRIVER_CONTROLLER='{{ contrail_ip }}'
32
-CONTRAIL_DRIVER_PORT={{ contrail_port }}
31
+OPENCONTRAIL_APISERVER_IP='{{ contrail_ip }}'
32
+OPENCONTRAIL_APISERVER_PORT={{ contrail_port }}
33
+
33 34
 enable_plugin networking-opencontrail https://github.com/openstack/networking-opencontrail
35
+#enable_plugin networking-opencontrail https://github.com/openstack/networking-opencontrail stable/ocata

+ 10
- 0
playbooks/roles/openstack_vm/files/keystone_stable-pike.patch View File

@@ -0,0 +1,10 @@
1
+--- keystone.orig	2018-01-09 10:50:01.005819940 +0000
2
++++ keystone	2018-01-09 10:50:18.133820750 +0000
3
+@@ -607,7 +607,7 @@
4
+         --bootstrap-role-name admin \
5
+         --bootstrap-service-name keystone \
6
+         --bootstrap-region-id "$REGION_NAME" \
7
+-        --bootstrap-admin-url "$KEYSTONE_AUTH_URI" \
8
++        --bootstrap-admin-url "$KEYSTONE_AUTH_URI/v2.0" \
9
+         --bootstrap-public-url "$KEYSTONE_SERVICE_URI"
10
+ }

+ 0
- 15
playbooks/roles/openstack_vm/tasks/install_drv_depend.yml View File

@@ -1,15 +0,0 @@
1
----
2
-# Install networking-opencontrail dependencies to Openstack VM
3
-
4
-- name: clone contrail-neutron-plugin to satisfy dependencies
5
-  git: 
6
-    repo: "https://github.com/Juniper/contrail-neutron-plugin.git"
7
-    dest: ~/contrail-neutron-plugin 
8
-    accept_hostkey: yes
9
-  tags: driver
10
-
11
-- name: install contrail-neutron-plugin
12
-  shell: sudo pip install .
13
-  args:
14
-    chdir: ~/contrail-neutron-plugin
15
-  tags: driver

+ 4
- 1
playbooks/roles/openstack_vm/tasks/openstack_patch.yml View File

@@ -2,8 +2,11 @@
2 2
 # Patch stack.sh for proper endpoints used by OpenContrail controller
3 3
 - name: copy Openstack endpoint patch
4 4
   copy:
5
-    src: ../files/keystone.patch
5
+    src: "{{ item }}"
6 6
     dest: ~/devstack/keystone.patch
7
+  with_first_found:
8
+    - ../files/keystone_{{ openstack_branch | regex_replace('/', '-') }}.patch
9
+    - ../files/keystone.patch
7 10
 
8 11
 - name: patch keystone endpoint 
9 12
   shell: patch keystone < ../keystone.patch

Loading…
Cancel
Save