Compare commits
2
Commits
main
...
188183667a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
188183667a | ||
|
|
2b293e9835 |
@@ -12,6 +12,10 @@ crowdsec:
|
||||
scenarios: {}
|
||||
# path below /etc/crowdsec -> content, for local parsers and scenarios.
|
||||
local_files: {}
|
||||
# name -> installed hub scenario removed from the agent (null drops one); needed where a local scenario replaces it.
|
||||
disabled_scenarios: {}
|
||||
# name -> path below /etc/crowdsec of a retired local file, removed when present (null drops one).
|
||||
absent_files: {}
|
||||
# name -> CIDR (single addresses as /32 or /128) never acted upon. Joined by
|
||||
# the public_ips (same format) of every inventory host, then whitelisted by
|
||||
# this agent and, when lapi_allowlist is set, allowlisted on the LAPI.
|
||||
|
||||
@@ -171,6 +171,24 @@
|
||||
when: crowdsec_missing | length > 0
|
||||
notify: Restart crowdsec
|
||||
|
||||
# Read again: the collections installed above bring their scenarios along.
|
||||
- name: List the installed hub scenarios
|
||||
ansible.builtin.command: cscli hub list -o json
|
||||
register: crowdsec_scenarios_json
|
||||
changed_when: false
|
||||
failed_when: crowdsec_scenarios_json.rc != 0 and not ansible_check_mode
|
||||
check_mode: false
|
||||
|
||||
# --force also removes items that belong to an installed collection. A plain "cscli hub upgrade" keeps them removed;
|
||||
# "cscli hub upgrade --force" would bring them back.
|
||||
- name: Remove the hub scenarios replaced by local ones
|
||||
ansible.builtin.command: "cscli scenarios remove {{ item.value }} --force"
|
||||
loop: "{{ crowdsec.disabled_scenarios | dict2items | rejectattr('value', 'none') }}"
|
||||
loop_control:
|
||||
label: "{{ item.value }}"
|
||||
when: item.value in ((crowdsec_scenarios_json.stdout | default('{}', true) | from_json).scenarios | default([], true) | map(attribute='name'))
|
||||
notify: Restart crowdsec
|
||||
|
||||
- name: Install the local parsers and scenarios
|
||||
ansible.builtin.copy:
|
||||
dest: "/etc/crowdsec/{{ item.key }}"
|
||||
@@ -181,6 +199,15 @@
|
||||
label: "{{ item.key }}"
|
||||
notify: Restart crowdsec
|
||||
|
||||
- name: Remove retired local files
|
||||
ansible.builtin.file:
|
||||
path: "/etc/crowdsec/{{ item.value }}"
|
||||
state: absent
|
||||
loop: "{{ crowdsec.absent_files | dict2items | rejectattr('value', 'none') }}"
|
||||
loop_control:
|
||||
label: "{{ item.value }}"
|
||||
notify: Restart crowdsec
|
||||
|
||||
- name: Enable the agent and the bouncer
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ item }}"
|
||||
|
||||
@@ -91,3 +91,10 @@
|
||||
when: docker_binary.stat.exists
|
||||
tags: docker_prune
|
||||
|
||||
- name: Remove hand-written docker system prune lines from root crontab
|
||||
ansible.builtin.lineinfile:
|
||||
path: /var/spool/cron/crontabs/root
|
||||
regexp: '^\S+ \S+ \S+ \S+ \S+ docker system prune -af'
|
||||
state: absent
|
||||
tags: docker_prune
|
||||
|
||||
|
||||
Reference in New Issue
Block a user