|
|
|
@ -42,3 +42,37 @@ |
|
|
|
|
when: crowdsec_lapi_registration.rc == 0 |
|
|
|
|
|
|
|
|
|
tags: crowdsec |
|
|
|
|
|
|
|
|
|
- when: |
|
|
|
|
- crowdsec_capi_enabled |
|
|
|
|
- crowdsec_capi_user is not defined or crowdsec_capi_pass is not defined |
|
|
|
|
- not crowdsec_capi_user_file.stat.exists or not crowdsec_capi_pass_file.stat.exists |
|
|
|
|
block: |
|
|
|
|
- name: Register on the central API |
|
|
|
|
command: cscli capi register -o raw -f /dev/stdout |
|
|
|
|
register: crowdsec_capi_credentials |
|
|
|
|
- set_fact: crowdsec_capi_credentials_yaml={{ crowdsec_capi_credentials.stdout | from_yaml }} |
|
|
|
|
- copy: content={{ crowdsec_capi_credentials_yaml.login }} dest=/etc/crowdsec/meta/capi_user mode=600 |
|
|
|
|
- copy: content={{ crowdsec_capi_credentials_yaml.password }} dest=/etc/crowdsec/meta/capi_pass mode=600 |
|
|
|
|
- set_fact: crowdsec_capi_user={{ crowdsec_capi_credentials_yaml.login }} |
|
|
|
|
- set_fact: crowdsec_capi_pass={{ crowdsec_capi_credentials_yaml.password }} |
|
|
|
|
tags: crowdsec |
|
|
|
|
|
|
|
|
|
- when: |
|
|
|
|
- crowdsec_capi_enabled |
|
|
|
|
- crowdsec_capi_user is not defined or crowdsec_capi_pass is not defined |
|
|
|
|
- crowdsec_capi_user_file.stat.exists |
|
|
|
|
- crowdsec_capi_pass_file.stat.exists |
|
|
|
|
block: |
|
|
|
|
- slurp: src=/etc/crowdsec/meta/capi_user |
|
|
|
|
register: crowdsec_capi_user_meta |
|
|
|
|
- set_fact: crowdsec_capi_user={{ crowdsec_capi_user_meta.content | b64decode | trim }} |
|
|
|
|
- slurp: src=/etc/crowdsec/meta/capi_pass |
|
|
|
|
register: crowdsec_capi_pass_meta |
|
|
|
|
- set_fact: crowdsec_capi_pass={{ crowdsec_capi_pass_meta.content | b64decode | trim }} |
|
|
|
|
tags: crowdsec |
|
|
|
|
|
|
|
|
|
- name: Deploy online credentials config |
|
|
|
|
template: src=online_api_credentials.yaml.j2 dest=/etc/crowdsec/online_api_credentials.yaml mode=600 |
|
|
|
|
notify: reload crowdsec |
|
|
|
|
tags: crowdsec |
|
|
|
|