OCD ansible playbooks for ealt-edge helm cAdvisor 31/3431/1
authorArvind Patel <arvind.patel@huawei.com>
Wed, 13 May 2020 10:57:20 +0000 (16:27 +0530)
committerArvind Patel <arvind.patel@huawei.com>
Wed, 13 May 2020 10:57:20 +0000 (16:27 +0530)
Change-Id: I90f4fdc0cc7214171cf8f79c8664b9b1199eb27f

ocd/infra/playbooks/roles/cAdvisor/files/values.yaml [new file with mode: 0644]
ocd/infra/playbooks/roles/cAdvisor/tasks/install.yml [new file with mode: 0644]
ocd/infra/playbooks/roles/cAdvisor/tasks/main.yml [new file with mode: 0644]
ocd/infra/playbooks/roles/cAdvisor/tasks/uninstall.yml [new file with mode: 0644]
ocd/infra/playbooks/roles/helm/tasks/install.yml [new file with mode: 0644]
ocd/infra/playbooks/roles/helm/tasks/main.yml [new file with mode: 0644]
ocd/infra/playbooks/roles/helm/tasks/uninstall.yml [new file with mode: 0644]

diff --git a/ocd/infra/playbooks/roles/cAdvisor/files/values.yaml b/ocd/infra/playbooks/roles/cAdvisor/files/values.yaml
new file mode 100644 (file)
index 0000000..a27be11
--- /dev/null
@@ -0,0 +1,3 @@
+image:
+  repository: unibaktr/cadvisor
+  tag: v0.36.0
diff --git a/ocd/infra/playbooks/roles/cAdvisor/tasks/install.yml b/ocd/infra/playbooks/roles/cAdvisor/tasks/install.yml
new file mode 100644 (file)
index 0000000..73a8b90
--- /dev/null
@@ -0,0 +1,40 @@
+# Copyright 2020 Huawei Technologies Co., Ltd.
+#
+# 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: check if cadvisor is already installed
+  shell:
+    cmd: helm status cadvisor
+  register: result
+  ignore_errors: 'True'
+
+- name: "This is for Add repo helm "
+  command: helm repo add code-chris https://code-chris.github.io/helm-charts
+  when: result is failed
+
+- name: "This is for Update helm repo"
+  command: helm repo update
+  when: result is failed
+
+- name: copy values.yaml to host
+  copy:
+    src: values.yaml
+    dest: /tmp/cAdvisor/
+  when: result is failed
+
+- name: "Command for install cAdvisor"
+# yamllint disable rule:line-length
+  command: helm install cadvisor code-chris/cadvisor -f /tmp/cAdvisor/values.yaml
+# yamllint disable rule:line-length
+  when: result is failed
diff --git a/ocd/infra/playbooks/roles/cAdvisor/tasks/main.yml b/ocd/infra/playbooks/roles/cAdvisor/tasks/main.yml
new file mode 100644 (file)
index 0000000..121a8e0
--- /dev/null
@@ -0,0 +1,27 @@
+# Copyright 2020 Huawei Technologies Co., Ltd.
+#
+# 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.
+
+---
+
+# tasks file for cAdvisor
+
+- name: Install cAdvisor
+  debug:
+    msg: installing cAdvisor
+
+- include: "install.yml"
+  when: operation == 'install'
+
+- include: "uninstall.yml"
+  when: operation == 'uninstall'
diff --git a/ocd/infra/playbooks/roles/cAdvisor/tasks/uninstall.yml b/ocd/infra/playbooks/roles/cAdvisor/tasks/uninstall.yml
new file mode 100644 (file)
index 0000000..7b7dfce
--- /dev/null
@@ -0,0 +1,29 @@
+# Copyright 2020 Huawei Technologies Co., Ltd.
+#
+# 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: check if cadvisor is installed before deleting
+  shell:
+    cmd: helm status cadvisor
+  register: result
+  ignore_errors: 'True'
+
+- name: "Go to helm ls"
+  command: helm ls
+  when: result is succeeded
+
+- name: "Uninstall cadvisor"
+  command: helm delete cadvisor
+  when: result is succeeded
diff --git a/ocd/infra/playbooks/roles/helm/tasks/install.yml b/ocd/infra/playbooks/roles/helm/tasks/install.yml
new file mode 100644 (file)
index 0000000..cee370f
--- /dev/null
@@ -0,0 +1,57 @@
+# Copyright 2020 Huawei Technologies Co., Ltd.
+#
+# 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: check whether helm is already installed
+  command: which helm
+  register: result
+  ignore_errors: 'True'
+
+- name: "Helm download command on x86_64"
+  command: wget https://get.helm.sh/helm-v3.0.2-linux-amd64.tar.gz
+  when: result is failed and ansible_architecture == 'x86_64'
+
+- name: "Untar helm on x86_64"
+  command: tar -zxvf helm-v3.0.2-linux-amd64.tar.gz
+  when: result is failed and ansible_architecture == 'x86_64'
+
+- name: "Move to bin folder on x86_64"
+  command: mv linux-amd64/helm /usr/local/bin/
+  when: result is failed and ansible_architecture == 'x86_64'
+
+- name: "Helm download command on aarch64"
+  command: wget https://get.helm.sh/helm-v3.0.2-linux-arm64.tar.gz
+  when: result is failed and ansible_architecture == 'aarch64'
+
+- name: "Untar helm on aarch64"
+  command: tar -zxvf helm-v3.0.2-linux-arm64.tar.gz
+  when: result is failed and ansible_architecture == 'aarch64'
+
+- name: "Move to bin folder on aarch64"
+  command: mv linux-arm64/helm /usr/local/bin/
+  when: result is failed and ansible_architecture == 'aarch64'
+
+- name: "Add repo"
+# yamllint disable rule:line-length
+  command: helm repo add stable https://kubernetes-charts.storage.googleapis.com/
+# yamllint disable rule:line-length
+  when: result is failed
+
+- name: "update repo"
+  command: helm repo update
+  when: result is failed
+
+- name: "list repo"
+  command: helm repo list
+  when: result is failed
diff --git a/ocd/infra/playbooks/roles/helm/tasks/main.yml b/ocd/infra/playbooks/roles/helm/tasks/main.yml
new file mode 100644 (file)
index 0000000..00d0493
--- /dev/null
@@ -0,0 +1,25 @@
+# Copyright 2020 Huawei Technologies Co., Ltd.
+#
+# 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.
+---
+
+# tasks file for helm
+- name: Helm install
+  debug:
+    msg: installing helm
+
+- include: "install.yml"
+  when: operation == 'install'
+
+- include: "uninstall.yml"
+  when: operation == 'uninstall'
diff --git a/ocd/infra/playbooks/roles/helm/tasks/uninstall.yml b/ocd/infra/playbooks/roles/helm/tasks/uninstall.yml
new file mode 100644 (file)
index 0000000..3e25035
--- /dev/null
@@ -0,0 +1,39 @@
+# Copyright 2020 Huawei Technologies Co., Ltd.
+#
+# 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: check whether helm is installed before deleting
+  command: which helm
+  register: result
+  ignore_errors: 'True'
+
+- name: Helm Uninstall on x86_64
+  command: rm -rf linux-amd64/helm
+  when: result is succeeded and ansible_architecture == 'x86_64'
+
+- name: Remove download file on x86_64
+  command: rm ~/helm-v3.0.2-linux-amd64.tar.gz
+  when: result is succeeded and ansible_architecture == 'x86_64'
+
+- name: Helm Uninstall on aarch64
+  command: rm -rf linux-arm64/helm
+  when: result is succeeded and ansible_architecture == 'aarch64'
+
+- name: Remove download file on aarch64
+  command: rm helm-v3.0.2-linux-arm64.tar.gz
+  when: result is succeeded and ansible_architecture == 'aarch64'
+
+- name: Remove helm from bin
+  command: rm /usr/local/bin/helm
+  when: result is succeeded