2021-11-07 10:22:51 +00:00
|
|
|
---
|
|
|
|
- name: Kubernetes Apps | Install yq
|
|
|
|
become: yes
|
|
|
|
get_url:
|
|
|
|
url: "https://github.com/mikefarah/yq/releases/download/v4.11.2/yq_linux_amd64"
|
|
|
|
dest: "{{ bin_dir }}/yq"
|
|
|
|
mode: '0755'
|
|
|
|
|
|
|
|
- name: Kubernetes Apps | Set ArgoCD template list
|
|
|
|
set_fact:
|
|
|
|
argocd_templates:
|
|
|
|
- name: namespace
|
|
|
|
file: argocd-namespace.yml
|
|
|
|
- name: install
|
|
|
|
file: argocd-install.yml
|
|
|
|
namespace: "{{ argocd_namespace }}"
|
2022-01-11 08:45:16 +00:00
|
|
|
url: "https://raw.githubusercontent.com/argoproj/argo-cd/{{ argocd_version }}/manifests/install.yaml"
|
2021-11-07 10:22:51 +00:00
|
|
|
when:
|
|
|
|
- "inventory_hostname == groups['kube_control_plane'][0]"
|
|
|
|
|
|
|
|
- name: Kubernetes Apps | Download ArgoCD remote manifests
|
|
|
|
become: yes
|
|
|
|
get_url:
|
|
|
|
url: "{{ item.url }}"
|
|
|
|
dest: "{{ kube_config_dir }}/{{ item.file }}"
|
2022-01-09 09:51:12 +00:00
|
|
|
mode: 0644
|
2021-11-07 10:22:51 +00:00
|
|
|
with_items: "{{ argocd_templates | selectattr('url', 'defined') | list }}"
|
|
|
|
loop_control:
|
|
|
|
label: "{{ item.file }}"
|
|
|
|
when:
|
|
|
|
- "inventory_hostname == groups['kube_control_plane'][0]"
|
|
|
|
|
|
|
|
- name: Kubernetes Apps | Set ArgoCD namespace for remote manifests
|
|
|
|
become: yes
|
|
|
|
command: |
|
2022-01-11 08:45:16 +00:00
|
|
|
{{ bin_dir }}/yq eval-all -i '.metadata.namespace="{{ argocd_namespace }}"' {{ kube_config_dir }}/{{ item.file }}
|
2021-11-07 10:22:51 +00:00
|
|
|
with_items: "{{ argocd_templates | selectattr('url', 'defined') | list }}"
|
|
|
|
loop_control:
|
|
|
|
label: "{{ item.file }}"
|
|
|
|
when:
|
|
|
|
- "inventory_hostname == groups['kube_control_plane'][0]"
|
|
|
|
|
|
|
|
- name: Kubernetes Apps | Create ArgoCD manifests from templates
|
|
|
|
become: yes
|
|
|
|
template:
|
|
|
|
src: "{{ item.file }}.j2"
|
|
|
|
dest: "{{ kube_config_dir }}/{{ item.file }}"
|
2022-01-09 09:51:12 +00:00
|
|
|
mode: 0644
|
2021-11-07 10:22:51 +00:00
|
|
|
with_items: "{{ argocd_templates | selectattr('url', 'undefined') | list }}"
|
|
|
|
loop_control:
|
|
|
|
label: "{{ item.file }}"
|
|
|
|
when:
|
|
|
|
- "inventory_hostname == groups['kube_control_plane'][0]"
|
|
|
|
|
|
|
|
- name: Kubernetes Apps | Install ArgoCD
|
|
|
|
become: yes
|
|
|
|
kube:
|
|
|
|
name: ArgoCD
|
|
|
|
kubectl: "{{ bin_dir }}/kubectl"
|
|
|
|
filename: "{{ kube_config_dir }}/{{ item.file }}"
|
|
|
|
state: latest
|
|
|
|
with_items: "{{ argocd_templates }}"
|
|
|
|
when:
|
|
|
|
- "inventory_hostname == groups['kube_control_plane'][0]"
|
|
|
|
|
|
|
|
# https://github.com/argoproj/argo-cd/blob/master/docs/faq.md#i-forgot-the-admin-password-how-do-i-reset-it
|
|
|
|
- name: Kubernetes Apps | Set ArgoCD custom admin password
|
|
|
|
become: yes
|
|
|
|
shell: |
|
2022-01-11 08:45:16 +00:00
|
|
|
{{ bin_dir }}/kubectl --kubeconfig /etc/kubernetes/admin.conf -n {{ argocd_namespace }} patch secret argocd-secret -p \
|
2021-11-07 10:22:51 +00:00
|
|
|
'{
|
|
|
|
"stringData": {
|
2022-01-11 08:45:16 +00:00
|
|
|
"admin.password": "{{ argocd_admin_password | password_hash('bcrypt') }}",
|
2021-11-07 10:22:51 +00:00
|
|
|
"admin.passwordMtime": "'$(date +%FT%T%Z)'"
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
when:
|
|
|
|
- argocd_admin_password is defined
|
|
|
|
- "inventory_hostname == groups['kube_control_plane'][0]"
|