135 lines
3.7 KiB
YAML
135 lines
3.7 KiB
YAML
- name: Deploy MinIO
|
|
hosts: all:!localhost
|
|
user: "{{ user_prompt }}"
|
|
vars:
|
|
host_name: "{{ host_name_prompt }}"
|
|
memory_req: "2Gi"
|
|
storage_req: "20Gi"
|
|
environment:
|
|
KUBECONFIG: /home/{{ user_prompt }}/.kube/config
|
|
|
|
tasks:
|
|
- name: Install yaml library for python
|
|
become: true
|
|
ansible.builtin.package:
|
|
name: ansible
|
|
state: present
|
|
|
|
- name: Check if Helm does exist
|
|
ansible.builtin.command:
|
|
cmd: which helm
|
|
register: result_which
|
|
failed_when: result_which.rc not in [ 0, 1 ]
|
|
|
|
- name: Install helm
|
|
when: result_which.rc == 1
|
|
block:
|
|
- name: Download helm from source
|
|
ansible.builtin.get_url:
|
|
url: https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
|
|
dest: ./get_helm.sh
|
|
mode: 0700
|
|
|
|
- name: Launch helm install script
|
|
become: true
|
|
ansible.builtin.shell:
|
|
cmd: |
|
|
./get_helm.sh
|
|
|
|
- name: Test if MinIO is already installed
|
|
ansible.builtin.shell:
|
|
cmd : helm repo list | grep 'https://charts.min.io/'
|
|
register: minio_charts
|
|
failed_when: minio_charts.rc not in [0,1]
|
|
|
|
- name: Add helm repo MinIO
|
|
kubernetes.core.helm_repository:
|
|
repo_url: https://charts.min.io/
|
|
repo_state: present
|
|
repo_name: minio
|
|
when: minio_charts.rc == 1
|
|
|
|
- name: Update helm repo
|
|
ansible.builtin.command:
|
|
cmd : |
|
|
helm repo update
|
|
when: minio_charts.rc == 1
|
|
|
|
- name: Test is argo-artifact is already running
|
|
ansible.builtin.shell:
|
|
helm list | grep -w "argo-artifacts" | wc -l
|
|
register: argo_artifact_deployed
|
|
failed_when: argo_artifact_deployed.rc not in [ 0, 1 ]
|
|
|
|
- name: Initialize MinIO
|
|
when: argo_artifact_deployed.stdout == "0"
|
|
kubernetes.core.helm:
|
|
name: argo-artifacts
|
|
chart_ref: minio/minio
|
|
release_namespace: default
|
|
values:
|
|
service:
|
|
type: LoadBalancer
|
|
fullnameOverride: argo-artifacts
|
|
resources:
|
|
requests:
|
|
memory: "{{ memory_req }}"
|
|
replicas: 2
|
|
volumeClaimTemplates:
|
|
spec:
|
|
resources:
|
|
requests: "{{ storage_req }}"
|
|
consoleService:
|
|
type: LoadBalancer
|
|
# port: 9001
|
|
state: present
|
|
|
|
- name: Retrieve root user
|
|
ansible.builtin.shell:
|
|
cmd: |
|
|
kubectl get secret argo-artifacts --namespace default -o jsonpath="{.data.rootUser}"
|
|
register : user_encoded
|
|
|
|
- name: Decode root user
|
|
ansible.builtin.shell:
|
|
cmd: |
|
|
echo {{ user_encoded.stdout }} | base64 -d
|
|
register: user
|
|
|
|
- name: Retrieve root password
|
|
ansible.builtin.shell:
|
|
cmd: |
|
|
kubectl get secret argo-artifacts --namespace default -o jsonpath="{.data.rootPassword}"
|
|
register : password_encoded
|
|
|
|
|
|
- name: Decode root password
|
|
ansible.builtin.shell:
|
|
cmd: |
|
|
echo {{ password_encoded.stdout }} | base64 -d
|
|
register: password
|
|
|
|
- name: Retrieve console ip
|
|
ansible.builtin.shell:
|
|
cmd: |
|
|
kubectl get service argo-artifacts-console -o jsonpath="{.status.loadBalancer.ingress[0].ip}"
|
|
register : ip_console
|
|
|
|
- name: Retrieve API internal ip
|
|
ansible.builtin.shell:
|
|
cmd: |
|
|
kubectl get service argo-artifacts -o jsonpath="{.spec.clusterIP}"
|
|
register : ip_api
|
|
|
|
- name: Display info
|
|
debug:
|
|
msg :
|
|
"
|
|
MinIO UI console info
|
|
external IP GUI : {{ ip_console.stdout }}
|
|
user : {{ user.stdout }}
|
|
password : {{ password.stdout }}
|
|
|
|
IP API : {{ ip_api.stdout }}
|
|
"
|