Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: 🎨 remove default helm values and split proxy #91

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions install.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: Installation du socle DSO
hosts: localhost
gather_facts: false
Expand Down Expand Up @@ -84,7 +85,8 @@
- console-dso

post_tasks:
- debug:
- name: Post-Install Disclaimer
ansible.builtin.debug:
msg: "{{ dsc | get_debug_messages }}"
tags:
- always
- always
17 changes: 14 additions & 3 deletions roles/argocd/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: Get argo client secret
kubernetes.core.k8s_info:
kind: Secret
Expand All @@ -12,7 +13,7 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
creationTimestamp: null
creationTimestamp:
name: system:openshift:scc:privileged
roleRef:
apiGroup: rbac.authorization.k8s.io
Expand All @@ -34,13 +35,23 @@
name: bitnami
repo_url: https://charts.bitnami.com/bitnami

- name: Set extra env vars
- name: Set argo_values
ansible.builtin.set_fact:
argo_values: "{{ lookup('template', 'values.yaml.j2') | from_yaml }}"

- name: Merge with proxy settings
when: dsc.proxy.enabled
block:
- name: Generate proxy values
ansible.builtin.set_fact:
argo_proxy_values: "{{ lookup('template', 'proxy-values.yaml.j2') | from_yaml }}"
- name: Merge with argo proxy values
ansible.builtin.set_fact:
argo_values: "{{ argo_values | combine(argo_proxy_values, recursive=True, list_merge='append') }}"

- name: Merge with argo user values
ansible.builtin.set_fact:
argo_values: "{{ argo_values | combine(dsc.argocd['values'], recursive=True) }}"
argo_values: "{{ argo_values | combine(dsc.argocd['values'], recursive=True, list_merge='append') }}"

- name: Deploy helm
kubernetes.core.helm:
Expand Down
12 changes: 12 additions & 0 deletions roles/argocd/templates/proxy-values.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

server:
extraEnvVars: &extraEnvVars
- name: HTTP_PROXY
value: "{{ dsc.proxy.http_proxy }}"
- name: HTTPS_PROXY
value: "{{ dsc.proxy.https_proxy }}"
- name: NO_PROXY
value: "{{ dsc.proxy.no_proxy }},argo-argo-cd-repo-server"

repoServer:
extraEnvVars: *extraEnvVars
26 changes: 3 additions & 23 deletions roles/argocd/templates/values.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ securityContext: &securityContext
runAsUser: null
podSecurityContext:
fsGroup: null
# TODO variabilize openshift boolean
openshift:
enabled: true
image:
PullPolicy: IfNotPresent

config:
{% if dsc.argocd.admin.enabled %}
secret:
Expand Down Expand Up @@ -53,26 +49,10 @@ server:
kinds:
- TaskRun
- PipelineRun
extraEnvVars:
{% if dsc.proxy.enabled %}
- name: HTTP_PROXY
value: "{{ dsc.proxy.http_proxy }}"
- name: HTTPS_PROXY
value: "{{ dsc.proxy.https_proxy }}"
- name: NO_PROXY
value: "{{ dsc.proxy.no_proxy }},argo-argo-cd-repo-server"
{% endif %}
extraEnvVars: []
repoServer:
<<: *securityContext
extraEnvVars:
{% if dsc.proxy.enabled %}
- name: HTTP_PROXY
value: "{{ dsc.proxy.http_proxy }}"
- name: HTTPS_PROXY
value: "{{ dsc.proxy.https_proxy }}"
- name: NO_PROXY
value: "{{ dsc.proxy.no_proxy }}"
{% endif %}
extraEnvVars: []
extraDeploy:
- apiVersion: v1
data:
Expand Down
1 change: 1 addition & 0 deletions roles/ca/tasks/additionals_ca.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: Set empty ca fact
ansible.builtin.set_fact:
additionals_ca_pem_array: []
Expand Down
7 changes: 4 additions & 3 deletions roles/ca/tasks/exposed_ca.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: No exposed_ca
when: dsc.exposedCA.type == 'none'
ansible.builtin.set_fact:
Expand Down Expand Up @@ -37,7 +38,7 @@
- name: Get certmanager secret
kubernetes.core.k8s_info:
name: "{{ dsc.ingress.tls.ca.secretName }}"
namespace: "cert-manager"
namespace: cert-manager
kind: Secret
register: exposed_ca_resource

Expand All @@ -50,10 +51,10 @@
block:
- name: Get url
ansible.builtin.shell:
cmd: "curl {{ dsc.exposedCA.url }} -s | openssl x509"
cmd: curl {{ dsc.exposedCA.url }} -s | openssl x509
changed_when: false
register: exposed_ca_resource
tags: ["skip_ansible_lint"]
tags: [skip_ansible_lint]

- name: Extract key
ansible.builtin.set_fact:
Expand Down
5 changes: 3 additions & 2 deletions roles/ca/tasks/get-ca.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: Get CA cert
kubernetes.core.k8s_info:
namespace: default
Expand All @@ -12,7 +13,7 @@

- name: Set ca fact (secret)
ansible.builtin.set_fact:
additionals_ca_pem_array: "{{ additionals_ca_pem_array + [( ca_cert.resources[0].data[key] | b64decode )] }}"
additionals_ca_pem_array: "{{ additionals_ca_pem_array + [(ca_cert.resources[0].data[key] | b64decode)] }}"
when: kind == 'Secret' and key | length != 0

- name: Set ca fact (cm)
Expand All @@ -25,7 +26,7 @@

- name: Set ca fact (secret)
ansible.builtin.set_fact:
additionals_ca_pem_array: "{{ additionals_ca_pem_array + [( ca_cert.resources[0].data[resKey.key] | b64decode )] }}"
additionals_ca_pem_array: "{{ additionals_ca_pem_array + [(ca_cert.resources[0].data[resKey.key] | b64decode)] }}"
loop: "{{ ca_cert.resources[0].data | dict2items }}"
when: kind == 'Secret' and key | length == 0
loop_control:
Expand Down
1 change: 1 addition & 0 deletions roles/ca/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: Additionals_ca tasks
ansible.builtin.include_tasks:
file: additionals_ca.yaml
Expand Down
13 changes: 12 additions & 1 deletion roles/cert-manager/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: Add cert-manager helm repo
kubernetes.core.helm_repository:
name: jetstack
Expand All @@ -19,7 +20,17 @@

- name: Set cert-manager helm values
ansible.builtin.set_fact:
cm_values: "{{ lookup('template', 'values.yaml.j2') | from_yaml }}"
cm_values: {}

- name: Merge with proxy settings
when: dsc.proxy.enabled
block:
- name: Generate proxy values
ansible.builtin.set_fact:
cm_proxy_values: "{{ lookup('template', 'proxy-values.yaml.j2') | from_yaml }}"
- name: Merge with cm proxy values
ansible.builtin.set_fact:
cm_values: "{{ cm_values | combine(cm_proxy_values, recursive=True, list_merge='append') }}"

- name: Deploy helm
kubernetes.core.helm:
Expand Down
3 changes: 3 additions & 0 deletions roles/cert-manager/templates/proxy-values.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
http_proxy: "{{ dsc.proxy.http_proxy }}"
https_proxy: "{{ dsc.proxy.https_proxy }}"
no_proxy: "{{ dsc.proxy.no_proxy }}"
Loading