From 47cfc1c8efa26fbd1a30c53291c5907ddfc0c3d3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ferenc=20T=C3=B3th?= Date: Fri, 28 Jun 2019 10:37:13 +0200 Subject: [PATCH] Add infra_chart_reconfig_fluentd playbook MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This playbook reconfigures the fluentd component of the `caas-infra` chart according to the `log_forwarding` rules in CM. Typically this playbook is called by CM activator whenever the `cloud.caas` content has been changed over REST API or by hostcli. Signed-off-by: Ferenc Tóth Change-Id: I1b6dacc8ce1cab32443b8bd4bea70c67e99508c9 --- SPECS/infra-charts.spec | 6 ++-- .../playbooks/infra_chart_reconfig_fluentd.yaml | 33 ++++++++++++++++++++++ .../roles/infra_chart_reconfig/defaults/main.yaml | 16 +++++++++++ ansible/roles/infra_chart_reconfig/tasks/main.yaml | 29 +++++++++++++++++++ 4 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 ansible/playbooks/infra_chart_reconfig_fluentd.yaml create mode 100644 ansible/roles/infra_chart_reconfig/defaults/main.yaml create mode 100644 ansible/roles/infra_chart_reconfig/tasks/main.yaml diff --git a/SPECS/infra-charts.spec b/SPECS/infra-charts.spec index cba2a0a..9cfc423 100644 --- a/SPECS/infra-charts.spec +++ b/SPECS/infra-charts.spec @@ -15,7 +15,7 @@ %define COMPONENT infra-charts %define RPM_NAME caas-%{COMPONENT} %define RPM_MAJOR_VERSION 1.0.0 -%define RPM_MINOR_VERSION 13 +%define RPM_MINOR_VERSION 14 Name: %{RPM_NAME} Version: %{RPM_MAJOR_VERSION} @@ -26,7 +26,7 @@ BuildArch: x86_64 Vendor: %{_platform_vendor} Source0: %{name}-%{version}.tar.gz -Requires: rsync +Requires: rsync, jq %description This rpm contains the necessary helm charts to deploy the caas subsystem. @@ -39,10 +39,12 @@ This rpm contains the necessary helm charts to deploy the caas subsystem. %install mkdir -p %{buildroot}/%{_playbooks_path}/ rsync -av ansible/playbooks/install_caas_infra.yaml %{buildroot}/%{_playbooks_path}/ +rsync -av ansible/playbooks/infra_chart_reconfig_fluentd.yaml %{buildroot}/%{_playbooks_path}/ mkdir -p %{buildroot}/%{_roles_path}/ rsync -av ansible/roles/install_caas_infra %{buildroot}/%{_roles_path}/ rsync -av ansible/roles/pre_install_caas_infra %{buildroot}/%{_roles_path}/ +rsync -av ansible/roles/infra_chart_reconfig %{buildroot}/%{_roles_path}/ mkdir -p %{buildroot}/%{_caas_chart_path}/ rsync -av infra-charts/* %{buildroot}/%{_caas_chart_path}/ diff --git a/ansible/playbooks/infra_chart_reconfig_fluentd.yaml b/ansible/playbooks/infra_chart_reconfig_fluentd.yaml new file mode 100644 index 0000000..a3dea05 --- /dev/null +++ b/ansible/playbooks/infra_chart_reconfig_fluentd.yaml @@ -0,0 +1,33 @@ +--- +# Copyright 2019 Nokia +# +# 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. + +# nokia.cmframework.requires: install_caas_infra.yaml +- hosts: caas_master + run_once: true + strategy: free + become: true + become_user: "{{ users.admin_user_name }}" + vars: + - infra_chart_name: "caas-infra" + - infra_chart_components: [fluentd] + pre_tasks: + - name: check infra chart status + shell: "helm status {{ infra_chart_name }} -o json | jq .info.status.code" + register: helm_infra_chart_status + ignore_errors: yes + roles: + - role: infra_chart_reconfig + when: + - helm_infra_chart_status.stdout == "1" diff --git a/ansible/roles/infra_chart_reconfig/defaults/main.yaml b/ansible/roles/infra_chart_reconfig/defaults/main.yaml new file mode 100644 index 0000000..3afb374 --- /dev/null +++ b/ansible/roles/infra_chart_reconfig/defaults/main.yaml @@ -0,0 +1,16 @@ +--- +# Copyright 2019 Nokia +# +# 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. + +infra_chart_filenames: "{{ infra_chart_components | map('regex_replace', '^(.*)$', caas.caas_chart_path+'/values_\\1.yaml') | list }}" diff --git a/ansible/roles/infra_chart_reconfig/tasks/main.yaml b/ansible/roles/infra_chart_reconfig/tasks/main.yaml new file mode 100644 index 0000000..4332de1 --- /dev/null +++ b/ansible/roles/infra_chart_reconfig/tasks/main.yaml @@ -0,0 +1,29 @@ +--- +# Copyright 2019 Nokia +# +# 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: collect image names from the deployed {{ infra_chart_name }} chart + shell: "helm get manifest {{ infra_chart_name }} | grep ' image: {{ caas.registry_url }}' | sed 's/^\ *image:\ //' | sort -u" + register: helm_get_manifest_images +- set_fact: + container_image_names: "{{ helm_get_manifest_images.stdout_lines }}" + +- name: template component specific values file + template: + src: "{{ item }}.j2" + dest: "{{ item }}" + with_items: "{{ infra_chart_filenames }}" + +- name: helm upgrade + shell: "HELM_HOST={{ caas.tiller_ip }}:{{ caas.tiller_port }} helm upgrade {{ infra_chart_name }} default/{{ infra_chart_name }} -f {{ infra_chart_filenames | join(',') }} --wait --timeout {{ caas.helm_operation_timeout }}" -- 2.16.6