96 lines
2.8 KiB
YAML
96 lines
2.8 KiB
YAML
# ansible-playbook -i my_hosts.yaml deploy_argo.yml --ask-pass --ask-become-pass
|
||
|
||
# Need to think about which serviceaccount will be used to launch the workflow, by default
|
||
# uses argo:default but it doesn't have enough rights, need to use argo:argo
|
||
# like '$ argo submit -f .... --serviceaccount=argo'
|
||
|
||
|
||
- name: Installation de Argo
|
||
hosts: all
|
||
user: "{{ user_prompt }}"
|
||
vars:
|
||
ARGO_VERSION: "3.5.2"
|
||
environment:
|
||
KUBECONFIG: /home/{{ user_prompt }}/.kube/config
|
||
|
||
tasks:
|
||
- name: Create argo namespace
|
||
kubernetes.core.k8s:
|
||
state: present
|
||
definition:
|
||
apiVersion: v1
|
||
kind: Namespace
|
||
metadata:
|
||
labels:
|
||
kubernetes.io/metadata.name: argo
|
||
name: argo
|
||
|
||
- name: Verifier si argo est déjà entrain de tourner
|
||
ansible.builtin.shell:
|
||
cmd: |
|
||
kubectl get -n argo pods | grep -q argo-server
|
||
register: argo_server_pod
|
||
failed_when: argo_server_pod.rc not in [ 0, 1 ]
|
||
|
||
- name: Installing argo services
|
||
ansible.builtin.shell:
|
||
cmd: |
|
||
kubectl apply -n argo -f https://github.com/argoproj/argo-workflows/releases/download/v{{ ARGO_VERSION }}/install.yaml
|
||
when: argo_server_pod.rc == 1
|
||
|
||
|
||
- name: Vérifier l'état du pod argo-server
|
||
ansible.builtin.shell:
|
||
cmd: |
|
||
argo_server_name=$(kubectl get -n argo pods | grep argo-server | cut -d ' ' -f 1)
|
||
kubectl get -n argo pods $argo_server_name --output=jsonpath='{.status.phase}'
|
||
register: pod_status
|
||
retries: 30
|
||
delay: 10
|
||
until: pod_status.stdout == "Running"
|
||
|
||
- name: Patch first connection bug
|
||
ansible.builtin.shell: |
|
||
kubectl patch deployment \
|
||
argo-server \
|
||
--namespace argo \
|
||
--type='json' \
|
||
-p='[{"op": "replace", "path": "/spec/template/spec/containers/0/args", "value": [
|
||
"server",
|
||
"--auth-mode=server"
|
||
]}]'
|
||
|
||
- name: Copying the configuration file to new host
|
||
copy: src=argo-service.yml dest=$HOME mode=0755
|
||
|
||
- name: Applying the conf file to make the service a NodePort typ
|
||
ansible.builtin.shell:
|
||
cmd: |
|
||
kubectl apply -f argo-service.yml
|
||
|
||
- name: download argo CLI
|
||
become: true
|
||
ansible.builtin.uri:
|
||
url: " https://github.com/argoproj/argo-workflows/releases/download/v{{ ARGO_VERSION }}/argo-linux-amd64.gz"
|
||
method: GET
|
||
dest: /var
|
||
status_code: 200
|
||
headers:
|
||
Content-Type: "application/json"
|
||
|
||
- name: Install argo CLI
|
||
become: true
|
||
ansible.builtin.shell:
|
||
cmd: |
|
||
gunzip argo-linux-amd64.gz
|
||
chmod +x argo-linux-amd64
|
||
mv ./argo-linux-amd64 /usr/local/bin/argo
|
||
args:
|
||
chdir: /var
|
||
|
||
- name: Enable argo CLI autocomplete
|
||
ansible.builtin.shell:
|
||
cmd: |
|
||
grep 'argo completion bash' $HOME/.bashrc || echo 'source <(argo completion bash)' >> $HOME/.bashrc
|
||
|