Update crowdsec deployment

This commit is contained in:
Adrien Reslinger 2023-11-26 10:48:23 +01:00
parent 0cfe2972c0
commit b045b7808a
Signed by: adrien
GPG key ID: DA7B27055C66D6DE
3 changed files with 40 additions and 4 deletions

View file

@ -26,5 +26,37 @@
# - crowdsec-agent-DaemonSet.yml.j2
# - crowdsec-agent-serviceMonitor.yml.j2
# - name: Wait until pod crowdsec-lapi is ready
# kubernetes.core.k8s_info:
# kind: Pod
# wait: yes
# label_selectors:
# - "k8s-app: crowdsec"
# - "type: lapi"
# namespace: "{{ crowdsec_namespace }}"
# context: "{{ my_context }}"
# wait_sleep: 5
# wait_timeout: 360
- name: Configure traefik bouncer access
block:
# kubectl --context bach -n crowdsec exec deploy/crowdsec-lapi -c crowdsec-lapi -- cscli bouncers list -o raw | grep '^traefik,'
- name: Test if traefik bouncer already existe
ansible.builtin.shell: kubectl --context {{ my_context }} -n {{ crowdsec_namespace }} exec deploy/crowdsec-lapi -c crowdsec-lapi -- cscli bouncers list -o raw | grep -q '^traefik,'
delegate_to: localhost
# register: traefik_bouncer_enrolled
# changed_when: false
check_mode: false
rescue:
# kubectl --context bach -n crowdsec exec deploy/crowdsec-lapi -c crowdsec-lapi -- cscli bouncers add traefik -o raw
- name: Test if traefik bouncer already existe
ansible.builtin.command: kubectl --context {{ my_context }} -n {{ crowdsec_namespace }} exec deploy/crowdsec-lapi -c crowdsec-lapi -- cscli bouncers add traefik -o raw
delegate_to: localhost
register: traefik_bouncer_token
- name: Show next command
debug:
msg: vault write exploit/clusters/{{ my_context }}/crowdsec_traefik_bouncer api_key={{ traefik_bouncer_token.stdout }}
# kubectl --context chopin -n crowdsec rollout restart deploy/crowdsec-lapi
tags:
- crowdsec