[docker][ansible] Add a playbook for building the containers
[barometer.git] / docs / release / userguide / installguide.oneclick.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
3 .. (c) Anuket and others
4 .. _barometer-oneclick-userguide:
5
6 ========================================
7 Anuket Barometer One Click Install Guide
8 ========================================
9
10 .. contents::
11    :depth: 3
12    :local:
13
14 The intention of this user guide is to outline how to use the ansible
15 playbooks for a one click installation of Barometer. A more in-depth
16 installation guide is available with the
17 :ref:`Docker user guide <barometer-docker-userguide>`.
18
19
20 One Click Install with Ansible
21 ------------------------------
22
23
24 Proxy for package manager on host
25 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26 .. note::
27    This step has to be performed only if host is behind HTTP/HTTPS proxy
28
29 Proxy URL have to be set in dedicated config file
30
31 1. CentOS - ``/etc/yum.conf``
32
33 .. code:: bash
34
35     proxy=http://your.proxy.domain:1234
36
37 2. Ubuntu - ``/etc/apt/apt.conf``
38
39 .. code:: bash
40
41     Acquire::http::Proxy "http://your.proxy.domain:1234"
42
43 After update of config file, apt mirrors have to be updaited via
44 ``apt-get update``
45
46 .. code:: bash
47
48     $ sudo apt-get update
49
50 Proxy environment variables (for docker and pip)
51 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
52 .. note::
53    This step has to be performed only if host is behind HTTP/HTTPS proxy
54
55 Configuring proxy for packaging system is not enough, also some proxy
56 environment variables have to be set in the system before ansible scripts
57 can be started.
58 Barometer configures docker proxy automatically via ansible task as a part
59 of *one click install* process - user only has to provide proxy URL using common
60 shell environment variables and ansible will automatically configure proxies
61 for docker(to be able to fetch barometer images). Another component used by
62 ansible (e.g. pip is used for downloading python dependencies) will also benefit
63 from setting proxy variables properly in the system.
64
65 Proxy variables used by ansible One Click Install:
66    * ``http_proxy``
67    * ``https_proxy``
68    * ``ftp_proxy``
69    * ``no_proxy``
70
71 Variables mentioned above have to be visible for superuser (because most
72 actions involving ``ansible-barometer`` installation require root privileges).
73 Proxy variables are commonly defined in ``/etc/environment`` file (but any other
74 place is good as long as variables can be seen by commands using ``su``).
75
76 Sample proxy configuration in ``/etc/environment``:
77
78 .. code:: bash
79
80     http_proxy=http://your.proxy.domain:1234
81     https_proxy=http://your.proxy.domain:1234
82     ftp_proxy=http://your.proxy.domain:1234
83     no_proxy=localhost
84
85 Install Ansible
86 ^^^^^^^^^^^^^^^
87 .. note::
88    * sudo permissions or root access are required to install ansible.
89    * ansible version needs to be 2.4+, because usage of import/include statements
90
91 The following steps have been verified with Ansible 2.6.3 on Ubuntu 16.04 and 18.04.
92 To install Ansible 2.6.3 on Ubuntu:
93
94 .. code:: bash
95
96     $ sudo apt-get install python
97     $ sudo apt-get install python-pip
98     $ sudo -H pip install 'ansible==2.6.3'
99     $ sudo apt-get install git
100
101 The following steps have been verified with Ansible 2.6.3 on Centos 7.5.
102 To install Ansible 2.6.3 on Centos:
103
104 .. code:: bash
105
106     $ sudo yum install python
107     $ sudo yum install epel-release
108     $ sudo yum install python-pip
109     $ sudo -H pip install 'ansible==2.6.3'
110     $ sudo yum install git
111
112 .. note::
113    When using multi-node-setup, please make sure that ``python`` package is
114    installed on all of the target nodes (ansible during 'Gathering facts'
115    phase is using ``python2`` and it may not be installed by default on some
116    distributions - e.g. on Ubuntu 16.04 it has to be installed manually)
117
118 Clone barometer repo
119 ^^^^^^^^^^^^^^^^^^^^
120
121 .. code:: bash
122
123     $ git clone https://gerrit.opnfv.org/gerrit/barometer
124     $ cd barometer
125
126 Install ansible dependencies
127 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
128
129 To run the ansible playbooks for the one-click install, additional dependencies are needed.
130 There are listed in requirements.yml and can be installed using::
131
132   $ ansible-galaxy install -r $barometer_dir/requirements.yml
133
134
135 Edit inventory file
136 ^^^^^^^^^^^^^^^^^^^
137 Edit inventory file and add hosts:
138 ``$barometer_dir/docker/ansible/default.inv``
139
140 .. code:: bash
141
142     [collectd_hosts]
143     localhost
144
145     [collectd_hosts:vars]
146     install_mcelog=true
147     insert_ipmi_modules=true
148     #to use master or experimental container set the collectd flavor below
149     #possible values: stable|master|experimental
150     flavor=stable
151
152     [influxdb_hosts]
153     #hostname or ip must be used.
154     #using localhost will cause issues with collectd network plugin.
155     #hostname
156
157     [grafana_hosts]
158     #NOTE: As per current support, Grafana and Influxdb should be same host.
159     #hostname
160
161     [prometheus_hosts]
162     #localhost
163
164     [zookeeper_hosts]
165     #NOTE: currently one zookeeper host is supported
166     #hostname
167
168     [kafka_hosts]
169     #hostname
170
171     [ves_hosts]
172     #hostname
173
174 Change localhost to different hosts where neccessary.
175 Hosts for influxdb and grafana are required only for ``collectd_service.yml``.
176 Hosts for zookeeper, kafka and ves are required only for ``collectd_ves.yml``.
177
178 .. note::
179    Zookeeper, Kafka and VES need to be on the same host, there is no
180    support for multi node setup.
181
182 To change host for kafka edit ``kafka_ip_addr`` in
183 ``./roles/config_files/vars/main.yml``.
184
185 Additional plugin dependencies
186 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
187
188 By default ansible will try to fulfill dependencies for ``mcelog`` and
189 ``ipmi`` plugin. For ``mcelog`` plugin it installs mcelog daemon. For ipmi it
190 tries to insert ``ipmi_devintf`` and ``ipmi_si`` kernel modules.
191 This can be changed in inventory file with use of variables ``install_mcelog``
192 and ``insert_ipmi_modules``, both variables are independent:
193
194 .. code:: bash
195
196     [collectd_hosts:vars]
197     install_mcelog=false
198     insert_ipmi_modules=false
199
200 .. note::
201    On Ubuntu 18.04 the deb package for mcelog daemon is not available in official
202    Ubuntu repository. In that case ansible scripts will try to download, make and
203    install the daemon from mcelog git repository.
204
205 Configure ssh keys
206 ^^^^^^^^^^^^^^^^^^
207
208 Generate ssh keys if not present, otherwise move onto next step.
209 ssh keys are required for Ansible to connect the host you use for Barometer Installation.
210
211 .. code:: bash
212
213     $ sudo ssh-keygen
214
215 Copy ssh key to all target hosts. It requires to provide root password.
216 The example is for ``localhost``.
217
218 .. code:: bash
219
220     $ sudo -i
221     $ ssh-copy-id root@localhost
222
223 Verify that key is added and password is not required to connect.
224
225 .. code:: bash
226
227     $ sudo ssh root@localhost
228
229 .. note::
230    Keys should be added to every target host and [localhost] is only used as an
231    example. For multinode installation keys need to be copied for each node:
232    [collectd_hostname], [influxdb_hostname] etc.
233
234 Build the Collectd containers
235 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
236
237 This is an optional step, if you do not wish to build the containers locally, please continue to `Download and run Collectd+Influxdb+Grafana containers`_.
238 This step will build the container images locally, allowing for testing of new changes to collectd.
239 This is particularly useful for the ``experimental`` flavour for testing PRs, and for building a ``collectd-6`` container.
240
241 To run the playbook and build the containers, run::
242     sudo ansible-playbook docker/ansible/collectd_build.yml
243
244 By default, all contaienrs will be built.
245 Since this can take a while, it is recommended that you choose a flavor to build using tags::
246
247     sudo ansible-playbook docker/ansible/collectd_build.yml --tags='collectd-6,latest'
248
249 The available tags are:
250
251 * *stable* builds the ``barometer-collectd`` image
252 * *latest* builds the ``barometer-collectd-latest`` image
253 * *experimental* builds the ``barometer-collectd-experimental`` container, with optional PRs
254 * *collectd-6* builds the ``baromter-collectd-6`` container, with optional PR(s)
255
256 * *flask_test* builds a small webapp that displays the metrics sent via the write_http plugin
257
258 .. note::
259    The flask_test tag must be explicitly enabled.
260    This can be done either through the ``--tags='flask_test'`` (to build just
261    this container) or with ``--tags=all`` to build this and all the other
262    containers as well.
263
264 Download and run Collectd+Influxdb+Grafana containers
265 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
266
267 The One Click installation features easy and scalable deployment of Collectd,
268 Influxdb and Grafana containers using Ansible playbook. The following steps goes
269 through more details.
270
271 .. code:: bash
272
273     $ sudo -H ansible-playbook -i default.inv collectd_service.yml
274
275 Check the three containers are running, the output of ``docker ps`` should be similar to:
276
277 .. code:: bash
278
279     $ sudo docker ps
280     CONTAINER ID   IMAGE                       COMMAND                  CREATED             STATUS         PORTS     NAMES
281     4c2143fb6bbd   anuket/barometer-grafana    "/run.sh"                59 minutes ago      Up 4 minutes             bar-grafana
282     5e356cb1cb04   anuket/barometer-influxdb   "/entrypoint.sh infl…"   59 minutes ago      Up 4 minutes             bar-influxdb
283     2ddac8db21e2   anuket/barometer-collectd   "/run_collectd.sh"       About an hour ago   Up 4 minutes             bar-collectd
284
285 To make some changes when a container is running run:
286
287 .. code:: bash
288
289     $ sudo docker exec -ti <CONTAINER ID> /bin/bash
290
291 Connect to ``<host_ip>:3000`` with a browser and log into Grafana: admin/admin.
292 For short introduction please see the:
293 `Grafana guide <https://grafana.com/docs/grafana/latest/guides/getting_started/>`_.
294
295 The collectd configuration files can be accessed directly on target system in
296 ``/opt/collectd/etc/collectd.conf.d``. It can be used for manual changes or
297 enable/disable plugins. If configuration has been modified it is required to
298 restart collectd:
299
300 .. code:: bash
301
302     $ sudo docker restart bar-collectd
303
304 Download and run collectd+kafka+ves containers
305 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
306
307 .. code:: bash
308
309     $ sudo ansible-playbook -i default.inv collectd_ves.yml
310
311 Check the containers are running, the output of ``docker ps`` should be similar to:
312
313 .. code:: bash
314
315     $ sudo docker ps
316     CONTAINER ID        IMAGE                      COMMAND                  CREATED             STATUS                     PORTS               NAMES
317     d041d8fff849        zookeeper:3.4.11           "/docker-entrypoint.…"   2 minutes ago       Up 2 minutes                                   bar-zookeeper
318     da67b81274bc        anuket/barometer-ves       "./start_ves_app.sh …"   2 minutes ago       Up 2 minutes                                   bar-ves
319     2c25e0c79f93        anuket/barometer-kafka     "/src/start_kafka.sh"    2 minutes ago       Up 2 minutes                                   bar-kafka
320     b161260c90ed        anuket/barometer-collectd  "/run_collectd.sh"       2 minutes ago       Up 2 minutes                                   bar-collectd
321
322
323 To make some changes when a container is running run:
324
325 .. code:: bash
326
327     $ sudo docker exec -ti <CONTAINER ID> /bin/bash
328
329 List of default plugins for collectd container
330 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
331 .. note::
332    From Jerma release, the supported dpdk version is 19.11
333
334    If you would like to use v18.11, make the following changes:
335
336    1. Update the dpdk version to v18.11 in ``<barometer>/src/package-list.mk``
337    2. Replace all ``common_linux`` string with ``common_linuxapp`` in ``<barometer>/src/dpdk/Makefile``
338
339    If you would like to downgrade to a version lower than v18.11, make the following changes:
340
341    1. Update the dpdk version to a version lower than v18.11 (e.g.:- v16.11) in ``<barometer>/src/package-list.mk``
342    2. Replace all ``common_linux`` string with ``common_linuxapp`` in ``<barometer>/src/dpdk/Makefile``
343    3. Change the Makefile path from ``(WORKDIR)/kernel/linux/kni/Makefile`` to ``(WORKDIR)/lib/librte_eal/linuxapp/kni/Makefile`` in ``(WORK_DIR)/src/dpdk/Makefile``.
344
345 By default the collectd is started with default configuration which includes
346 the following plugins:
347
348 * ``csv``, ``contextswitch``, ``cpu``, ``cpufreq``, ``df``, ``disk``,
349   ``ethstat``, ``ipc``, ``irq``, ``load``, ``memory``, ``numa``,
350   ``processes``, ``swap``, ``turbostat``, ``uuid``, ``uptime``, ``exec``,
351   ``hugepages``, ``intel_pmu``, ``ipmi``, ``write_kafka``, ``logfile``,
352   ``logparser``, ``mcelog``, ``network``, ``intel_rdt``, ``rrdtool``,
353   ``snmp_agent``, ``syslog``, ``virt``, ``ovs_stats``, ``ovs_events``,
354   ``dpdk_telemetry``.
355
356 .. note::
357    Some of the plugins are loaded depending on specific system requirements and can be omitted if
358    dependency is not met, this is the case for:
359
360    * ``hugepages``, ``ipmi``, ``mcelog``, ``intel_rdt``, ``virt``, ``ovs_stats``, ``ovs_events``
361
362    For instructions on how to disable certain plugins see the `List and description of tags used in ansible scripts`_ section.
363
364 List and description of tags used in ansible scripts
365 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
366
367 Tags can be used to run a specific part of the configuration without running
368 the whole playbook. To run a specific parts only:
369
370 .. code:: bash
371
372     $ sudo ansible-playbook -i default.inv collectd_service.yml --tags "syslog,cpu,uuid"
373
374 To disable some parts or plugins:
375
376 .. code:: bash
377
378     $ sudo ansible-playbook -i default.inv collectd_service.yml --skip-tags "en_default_all,syslog,cpu,uuid"
379
380 List of available tags:
381
382 ``install_docker``
383   Install docker and required dependencies with package manager.
384
385 ``add_docker_proxy``
386   Configure proxy file for docker service if proxy is set on host environment.
387
388 ``rm_config_dir``
389   Remove collectd config files.
390
391 ``copy_additional_configs``
392   Copy additional configuration files to target system. Path to additional
393   configuration is stored in
394   ``$barometer_dir/docker/ansible/roles/config_files/docs/main.yml`` as
395   ``additional_configs_path``.
396
397 ``en_default_all``
398   Set of default read plugins: ``contextswitch``, ``cpu``, ``cpufreq``, ``df``,
399   ``disk``, ``ethstat``, ``ipc``, ``irq``, ``load``, ``memory``, ``numa``,
400   ``processes``, ``swap``, ``turbostat``, ``uptime``.
401
402 ``plugins tags``
403   The following tags can be used to enable/disable plugins: ``csv``,
404   ``contextswitch``, ``cpu``, ``cpufreq``, ``df``, ``disk,`` ``ethstat``,
405   ``ipc``, ``irq``, ``load``, ``memory``, ``numa``, ``processes``, ``swap``,
406   ``turbostat``, ``uptime``, ``exec``, ``hugepages``, ``ipmi``, ``kafka``,
407   ``logfile``, ``logparser``, ``mcelog``, ``network``, ``pmu``, ``rdt``,
408   ``rrdtool``, ``snmp``, ``syslog``, ``unixsock``, ``virt``, ``ovs_stats``,
409   ``ovs_events``, ``uuid``, ``dpdk_telemetry``.
410