diff --git a/crowdsec/defaults/main.yml b/crowdsec/defaults/main.yml index 30212ae..82d7278 100644 --- a/crowdsec/defaults/main.yml +++ b/crowdsec/defaults/main.yml @@ -4,6 +4,8 @@ crowdsec: lapi_url: "" registration_token: "" bouncer_api_key: "" + # Machine name at the LAPI; empty is the short hostname. + machine_name: "" # name -> hub collection, merged across group_vars/host_vars (null drops one). collections: {} # name -> hub scenario outside the collections. diff --git a/crowdsec/tasks/main.yml b/crowdsec/tasks/main.yml index 623587a..3e834b2 100644 --- a/crowdsec/tasks/main.yml +++ b/crowdsec/tasks/main.yml @@ -148,7 +148,7 @@ - name: Register the agent at the LAPI ansible.builtin.command: >- cscli lapi register --url {{ crowdsec.lapi_url }} - --token {{ crowdsec.registration_token }} --machine {{ ansible_hostname }} + --token {{ crowdsec.registration_token }} --machine {{ crowdsec.machine_name | default(ansible_hostname, true) }} when: crowdsec_registered.rc != 0 no_log: true notify: Restart crowdsec