You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.4 KiB
44 lines
1.4 KiB
---
|
|
|
|
- name: Deploy configuration
|
|
template: src={{ item }}.j2 dest=/etc/crowdsec/{{ item }}
|
|
loop:
|
|
- config.yaml
|
|
- acquis.yaml
|
|
- simulation.yaml
|
|
- profile.yaml
|
|
notify: reload crowdsec
|
|
tags: crowdsec
|
|
|
|
# Create the database
|
|
- import_tasks: ../includes/webapps_create_mysql_db.yml
|
|
vars:
|
|
- db_name: "{{ crowdsec_db_name }}"
|
|
- db_user: "{{ crowdsec_db_user }}"
|
|
- db_server: "{{ crowdsec_db_server }}"
|
|
- db_pass: "{{ crowdsec_db_pass }}"
|
|
tags: crowdsec
|
|
|
|
- name: Declare on the local API
|
|
command: cscli machines add {{ crowdsec_lapi_user }} --auto
|
|
register: crowdsec_lapi_add
|
|
when: inventory_hostname == crowdsec_lapi_server
|
|
changed_when: crowdsec_lapi_add.rc == 0
|
|
failed_when: crowdsec_lapi_add.rc not in [0,1]
|
|
tags: crowdsec
|
|
|
|
- when: inventory_hostname != crowdsec_lapi_server
|
|
block:
|
|
- name: Register against the Local API
|
|
command: cscli lapi register --machine {{ crowdsec_lapi_user }} --url {{ crowdsec_lapi_url }}
|
|
register: crowdsec_lapi_registration
|
|
changed_when: crowdsec_lapi_registration.rc == 0
|
|
failed_when: crowdsec_lapi_registration.rc not in [0,1] # RC 1 when machine already exists
|
|
notify: reload crowdsec
|
|
|
|
- name: Validate crowdsec registration on the Local API server
|
|
command: cscli machines validate {{ crowdsec_lapi_user }}
|
|
delegate_to: "{{ crowdsec_lapi_server }}"
|
|
when: crowdsec_lapi_registration.rc == 0
|
|
|
|
tags: crowdsec
|
|
|