-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cee481f
commit 80efb05
Showing
6 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
argocd_enabled: false | ||
argocd_version: v2.1.0 | ||
argocd_namespace: argocd | ||
# argocd_admin_password: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--- | ||
- 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 }}" | ||
url: "https://raw.githubusercontent.com/argoproj/argo-cd/{{argocd_version}}/manifests/install.yaml" | ||
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 }}" | ||
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: | | ||
{{ bin_dir }}/yq eval-all -i '.metadata.namespace="{{argocd_namespace}}"' {{ kube_config_dir }}/{{ item.file }} | ||
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 }}" | ||
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: | | ||
{{ bin_dir }}/kubectl --kubeconfig /etc/kubernetes/admin.conf -n {{argocd_namespace}} patch secret argocd-secret -p \ | ||
'{ | ||
"stringData": { | ||
"admin.password": "{{argocd_admin_password|password_hash('bcrypt')}}", | ||
"admin.passwordMtime": "'$(date +%FT%T%Z)'" | ||
} | ||
}' | ||
when: | ||
- argocd_admin_password is defined | ||
- "inventory_hostname == groups['kube_control_plane'][0]" |
7 changes: 7 additions & 0 deletions
7
roles/kubernetes-apps/argocd/templates/argocd-namespace.yml.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: {{argocd_namespace}} | ||
labels: | ||
app: argocd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters