[docker][ansible] Add a playbook for building the containers 30/72430/18
authorEmma Foley <efoley@redhat.com>
Fri, 23 Apr 2021 18:46:57 +0000 (19:46 +0100)
committerEmma Foley <efoley@redhat.com>
Fri, 17 Dec 2021 09:48:20 +0000 (09:48 +0000)
To run the playbook and build the containers, run::
   sudo ansible-playbook docker/ansible/collectd_build.yml

Change-Id: I60e044f09c8da53f6d5a56d2aaa7b837b19a0b0b
Signed-off-by: Emma Foley <efoley@redhat.com>
docker/ansible/collectd_build.yml [new file with mode: 0644]
docker/ansible/roles/build_collectd/tasks/main.yml [new file with mode: 0644]
docs/release/release-notes/notes/ansible-build-containers-b4a4cc9cb70f83b3.yaml [new file with mode: 0644]
docs/release/userguide/installguide.oneclick.rst

diff --git a/docker/ansible/collectd_build.yml b/docker/ansible/collectd_build.yml
new file mode 100644 (file)
index 0000000..d5cad07
--- /dev/null
@@ -0,0 +1,22 @@
+# Copyright 2021 Anuket and others
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+---
+# ansible-playbook collectd_build.yml
+#
+- hosts: localhost
+  become: true
+  become_user: root
+  gather_facts: true
+  roles:
+    - name: build_collectd
diff --git a/docker/ansible/roles/build_collectd/tasks/main.yml b/docker/ansible/roles/build_collectd/tasks/main.yml
new file mode 100644 (file)
index 0000000..b8d5f4b
--- /dev/null
@@ -0,0 +1,71 @@
+# Copyright 2021 Anuket and others
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+---
+- name: Build stable container
+  docker_image:
+    name: opnfv/barometer-collectd
+    build:
+      path: "{{ playbook_dir }}/../barometer-collectd/"
+    source: build
+  tags:
+    - stable
+
+- name: Build the latest container
+  docker_image:
+    name: opnfv/barometer-collectd-latest
+    build:
+      path: "{{ playbook_dir }}/../../"
+      dockerfile: "docker/barometer-collectd-latest/Dockerfile"
+    source: build
+  tags:
+    - latest
+
+- name: Build collectd-experimental
+  docker_image:
+    name: opnfv/barometer-collectd-experimental
+    build:
+      path: "{{ playbook_dir }}/../../"
+      dockerfile: "docker/barometer-collectd-experimental/Dockerfile"
+      args:
+        COLLECTD_FLAVOR: experimental
+        COLLECTD_TAG: "{{ COLLECTD_TAG | default('main') }}"
+        COLLECTD_PULL_REQUESTS: "{{ COLLECTD_PULL_REQUESTS | default() }}"
+    source: build
+  tags:
+    - experimental
+
+- name: Build collectd-6
+  docker_image:
+    name: "opnfv/barometer-collectd-6{{ ( '-' + COLLECTD_PULL_REQUESTS ) if COLLECTD_PULL_REQUESTS is defined else '' }}"
+    build:
+      path: "{{ playbook_dir }}/../../"
+      dockerfile: "docker/barometer-collectd-experimental/Dockerfile"
+      args:
+        COLLECTD_FLAVOR: collectd-6
+        COLLECTD_TAG: "{{ COLLECTD_TAG | default('collectd-6.0') }}"
+        COLLECTD_PULL_REQUESTS: "{{ COLLECTD_PULL_REQUESTS | default(omit) }}"
+    source: build
+  tags:
+    - collectd-6
+
+- name: Build test_app for write_http
+  docker_image:
+    name: test-collectd-write_http
+    build:
+      path: "{{ playbook_dir }}/../flask_app/"
+    source: build
+  tags:
+    - flask_test
+    - never
+
diff --git a/docs/release/release-notes/notes/ansible-build-containers-b4a4cc9cb70f83b3.yaml b/docs/release/release-notes/notes/ansible-build-containers-b4a4cc9cb70f83b3.yaml
new file mode 100644 (file)
index 0000000..aae4b99
--- /dev/null
@@ -0,0 +1,11 @@
+release_summary: >
+    Add ansible playbook for building the containers locally.
+ansible:
+  - | 
+    Added a playbook and role for building the collectd containers locally.
+    This automates the actions described in the docker install guide. The
+    ``barometer-collectd``, ``barometer-collectd-latest`` and the
+    ``barometer-collectd-experimental`` containers are now easier to build
+    locally. The ``barometer-collectd-6`` and
+    ``barometer-collectd-experimental`` containers can also be built with
+    arbirtary PRs applied, to aid in testing locally. 
index ef3624c..78203a1 100644 (file)
@@ -231,6 +231,36 @@ Verify that key is added and password is not required to connect.
    example. For multinode installation keys need to be copied for each node:
    [collectd_hostname], [influxdb_hostname] etc.
 
+Build the Collectd containers
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+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`_.
+This step will build the container images locally, allowing for testing of new changes to collectd.
+This is particularly useful for the ``experimental`` flavour for testing PRs, and for building a ``collectd-6`` container.
+
+To run the playbook and build the containers, run::
+    sudo ansible-playbook docker/ansible/collectd_build.yml
+
+By default, all contaienrs will be built.
+Since this can take a while, it is recommended that you choose a flavor to build using tags::
+
+    sudo ansible-playbook docker/ansible/collectd_build.yml --tags='collectd-6,latest'
+
+The available tags are:
+
+* *stable* builds the ``barometer-collectd`` image
+* *latest* builds the ``barometer-collectd-latest`` image
+* *experimental* builds the ``barometer-collectd-experimental`` container, with optional PRs
+* *collectd-6* builds the ``baromter-collectd-6`` container, with optional PR(s)
+
+* *flask_test* builds a small webapp that displays the metrics sent via the write_http plugin
+
+.. note::
+   The flask_test tag must be explicitly enabled.
+   This can be done either through the ``--tags='flask_test'`` (to build just
+   this container) or with ``--tags=all`` to build this and all the other
+   containers as well.
+
 Download and run Collectd+Influxdb+Grafana containers
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^