From 27e32b5f564787351d658fab6bf947b85cddc1ab Mon Sep 17 00:00:00 2001 From: Adrien Reslinger Date: Sat, 19 Feb 2022 12:40:09 +0100 Subject: [PATCH] Install crowdsec --- .drone.yml | 12 +++++++++ meta/main.yml | 16 ++++++++++++ tasks/main.yml | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 .drone.yml create mode 100644 meta/main.yml create mode 100644 tasks/main.yml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..833f690 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,12 @@ +--- +kind: pipeline +type: kubernetes +name: default + +steps: + - name: lint + image: quay.io/adrilinux/ansible:latest + commands: + - ansible-lint ./ +# - "find . -maxdepth 1 -name '*.yml' | sort | grep -v '.drone.yml' | xargs ansible-playbook --syntax-check --list-tasks" +# - "find . -maxdepth 1 -name '*.yml' | sort | grep -v '.drone.yml' | xargs ansible-lint" diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..5629d8b --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,16 @@ +galaxy_info: + author: Adrien Reslinger + description: Install CrowdSec + company: Personnal + min_ansible_version: 2.9 + galaxy_tags: [] + license: GPL2 + platforms: + - name: CentOS + version: + - 7 + - 8 + - name: RedHat + version: + - 7 + - 8 diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..eeef01d --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,67 @@ +--- +- name: Crowdsec setup + block: +# - name: Include vars for {{ ansible_os_family }} +# include_vars: "{{ ansible_os_family }}_{{ ansible_distribution_major_version }}.yml" + + - name: Debian family configuration + block: + - name: Install required packages + package: + name: + - apt-transport-https + - gnupg + state: present + update_cache: yes + + - name: add crowdsec apt key + apt_key: + url: https://packagecloud.io/crowdsec/crowdsec/gpgkey + state: present + + - name: add crowdsec repository + apt_repository: + repo: 'deb https://packagecloud.io/crowdsec/crowdsec/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release|lower }} main' + state: present + update_cache: yes + + when: + - ansible_os_family == "Debian" + + - name: RedHat family configuration + block: + - name: Import CrowdSec RPM key + ansible.builtin.rpm_key: + state: present + key: "{{ item }}" + with_items: + - https://packagecloud.io/crowdsec/crowdsec/gpgkey + - https://packagecloud.io/crowdsec/crowdsec/gpgkey/crowdsec-crowdsec-B78D1222C9AD2D5D.pub.gpg + - https://packagecloud.io/crowdsec/crowdsec/gpgkey/crowdsec-crowdsec-FED78314A2468CCF.pub.gpg + - name: Add Official crowdsec's repo + yum_repository: + name: crowdsec_crowdsec + description: crowdsec_crowdsec + baseurl: https://packagecloud.io/crowdsec/crowdsec/el/$releasever/$basearch + enabled: true + gpgcheck: true + repo_gpgcheck: true + gpgkey: + - https://packagecloud.io/crowdsec/crowdsec/gpgkey + - https://packagecloud.io/crowdsec/crowdsec/gpgkey/crowdsec-crowdsec-B78D1222C9AD2D5D.pub.gpg + - https://packagecloud.io/crowdsec/crowdsec/gpgkey/crowdsec-crowdsec-FED78314A2468CCF.pub.gpg + metadata_expire: "300" + file: crowdsec + + when: + - ansible_os_family == "RedHat" + + - name: Install crowdsec + package: + name: + - crowdsec + state: present + update_cache: yes + + tags: + - crowdsec