Update ansible code
Some checks reported errors
continuous-integration/drone/push Build encountered an error

This commit is contained in:
Adrien Reslinger 2022-08-16 17:09:58 +02:00
parent 156561e633
commit 18e86f8687
Signed by: adrien
GPG key ID: DA7B27055C66D6DE
5 changed files with 120 additions and 118 deletions

View file

@ -1,10 +1,10 @@
---
- name: restart crowdsec
systemd:
ansible.builtin.systemd:
name: crowdsec
state: restarted
- name: restart crowdsec-firewall-bouncer
systemd:
ansible.builtin.systemd:
name: crowdsec-firewall-bouncer
state: restarted

View file

@ -10,7 +10,9 @@ galaxy_info:
version:
- 7
- 8
- 9
- name: RedHat
version:
- 7
- 8
- 9

View file

@ -14,14 +14,14 @@
when:
- ansible_os_family == "RedHat"
#- name: Register new bouncer
# command: cscli bouncers add {{ inventory_hostname }} -o raw
# - name: Register new bouncer
# ansible.builtin.command: cscli bouncers add {{ inventory_hostname }} -o raw
# register: _csbouncer
# delegate_to: "{{ crowdsec_delegate_server_hostname }}"
# changed_when: _csbouncer.stderr is not search("already exists")
#
#- name: Deploy bouncer config
# lineinfile:
# - name: Deploy bouncer config
# ansible.builtin.lineinfile:
# regex: "{{ item.regex }}"
# line: "{{ item.line }}"
# dest: /etc/crowdsec/bouncers/crowdsec-firewall-bouncer.yaml

View file

@ -2,7 +2,7 @@
- name: Crowdsec setup
block:
# - name: Include vars for {{ ansible_os_family }}
# include_vars: "{{ ansible_os_family }}_{{ ansible_distribution_major_version }}.yml"
# ansible.builtin.include_vars: "{{ ansible_os_family }}_{{ ansible_distribution_major_version }}.yml"
- name: Debian family configuration
block:
@ -12,7 +12,7 @@
- apt-transport-https
- gnupg
state: present
update_cache: yes
update_cache: true
- name: add crowdsec apt key
ansible.builtin.apt_key:
@ -23,7 +23,7 @@
ansible.builtin.apt_repository:
repo: 'deb https://packagecloud.io/crowdsec/crowdsec/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release|lower }} main'
state: present
update_cache: yes
update_cache: true
when:
- ansible_os_family == "Debian"
@ -61,10 +61,10 @@
name:
- crowdsec
state: present
update_cache: yes
update_cache: true
- name: Deploy main config
template:
ansible.builtin.template:
src: etc/crowdsec/config.yaml.j2
dest: /etc/crowdsec/config.yaml
owner: root
@ -73,7 +73,7 @@
notify: restart crowdsec
- name: Deploy whitelist
template:
ansible.builtin.template:
src: etc/crowdsec/parsers/s02-enrich/mywhitelist.yaml.j2
dest: /etc/crowdsec/parsers/s02-enrich/mywhitelist.yaml
owner: root
@ -83,15 +83,15 @@
notify: restart crowdsec
- name: Flush handlers to apply config
meta: flush_handlers
ansible.builtin.meta: flush_handlers
# - name: Register agent(s)
# include_tasks: register_agent.yml
# ansible.builtin.include_tasks: register_agent.yml
# when:
# - crowdsec_delegate_server_hostname != inventory_hostname
#
- name: Register distributed bouncers(s)
include_tasks: add_bouncer.yml
ansible.builtin.include_tasks: add_bouncer.yml
when:
- crowdsec_bouncer.enabled

View file

@ -1,17 +1,17 @@
---
- name: Check if agent is already registered
shell: cscli machines list -o raw | grep {{ inventory_hostname }} | grep true || echo "Not found"
ansible.builtin.shell: cscli machines list -o raw | grep {{ inventory_hostname }} | grep true || echo "Not found"
register: _csmachines
delegate_to: "{{ crowdsec_delegate_server_hostname }}"
changed_when: false
- block:
- name: Register agent to server
command: cscli lapi register -u {{ crowdsec_lapi_url }} --machine {{ inventory_hostname }}
ansible.builtin.command: cscli lapi register -u {{ crowdsec_lapi_url }} --machine {{ inventory_hostname }}
notify: restart crowdsec
- name: Validate agent on server
command: cscli machines validate {{ inventory_hostname }}
ansible.builtin.command: cscli machines validate {{ inventory_hostname }}
delegate_to: "{{ crowdsec_delegate_server_hostname }}"
when:
- _csmachines.rc == 0