Change-Id: Ie19368d97c0e95de0ad46807db44818e78709c68
19 files changed:
- prometheus
- helm
- k3s
- prometheus
- helm
- k3s
- hosts: infra-helm
become: yes
- hosts: infra-helm
become: yes
- prometheus
- kubeconfig
- cadvisor
- prometheus
- kubeconfig
- cadvisor
- hosts: mepautomate
become: yes
- hosts: mepautomate
become: yes
# yamllint disable rule:line-length
when: result.stdout == ""
# yamllint disable rule:line-length
when: result.stdout == ""
-- name: "Installing docker update"
+- name: "INSTALL: Installing docker update"
command: apt-get update -y
ignore_errors: yes
failed_when: false
no_log: True
command: apt-get update -y
ignore_errors: yes
failed_when: false
no_log: True
-- name: "Installing docker upgrade"
+- name: "INSTALL: Installing docker upgrade"
# yamllint disable rule:line-length
command: apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
# yamllint disable rule:line-length
ignore_errors: yes
when: result is failed and ansible_architecture == 'aarch64'
# yamllint disable rule:line-length
command: apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
# yamllint disable rule:line-length
ignore_errors: yes
when: result is failed and ansible_architecture == 'aarch64'
+- name: "INSTALL: Add repository"
shell: curl -sL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
when: result is failed and ansible_architecture == 'aarch64'
shell: curl -sL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
when: result is failed and ansible_architecture == 'aarch64'
-- name: "CA-Certificates"
+- name: "INSTALL: CA-Certificates"
# yamllint disable rule:line-length
shell: sudo add-apt-repository "deb [arch=arm64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
# yamllint disable rule:line-length
# yamllint disable rule:line-length
shell: sudo add-apt-repository "deb [arch=arm64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
# yamllint disable rule:line-length
no_log: True
when: result is failed and ansible_architecture == 'aarch64'
no_log: True
when: result is failed and ansible_architecture == 'aarch64'
+- name: "INSTALL: Update....."
command: apt-get update -y
ignore_errors: yes
failed_when: false
no_log: True
when: result is failed and ansible_architecture == 'aarch64'
command: apt-get update -y
ignore_errors: yes
failed_when: false
no_log: True
when: result is failed and ansible_architecture == 'aarch64'
-- name: "Installed docker"
+- name: "INSTALL: Installed docker"
command: apt-get install -y docker-ce docker-ce-cli containerd.io
ignore_errors: yes
when: result is failed and ansible_architecture == 'aarch64'
command: apt-get install -y docker-ce docker-ce-cli containerd.io
ignore_errors: yes
when: result is failed and ansible_architecture == 'aarch64'
---
# tasks file for docker
- include: "install.yml"
---
# tasks file for docker
- include: "install.yml"
when: operation == 'install'
- include: "uninstall.yml"
when: operation == 'install'
- include: "uninstall.yml"
when: operation == 'uninstall'
when: operation == 'uninstall'
# yamllint disable rule:line-length
when: result.stdout == ""
# yamllint disable rule:line-length
when: result.stdout == ""
-- name: "Uninstall docker engine"
+- name: "UNINSTALL: Uninstall docker engine"
command: apt-get purge -y docker-engine
ignore_errors: yes
when: result is succeeded and ansible_architecture == 'aarch64'
command: apt-get purge -y docker-engine
ignore_errors: yes
when: result is succeeded and ansible_architecture == 'aarch64'
-- name: "Uninstall docker"
+- name: "UNINSTALL: Uninstall docker"
command: apt-get purge -y docker
ignore_errors: yes
when: result is succeeded and ansible_architecture == 'aarch64'
#when: result is succeeded and ansible_architecture == 'x86_64'
command: apt-get purge -y docker
ignore_errors: yes
when: result is succeeded and ansible_architecture == 'aarch64'
#when: result is succeeded and ansible_architecture == 'x86_64'
-- name: "Uninstall docker.io"
+- name: "UNINSTALL: Uninstall docker.io"
command: apt-get purge -y docker.io
ignore_errors: yes
when: result is succeeded and ansible_architecture == 'aarch64'
command: apt-get purge -y docker.io
ignore_errors: yes
when: result is succeeded and ansible_architecture == 'aarch64'
-- name: "Uninstall docker-ce"
+- name: "UNINSTALL: Uninstall docker-ce"
command: apt-get purge -y docker-ce
ignore_errors: yes
when: result is succeeded and ansible_architecture == 'aarch64'
#when: result is succeeded and ansible_architecture == 'aarch64'
command: apt-get purge -y docker-ce
ignore_errors: yes
when: result is succeeded and ansible_architecture == 'aarch64'
#when: result is succeeded and ansible_architecture == 'aarch64'
-- name: "Uninstall docker"
+- name: "UNINSTALL: Uninstall docker"
command: apt-get purge -y docker-ce-cli
ignore_errors: yes
when: result is succeeded and ansible_architecture == 'aarch64'
command: apt-get purge -y docker-ce-cli
ignore_errors: yes
when: result is succeeded and ansible_architecture == 'aarch64'
# limitations under the License.
---
# limitations under the License.
---
-- name: Install grafana on x86_64
+- name: check if grafana is already installed
+ shell:
+ cmd: helm status mec-grafana
+ register: result
+ ignore_errors: yes
+ no_log: True
+
+- debug:
+ msg: grafana is already present
+ when: result.stdout != ""
+
+- debug:
+# yamllint disable rule:line-length
+ msg: Ignore Uninstall Log , Grafana not installed continue with Installation
+# yamllint disable rule:line-length
+ when: result.stdout == ""
+
+- name: "INSTALL: Install grafana on x86_64"
shell:
cmd: helm install mec-grafana stable/grafana
when: result is failed and ansible_architecture == 'x86_64'
shell:
cmd: helm install mec-grafana stable/grafana
when: result is failed and ansible_architecture == 'x86_64'
-- name: copy values.yaml to host
+- name: "INSTALL: copy values.yaml to host"
copy:
src: values.yaml
dest: /tmp/grafana/
when: result is failed and ansible_architecture == 'aarch64'
copy:
src: values.yaml
dest: /tmp/grafana/
when: result is failed and ansible_architecture == 'aarch64'
-- name: Install grafana on aarch64
+- name: "INSTALL: Install grafana on aarch64"
shell:
cmd: helm install mec-grafana stable/grafana -f /tmp/grafana/values.yaml
when: result is failed and ansible_architecture == 'aarch64'
shell:
cmd: helm install mec-grafana stable/grafana -f /tmp/grafana/values.yaml
when: result is failed and ansible_architecture == 'aarch64'
---
- include: "install.yml"
---
- include: "install.yml"
when: operation == 'install'
when: operation == 'install'
-- include: "uninstall.yml"
- when: operation == 'uninstall'
+ #- include: "uninstall.yml"
+ #when: operation == 'uninstall'
# limitations under the License.
---
# limitations under the License.
---
+- name: check if grafana is installed before deleting
+ shell:
+ cmd: helm status mec-grafana
+ register: result
+ ignore_errors: yes
+ no_log: True
+
+- debug:
+ msg: Uninstalling docker...
+ when: result.stdout != ""
+
+- debug:
+ msg: Ignore Uninstall Log , Grafana not installed
+ when: result.stdout == ""
+
- name: Uninstall grafana
shell:
cmd: helm uninstall mec-grafana
- name: Uninstall grafana
shell:
cmd: helm uninstall mec-grafana
# yamllint disable rule:line-length
when: result.stdout == ""
# yamllint disable rule:line-length
when: result.stdout == ""
-- name: "Helm download command on x86_64"
+- name: "INSTALL: 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'
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"
+- name: "INSTALL: 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'
command: tar -zxvf helm-v3.0.2-linux-amd64.tar.gz
when: result is failed and ansible_architecture == 'x86_64'
-- name: "Helm move to bin folder on x86_64"
+- name: "INSTALL: Helm move to bin folder on x86_64"
command: mv linux-amd64/helm /usr/local/bin/
when: result is failed and ansible_architecture == '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"
+- name: "INSTALL: 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'
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"
+- name: "INSTALL: Untar helm on aarch64"
command: tar -zxvf helm-v3.0.2-linux-arm64.tar.gz
when: result is failed and ansible_architecture == 'aarch64'
command: tar -zxvf helm-v3.0.2-linux-arm64.tar.gz
when: result is failed and ansible_architecture == 'aarch64'
-- name: "Helm move to bin folder on aarch64"
+- name: "INSTALL: Helm move to bin folder on aarch64"
command: mv linux-arm64/helm /usr/local/bin/
when: result is failed and ansible_architecture == 'aarch64'
command: mv linux-arm64/helm /usr/local/bin/
when: result is failed and ansible_architecture == 'aarch64'
+- name: "INSTALL: Add helm 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
# 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: "Updated helm repo"
+- name: "INSTALL: Updated helm repo"
command: helm repo update
when: result is failed
command: helm repo update
when: result is failed
-- name: "List helm repo"
+- name: "INSTALLED List helm repo"
command: helm repo list
when: result is failed
command: helm repo list
when: result is failed
# tasks file for helm
- include: "install.yml"
# tasks file for helm
- include: "install.yml"
when: operation == 'install'
- include: "uninstall.yml"
when: operation == 'install'
- include: "uninstall.yml"
when: operation == 'uninstall'
when: operation == 'uninstall'
# limitations under the License.
---
# limitations under the License.
---
-- name: Helm Uninstall on x86_64
+- name: check whether helm is installed before deleting
+ command: which helm
+ register: result
+ ignore_errors: yes
+ no_log: True
+
+- debug:
+ msg: Uninstalling helm...
+ when: result.stdout != ""
+
+- debug:
+ msg: Ignore Uninstall Log ,Helm not installed
+ when: result.stdout == ""
+
+- name: "UNINSTALL: Helm Uninstall on x86_64"
command: rm -rf linux-amd64/helm
when: result is succeeded and ansible_architecture == 'x86_64'
command: rm -rf linux-amd64/helm
when: result is succeeded and ansible_architecture == 'x86_64'
-- name: Remove download helm file on x86_64
+- name: "UNINSTALL: Remove download helm file on x86_64"
command: rm ~/helm-v3.0.2-linux-amd64.tar.gz
when: result is succeeded and ansible_architecture == '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
+- name: "UNINSTALL: Helm Uninstall on aarch64"
command: rm -rf linux-arm64/helm
ignore_errors: yes
no_log: True
when: result is succeeded and ansible_architecture == 'aarch64'
command: rm -rf linux-arm64/helm
ignore_errors: yes
no_log: True
when: result is succeeded and ansible_architecture == 'aarch64'
-- name: Remove download helm file on aarch64
+- name: "UNINSTALL: Remove download helm file on aarch64"
command: rm helm-v3.0.2-linux-arm64.tar.gz
ignore_errors: yes
no_log: True
when: result is succeeded and ansible_architecture == 'aarch64'
command: rm helm-v3.0.2-linux-arm64.tar.gz
ignore_errors: yes
no_log: True
when: result is succeeded and ansible_architecture == 'aarch64'
-- name: Remove helm from bin
+- name: "UNINSTALL: Remove helm from bin"
command: rm /usr/local/bin/helm
ignore_errors: yes
no_log: True
command: rm /usr/local/bin/helm
ignore_errors: yes
no_log: True
- debug: var=ansible_host
- debug: var=ansible_host
-- name: Disabling firewall for successfull k3s installation on CentOs
+- name: "INSTALL: Disabling firewall for successfull k3s installation on CentOs"
shell:
cmd: systemctl stop firewalld
when: ansible_facts['distribution'] == "CentOS" and result is failed
shell:
cmd: systemctl stop firewalld
when: ansible_facts['distribution'] == "CentOS" and result is failed
-- name: install container-selinux
+- name: "INSTALL: install container-selinux"
shell:
cmd: yum install -y container-selinux selinux-policy-base
when: ansible_facts['distribution'] == "CentOS" and result is failed
ignore_errors: true
shell:
cmd: yum install -y container-selinux selinux-policy-base
when: ansible_facts['distribution'] == "CentOS" and result is failed
ignore_errors: true
-- name: install k3s-selinux-0.1.1-rc1.el7.noarch.rpm
+- name: "INSTALL: install k3s-selinux-0.1.1-rc1.el7.noarch.rpm"
shell:
cmd: rpm -i https://rpm.rancher.io/k3s-selinux-0.1.1-rc1.el7.noarch.rpm
when: ansible_facts['distribution'] == "CentOS" and result is failed
ignore_errors: true
shell:
cmd: rpm -i https://rpm.rancher.io/k3s-selinux-0.1.1-rc1.el7.noarch.rpm
when: ansible_facts['distribution'] == "CentOS" and result is failed
ignore_errors: true
-- name: get interface name
+- name: "INSTALL: get interface name"
shell:
cmd: ip a |grep {{ ansible_host }} |awk '{print $NF}'
register: ifName
when: result is failed
# yamllint disable rule:line-length
shell:
cmd: ip a |grep {{ ansible_host }} |awk '{print $NF}'
register: ifName
when: result is failed
# yamllint disable rule:line-length
+- name: "INSTALL: install k3s"
shell:
cmd: curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--node-ip={{ ansible_host }} --node-external-ip={{ ansible_host }} --bind-address={{ ansible_host }} --flannel-iface=eth0 --docker --no-deploy=servicelb --no-deploy=traefik --write-kubeconfig-mode 644 --kube-apiserver-arg="service-node-port-range=30000-36000"" sh -
when: result is failed
# yamllint disable rule:line-length
shell:
cmd: curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--node-ip={{ ansible_host }} --node-external-ip={{ ansible_host }} --bind-address={{ ansible_host }} --flannel-iface=eth0 --docker --no-deploy=servicelb --no-deploy=traefik --write-kubeconfig-mode 644 --kube-apiserver-arg="service-node-port-range=30000-36000"" sh -
when: result is failed
# yamllint disable rule:line-length
+#- name: "INSTALL: install k3s"
# shell:
# cmd: curl -sfL https://get.k3s.io | sh -
# when: result is failed
# shell:
# cmd: curl -sfL https://get.k3s.io | sh -
# when: result is failed
-- name: create .kube dir
+- name: "INSTALL: create .kube dir"
shell:
cmd: mkdir -p $HOME/.kube/
when: result is failed
shell:
cmd: mkdir -p $HOME/.kube/
when: result is failed
+- name: "INSTALL: copy kubeconfig"
shell:
cmd: cp /etc/rancher/k3s/k3s.yaml $HOME/.kube/config
when: result is failed
shell:
cmd: cp /etc/rancher/k3s/k3s.yaml $HOME/.kube/config
when: result is failed
---
- include: "install.yml"
---
- include: "install.yml"
when: operation == 'install'
- include: "uninstall.yml"
when: operation == 'install'
- include: "uninstall.yml"
when: operation == 'uninstall'
when: operation == 'uninstall'
# limitations under the License.
---
# limitations under the License.
---
+- name: check whether k3s is already installed
+ shell:
+ cmd: which k3s
+ register: result
+ ignore_errors: yes
+ no_log: True
+
+- debug:
+ msg: Uninstalling k3s...
+ when: result.stdout != ""
+
+- debug:
+ msg: "UNINSTALL: Ignore Uninstall Log , K3s not installed"
+ when: result.stdout == ""
+
+- name: "UNINSTALL: kill k3s"
shell:
cmd: k3s-killall.sh
when: result is succeeded
shell:
cmd: k3s-killall.sh
when: result is succeeded
+- name: "UNINSTALL: uninstall k3s"
shell:
cmd: k3s-uninstall.sh
when: result is succeeded
shell:
cmd: k3s-uninstall.sh
when: result is succeeded
---
# tasks file for k8s
- include: "install.yml"
---
# tasks file for k8s
- include: "install.yml"
when: operation == 'install'
#- include: "uninstall.yml"
when: operation == 'install'
#- include: "uninstall.yml"
# yamllint disable rule:line-length
when: result.stdout == ""
# yamllint disable rule:line-length
when: result.stdout == ""
-- name: Install prometheus on x86_64
+- name: "INSTALL: Install prometheus on x86_64"
shell:
cmd: helm install mep-prometheus stable/prometheus --version v9.3.1
when: result is failed and ansible_architecture == 'x86_64'
shell:
cmd: helm install mep-prometheus stable/prometheus --version v9.3.1
when: result is failed and ansible_architecture == 'x86_64'
-- name: copy values.yaml to host
+- name: "INSTALL: copy values.yaml to host"
copy:
src: values.yaml
dest: /tmp/prometheus/
when: result is failed and ansible_architecture == 'aarch64'
copy:
src: values.yaml
dest: /tmp/prometheus/
when: result is failed and ansible_architecture == 'aarch64'
-- name: Install prometheus on aarch64
+- name: "INSTALL: Install prometheus on aarch64"
shell:
cmd: 'helm install mep-prometheus
stable/prometheus -f /tmp/prometheus/values.yaml --version v9.3.1'
shell:
cmd: 'helm install mep-prometheus
stable/prometheus -f /tmp/prometheus/values.yaml --version v9.3.1'
---
- include: "install.yml"
---
- include: "install.yml"
when: operation == 'install'
when: operation == 'install'
-- include: "uninstall.yml"
- when: operation == 'uninstall'
+ #- include: "uninstall.yml"
+ #static: false
+ #when: operation == 'uninstall'
# yamllint disable rule:line-length
when: result.stdout == ""
# yamllint disable rule:line-length
when: result.stdout == ""
-- name: copy common folder to host for rabbitmg installation
+- name: "INSTALL: copy common folder to host for rabbitmg installation"
copy:
src: common
dest: /tmp/rabbitmq/
when: result is failed
copy:
src: common
dest: /tmp/rabbitmq/
when: result is failed
-- name: Install common for rabbitmg installation
+- name: "INSTALL: Install common for rabbitmg installation"
shell:
cmd: kubectl apply -f /tmp/rabbitmq/common
when: result is failed
shell:
cmd: kubectl apply -f /tmp/rabbitmq/common
when: result is failed
-- name: copy statefulset_x86.yaml to host for rabbitmg installation
+- name: "INSTALL: copy statefulset_x86.yaml to host for rabbitmg installation"
copy:
src: statefulset_x86.yaml
dest: /tmp/rabbitmq/
when: result is failed and ansible_architecture == 'x86_64'
copy:
src: statefulset_x86.yaml
dest: /tmp/rabbitmq/
when: result is failed and ansible_architecture == 'x86_64'
-- name: Install rabbitmq on x86_64
+- name: "INSTALL: Install rabbitmq on x86_64"
shell:
cmd: kubectl apply -f /tmp/rabbitmq/statefulset_x86.yaml
when: result is failed and ansible_architecture == 'x86_64'
shell:
cmd: kubectl apply -f /tmp/rabbitmq/statefulset_x86.yaml
when: result is failed and ansible_architecture == 'x86_64'
-- name: copy statefulset_arm.yaml to host for rabbitmg installation
+- name: "INSTALL: copy statefulset_arm.yaml to host for rabbitmg installation"
copy:
src: statefulset_arm.yaml
dest: /tmp/rabbitmq/
when: result is failed and ansible_architecture == 'aarch64'
copy:
src: statefulset_arm.yaml
dest: /tmp/rabbitmq/
when: result is failed and ansible_architecture == 'aarch64'
-- name: Install rabbitmq on aarch64
+- name: "INSTALL: Install rabbitmq on aarch64"
shell:
cmd: kubectl apply -f /tmp/rabbitmq/statefulset_arm.yaml
when: result is failed and ansible_architecture == 'aarch64'
shell:
cmd: kubectl apply -f /tmp/rabbitmq/statefulset_arm.yaml
when: result is failed and ansible_architecture == 'aarch64'
---
- include: "install.yml"
---
- include: "install.yml"
when: operation == 'install'
when: operation == 'install'
-- include: "uninstall.yml"
- when: operation == 'uninstall'
+ #- include: "uninstall.yml"
+ #static: false
+ #when: operation == 'uninstall'