Ansible testing (#1691)
This commit is contained in:
parent
1002affc16
commit
c742242094
|
@ -58,16 +58,17 @@ ansible won't be able to see them.
|
||||||
variables for Debian and RedHat-based distributions, because stable releases
|
variables for Debian and RedHat-based distributions, because stable releases
|
||||||
require a package version suffix in the RPM file names.
|
require a package version suffix in the RPM file names.
|
||||||
|
|
||||||
- `TEST_PACKAGE_FILE`: optional, file pointing to the package under test
|
- `TEST_PACKAGE_FILE`: optional, file pointing to the package under test (.deb,
|
||||||
(.deb, .rpm, .pkg...). If both `TEST_PACKAGE_VERSION_*` and
|
.rpm, .pkg...). It can be a glob expression but it must match a single file,
|
||||||
`TEST_PACKAGE_FILE` are provided, both are be installed (to test upgrades
|
and the pattern works only on the filename. If both `TEST_PACKAGE_VERSION_*`
|
||||||
|
and `TEST_PACKAGE_FILE` are provided, both are be installed (to test upgrades
|
||||||
for example). Requires `PACKAGE_TESTING=true`
|
for example). Requires `PACKAGE_TESTING=true`
|
||||||
|
|
||||||
- `TEST_PACKAGE_DIR`: optional (but conflicts with `TEST_PACKAGE_FILE`), the path
|
- `TEST_PACKAGE_DIR`: optional (but conflicts with `TEST_PACKAGE_FILE`), the path
|
||||||
to a directory containing packages with the following layout:
|
to a directory containing packages with the following layout:
|
||||||
|
|
||||||
For DEB: `{{ package_dir }}/{{ ansible_distribution_release }}_{{ ansible_architecture.replace('x86_64', 'amd64) }}/{{ ansible_distribution_release }}/{{ ansible_architecture.replace('x86_64', 'amd64' }}/crowdsec_*.deb`
|
For DEB: `{{ package_dir }}/{{ ansible_distribution_release }}/{{ ansible_architecture.replace('x86_64', 'amd64' }}/crowdsec_*.deb`
|
||||||
For RPM: `{{ package_dir }}/{{ releasever }}/RPMS/{{ ansible_architecture }}/crowdsec-{{ testing_file_version }}*.{{ releasever }}.{{ ansible_architecture }}.rpm`
|
For RPM: `{{ package_dir }}/{{ releasever }}/RPMS/{{ ansible_architecture }}/crowdsec-*.{{ releasever }}.{{ ansible_architecture }}.rpm`
|
||||||
|
|
||||||
- `TEST_SKIP`: optional, comma-separated list of scripts that won't be executed.
|
- `TEST_SKIP`: optional, comma-separated list of scripts that won't be executed.
|
||||||
Example: `TEST_SKIP=02_nolapi.bats,03_noagent.bats`
|
Example: `TEST_SKIP=02_nolapi.bats,03_noagent.bats`
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- name: "install Go (!freebsd)"
|
- name: "install Go (!bsd)"
|
||||||
hosts: all
|
hosts: all
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
vars_files:
|
vars_files:
|
||||||
|
@ -8,9 +8,9 @@
|
||||||
- ansible.builtin.include_role:
|
- ansible.builtin.include_role:
|
||||||
name: gantsign.golang
|
name: gantsign.golang
|
||||||
when:
|
when:
|
||||||
- ansible_os_family != "FreeBSD"
|
- ansible_facts.system == 'Linux'
|
||||||
|
|
||||||
- name: "install Go (freebsd)"
|
- name: "install Go (bsd)"
|
||||||
hosts: all
|
hosts: all
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
become: true
|
become: true
|
||||||
|
@ -19,7 +19,20 @@
|
||||||
name: go
|
name: go
|
||||||
state: present
|
state: present
|
||||||
when:
|
when:
|
||||||
- ansible_os_family == "FreeBSD"
|
- ansible_facts.system == 'FreeBSD'
|
||||||
|
|
||||||
|
# required for jq and basic tools on centos and rhel
|
||||||
|
- name: "enable EPEL repository (RedHat)"
|
||||||
|
hosts: all
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- ansible.builtin.include_role:
|
||||||
|
name: geerlingguy.repo-epel
|
||||||
|
vars:
|
||||||
|
epel_repo_disable: false
|
||||||
|
when:
|
||||||
|
- ansible_facts.os_family == 'RedHat'
|
||||||
|
- ansible_facts.distribution != 'Fedora'
|
||||||
|
|
||||||
- name: "apply common configuration to all nodes"
|
- name: "apply common configuration to all nodes"
|
||||||
hosts: all
|
hosts: all
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
---
|
---
|
||||||
- src: geerlingguy.postgresql
|
|
||||||
- src: geerlingguy.mysql
|
- src: geerlingguy.mysql
|
||||||
|
- src: geerlingguy.postgresql
|
||||||
|
- src: geerlingguy.repo-epel
|
||||||
- src: gantsign.golang
|
- src: gantsign.golang
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
---
|
---
|
||||||
build_bash: false
|
build_bash: false
|
||||||
|
|
||||||
build_daemonize: (ansible_distribution == "Ubuntu" and ansible_distribution_version == '16.04') or ansible_distribution == 'Amazon'
|
build_daemonize: (ansible_facts.distribution == "Ubuntu" and ansible_facts.distribution == '16.04') or ansible_facts.distribution == 'Amazon'
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
- name: "Install daemonize"
|
- name: "Install daemonize"
|
||||||
ansible.builtin.import_tasks: daemonize.yml
|
ansible.builtin.import_tasks: daemonize.yml
|
||||||
when:
|
when:
|
||||||
- ansible_os_family != 'FreeBSD'
|
- ansible_facts.system == 'Linux'
|
||||||
|
|
||||||
- name: "install netcat"
|
- name: "install netcat"
|
||||||
ansible.builtin.import_tasks: netcat.yml
|
ansible.builtin.import_tasks: netcat.yml
|
||||||
|
@ -25,15 +25,16 @@
|
||||||
name:
|
name:
|
||||||
- bc
|
- bc
|
||||||
when:
|
when:
|
||||||
- ansible_os_family != 'FreeBSD'
|
- ansible_facts.system == 'Linux'
|
||||||
|
|
||||||
- name: "install base64(freebsd)"
|
# base64 for linux is in coreutils
|
||||||
|
- name: "install base64 (freebsd)"
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.package:
|
ansible.builtin.package:
|
||||||
name:
|
name:
|
||||||
- base64
|
- base64
|
||||||
when:
|
when:
|
||||||
- ansible_os_family == 'FreeBSD'
|
- ansible_facts.system == 'FreeBSD'
|
||||||
|
|
||||||
- name: "install pidof (Amazon)"
|
- name: "install pidof (Amazon)"
|
||||||
become: true
|
become: true
|
||||||
|
@ -41,7 +42,7 @@
|
||||||
name:
|
name:
|
||||||
- procps-ng
|
- procps-ng
|
||||||
when:
|
when:
|
||||||
- ansible_distribution == 'Amazon'
|
- ansible_facts.distribution == 'Amazon'
|
||||||
|
|
||||||
- name: "install gcc (for go-sqlite, needs cgo)"
|
- name: "install gcc (for go-sqlite, needs cgo)"
|
||||||
become: true
|
become: true
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
name:
|
name:
|
||||||
- nmap-ncat
|
- nmap-ncat
|
||||||
when:
|
when:
|
||||||
- ansible_facts['distribution'] in ['Amazon', 'Fedora', 'CentOS', 'OracleLinux']
|
- ansible_facts.distribution in ['Amazon', 'Fedora', 'CentOS', 'OracleLinux']
|
||||||
|
|
||||||
- name: "install netcat (RedHat)"
|
- name: "install netcat (RedHat)"
|
||||||
become: true
|
become: true
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
name:
|
name:
|
||||||
- netcat
|
- netcat
|
||||||
when:
|
when:
|
||||||
- ansible_facts['distribution'] == 'RedHat'
|
- (ansible_facts.distribution == 'RedHat') or (ansible_facts.distribution == 'AlmaLinux')
|
||||||
|
|
||||||
# "netcat" does not exist in some versions (only -traditional or -openbsd)
|
# "netcat" does not exist in some versions (only -traditional or -openbsd)
|
||||||
- name: "install netcat (Debian)"
|
- name: "install netcat (Debian)"
|
||||||
|
@ -22,4 +22,13 @@
|
||||||
name:
|
name:
|
||||||
- netcat-traditional
|
- netcat-traditional
|
||||||
when:
|
when:
|
||||||
- ansible_os_family == "Debian"
|
- ansible_facts.os_family == "Debian"
|
||||||
|
|
||||||
|
# "netcat" does not exist in some versions (only -traditional or -openbsd)
|
||||||
|
- name: "install netcat (Suse)"
|
||||||
|
become: true
|
||||||
|
ansible.builtin.package:
|
||||||
|
name:
|
||||||
|
- netcat-openbsd
|
||||||
|
when:
|
||||||
|
- ansible_facts.os_family == "Suse"
|
||||||
|
|
|
@ -1,19 +1,11 @@
|
||||||
---
|
---
|
||||||
# required for (at least) jq
|
|
||||||
- name: "enable EPEL"
|
|
||||||
become: true
|
|
||||||
ansible.builtin.package:
|
|
||||||
name: epel-release
|
|
||||||
when:
|
|
||||||
- ansible_distribution == 'CentOS'
|
|
||||||
|
|
||||||
- name: "update package cache (Debian)"
|
- name: "update package cache (Debian)"
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
upgrade: false
|
upgrade: false
|
||||||
update_cache: true
|
update_cache: true
|
||||||
when:
|
when:
|
||||||
- ansible_os_family == "Debian"
|
- ansible_facts.os_family == "Debian"
|
||||||
|
|
||||||
- name: "install gcc, git"
|
- name: "install gcc, git"
|
||||||
become: true
|
become: true
|
||||||
|
@ -28,7 +20,7 @@
|
||||||
name:
|
name:
|
||||||
- make
|
- make
|
||||||
when:
|
when:
|
||||||
- ansible_os_family != "FreeBSD"
|
- ansible_facts.system == "Linux"
|
||||||
|
|
||||||
- name: "install gmake (FreeBSD)"
|
- name: "install gmake (FreeBSD)"
|
||||||
become: true
|
become: true
|
||||||
|
@ -36,4 +28,4 @@
|
||||||
name:
|
name:
|
||||||
- gmake
|
- gmake
|
||||||
when:
|
when:
|
||||||
- ansible_os_family == "FreeBSD"
|
- ansible_facts.system == "FreeBSD"
|
||||||
|
|
|
@ -1,19 +1,38 @@
|
||||||
---
|
---
|
||||||
- name: "set package_file from package_dir"
|
- name: "set package_file from package_dir"
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
package_file: "{{ package_dir }}/{{ ansible_distribution_release }}_{{ ansible_architecture.replace('x86_64', 'amd64) }}/{{ ansible_distribution_release }}/{{ ansible_architecture.replace('x86_64', 'amd64' }}/crowdsec_*.deb"
|
package_file: "{{ package_dir }}/{{ ansible_facts.distribution_release }}/{{ ansible_facts.architecture.replace('x86_64', 'amd64') }}/crowdsec_*.deb"
|
||||||
when:
|
when:
|
||||||
- (package_dir is defined) and (package_dir | length > 0)
|
- (package_dir is defined) and (package_dir | length > 0)
|
||||||
|
|
||||||
|
- name: "look for .deb file matching package_file"
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
found_file: "{{ item }}"
|
||||||
|
with_fileglob:
|
||||||
|
- "{{ package_file }}"
|
||||||
|
when:
|
||||||
|
- (package_file is defined) and (package_file | length > 0)
|
||||||
|
|
||||||
|
- name: "check found_file"
|
||||||
|
ansible.builtin.fail:
|
||||||
|
msg: "No file found matching {{ package_file }}"
|
||||||
|
when:
|
||||||
|
- found_file is not defined
|
||||||
|
- (package_file is defined) and (package_file | length > 0)
|
||||||
|
|
||||||
- name: "copy built file for deb-like"
|
- name: "copy built file for deb-like"
|
||||||
become: false
|
become: false
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: "{{ package_file }}"
|
src: "{{ found_file }}"
|
||||||
dest: "{{ ansible_env.HOME }}/crowdsec.deb"
|
dest: "{{ ansible_env.HOME }}/crowdsec.deb"
|
||||||
mode: 0o644
|
mode: 0o644
|
||||||
|
when:
|
||||||
|
- (package_file is defined) and (package_file | length > 0)
|
||||||
|
|
||||||
- name: "install crowdsec on deb-like"
|
- name: "install crowdsec on deb-like"
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name: "{{ ansible_env.HOME }}/crowdsec.deb"
|
deb: "{{ ansible_env.HOME }}/crowdsec.deb"
|
||||||
allow_downgrade: true
|
allow_downgrade: true
|
||||||
|
when:
|
||||||
|
- (package_file is defined) and (package_file | length > 0)
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
- name: "add crowdsec repo [2/2] (*.deb)"
|
- name: "add crowdsec repo [2/2] (*.deb)"
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.apt_repository:
|
ansible.builtin.apt_repository:
|
||||||
repo: deb https://packagecloud.io/crowdsec/crowdsec/{{ ansible_distribution | lower }}/ {{ ansible_distribution_release }} main
|
repo: deb https://packagecloud.io/crowdsec/crowdsec/{{ ansible_facts.distribution | lower }}/ {{ ansible_facts.distribution_release }} main
|
||||||
|
|
||||||
- name: "install crowdsec testing repo [1/2] (*.deb)"
|
- name: "install crowdsec testing repo [1/2] (*.deb)"
|
||||||
become: true
|
become: true
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
- name: "add crowdsec testing repo [1/2] (*.deb)"
|
- name: "add crowdsec testing repo [1/2] (*.deb)"
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.apt_repository:
|
ansible.builtin.apt_repository:
|
||||||
repo: deb https://packagecloud.io/crowdsec/crowdsec-testing/{{ ansible_distribution | lower }}/ {{ ansible_distribution_release }} main
|
repo: deb https://packagecloud.io/crowdsec/crowdsec-testing/{{ ansible_facts.distribution | lower }}/ {{ ansible_facts.distribution_release }} main
|
||||||
|
|
||||||
- name: "install crowdsec"
|
- name: "install crowdsec"
|
||||||
become: true
|
become: true
|
||||||
|
|
|
@ -1,16 +1,33 @@
|
||||||
---
|
---
|
||||||
- name: "set package_file from package_dir"
|
- name: "set package_file from package_dir"
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
package_file: "{{ package_dir }}/{{ releasever }}/RPMS/{{ ansible_architecture }}/crowdsec-{{ testing_file_version }}*.{{ releasever }}.{{ ansible_architecture }}.rpm"
|
package_file: "{{ package_dir }}/{{ releasever }}/RPMS/{{ ansible_facts.architecture }}/crowdsec-*.{{ releasever }}.{{ ansible_facts.architecture }}.rpm"
|
||||||
when:
|
when:
|
||||||
- (package_dir is defined) and (package_dir | length > 0)
|
- (package_dir is defined) and (package_dir | length > 0)
|
||||||
|
|
||||||
|
- name: "look for .rpm file matching package_file"
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
found_file: "{{ item }}"
|
||||||
|
with_fileglob:
|
||||||
|
- "{{ package_file }}"
|
||||||
|
when:
|
||||||
|
- (package_file is defined) and (package_file | length > 0)
|
||||||
|
|
||||||
|
- name: "check found_file"
|
||||||
|
ansible.builtin.fail:
|
||||||
|
msg: "No file found matching {{ package_file }}"
|
||||||
|
when:
|
||||||
|
- found_file is not defined
|
||||||
|
- (package_file is defined) and (package_file | length > 0)
|
||||||
|
|
||||||
- name: "copy built file for rpm-like"
|
- name: "copy built file for rpm-like"
|
||||||
become: false
|
become: false
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: "{{ package_file }}"
|
src: "{{ found_file }}"
|
||||||
dest: "{{ ansible_env.HOME }}/crowdsec.rpm"
|
dest: "{{ ansible_env.HOME }}/crowdsec.rpm"
|
||||||
mode: 0o644
|
mode: 0o644
|
||||||
|
when:
|
||||||
|
- (package_file is defined) and (package_file | length > 0)
|
||||||
|
|
||||||
- name: "install crowdsec on rpm-like"
|
- name: "install crowdsec on rpm-like"
|
||||||
become: true
|
become: true
|
||||||
|
@ -18,3 +35,5 @@
|
||||||
name: "{{ ansible_env.HOME }}/crowdsec.rpm"
|
name: "{{ ansible_env.HOME }}/crowdsec.rpm"
|
||||||
disable_gpg_check: true
|
disable_gpg_check: true
|
||||||
allow_downgrade: true
|
allow_downgrade: true
|
||||||
|
when:
|
||||||
|
- (package_file is defined) and (package_file | length > 0)
|
||||||
|
|
|
@ -2,32 +2,30 @@
|
||||||
- name: "system details"
|
- name: "system details"
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: |
|
msg: |
|
||||||
Distribution: {{ ansible_distribution }}
|
Distribution: {{ ansible_facts.distribution }}
|
||||||
Version: {{ ansible_distribution_version }}
|
Version: {{ ansible_facts.distribution_version }}
|
||||||
Major: {{ ansible_distribution_major_version }}
|
Major: {{ ansible_facts.distribution_major_version }}
|
||||||
Release: {{ ansible_distribution_release }}
|
Release: {{ ansible_facts.distribution_release }}
|
||||||
Releasever: {{ releasever }}
|
Releasever: {{ releasever }}
|
||||||
|
|
||||||
- name: "install from binary repository (RedHat)"
|
- name: "install from binary repository (RedHat)"
|
||||||
ansible.builtin.import_tasks: install_from_rpm_repo.yml
|
ansible.builtin.import_tasks: install_from_rpm_repo.yml
|
||||||
when:
|
when:
|
||||||
- (package_version_rpm is defined) and (package_version_rpm|length > 0)
|
- (package_version_rpm is defined) and (package_version_rpm|length > 0)
|
||||||
- ansible_os_family == "RedHat"
|
- ansible_facts.os_family == "RedHat"
|
||||||
|
|
||||||
- name: "install from binary repository (Debian)"
|
- name: "install from binary repository (Debian)"
|
||||||
ansible.builtin.import_tasks: install_from_deb_repo.yml
|
ansible.builtin.import_tasks: install_from_deb_repo.yml
|
||||||
when:
|
when:
|
||||||
- (package_version_deb is defined) and (package_version_deb|length > 0)
|
- (package_version_deb is defined) and (package_version_deb|length > 0)
|
||||||
- ansible_os_family == "Debian"
|
- ansible_facts.os_family == "Debian"
|
||||||
|
|
||||||
- name: "install from *.rpm package file"
|
- name: "install from *.rpm package file"
|
||||||
ansible.builtin.import_tasks: install_from_rpm.yml
|
ansible.builtin.import_tasks: install_from_rpm.yml
|
||||||
when:
|
when:
|
||||||
- (package_file is defined) and (package_file|length > 0)
|
- ansible_facts.os_family == "RedHat"
|
||||||
- ansible_os_family == "RedHat"
|
|
||||||
|
|
||||||
- name: "install from *.deb package file"
|
- name: "install from *.deb package file"
|
||||||
ansible.builtin.import_tasks: install_from_deb.yml
|
ansible.builtin.import_tasks: install_from_deb.yml
|
||||||
when:
|
when:
|
||||||
- (package_file is defined) and (package_file|length > 0)
|
- ansible_facts.os_family == "Debian"
|
||||||
- ansible_os_family == "Debian"
|
|
||||||
|
|
|
@ -7,8 +7,11 @@ release:
|
||||||
Ubuntu: ubuntu
|
Ubuntu: ubuntu
|
||||||
FreeBSD: freebsd
|
FreeBSD: freebsd
|
||||||
OracleLinux: ol
|
OracleLinux: ol
|
||||||
|
Rocky: el
|
||||||
|
AlmaLinux: el
|
||||||
|
openSUSE Leap: opensuse
|
||||||
|
|
||||||
releasever: "{{ release[ansible_distribution] + ansible_distribution_major_version }}"
|
releasever: "{{ release[ansible_facts.distribution] + ansible_facts.distribution_major_version }}"
|
||||||
|
|
||||||
package_version_deb: "{{ lookup('ansible.builtin.env', 'TEST_PACKAGE_VERSION_DEB') }}"
|
package_version_deb: "{{ lookup('ansible.builtin.env', 'TEST_PACKAGE_VERSION_DEB') }}"
|
||||||
package_version_rpm: "{{ lookup('ansible.builtin.env', 'TEST_PACKAGE_VERSION_RPM') }}"
|
package_version_rpm: "{{ lookup('ansible.builtin.env', 'TEST_PACKAGE_VERSION_RPM') }}"
|
||||||
|
|
|
@ -60,6 +60,15 @@
|
||||||
when:
|
when:
|
||||||
- (suite_zip is not defined) or (suite_zip|length == 0)
|
- (suite_zip is not defined) or (suite_zip|length == 0)
|
||||||
|
|
||||||
|
- name: set safe.directory on crowdsec dir"
|
||||||
|
become: false
|
||||||
|
ansible.builtin.git_config:
|
||||||
|
scope: global
|
||||||
|
name: safe.directory
|
||||||
|
value: "{{ ansible_env.HOME }}/crowdsec"
|
||||||
|
when:
|
||||||
|
- (suite_zip is not defined) or (suite_zip|length == 0)
|
||||||
|
|
||||||
- name: "install tests: create crowdsec tests/local dir"
|
- name: "install tests: create crowdsec tests/local dir"
|
||||||
become: false
|
become: false
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
content: "{{ machine_id }}"
|
content: "{{ machine_id }}"
|
||||||
mode: 0o444
|
mode: 0o444
|
||||||
|
|
||||||
|
- name: "see if /var/lib/dbus exists"
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: "/var/lib/dbus"
|
||||||
|
register: dbus
|
||||||
|
|
||||||
# some distributions use var/lib/dbus,
|
# some distributions use var/lib/dbus,
|
||||||
# but the directory doesn't exists on fedora
|
# but the directory doesn't exists on fedora
|
||||||
- name: "set /var/lib/dbus/machine-id"
|
- name: "set /var/lib/dbus/machine-id"
|
||||||
|
@ -15,4 +20,4 @@
|
||||||
content: "{{ machine_id }}"
|
content: "{{ machine_id }}"
|
||||||
mode: 0o444
|
mode: 0o444
|
||||||
when:
|
when:
|
||||||
- ansible_os_family != 'FreeBSD' and ansible_distribution != "Fedora"
|
- dbus.stat.exists
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
make_cmd: make
|
make_cmd: make
|
||||||
when:
|
when:
|
||||||
- ansible_os_family != 'FreeBSD'
|
- ansible_facts.system != 'FreeBSD'
|
||||||
|
|
||||||
- name: "set make_cmd = gmake (freebsd)"
|
- name: "set make_cmd = gmake (freebsd)"
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
make_cmd: gmake
|
make_cmd: gmake
|
||||||
when:
|
when:
|
||||||
- ansible_os_family == 'FreeBSD'
|
- ansible_facts.system == 'FreeBSD'
|
||||||
|
|
||||||
- name: "build crowdsec from sources, prepare test environment and fixture"
|
- name: "build crowdsec from sources, prepare test environment and fixture"
|
||||||
become: false
|
become: false
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
state: directory
|
state: directory
|
||||||
when:
|
when:
|
||||||
- (package_testing is defined) and (package_testing not in ['', 'false', 'False'])
|
- (package_testing is defined) and (package_testing not in ['', 'false', 'False'])
|
||||||
- ansible_os_family in ["RedHat", "Debian"]
|
- ansible_facts.os_family in ["RedHat", "Debian"]
|
||||||
|
|
||||||
- name: "override StartLimitBurst"
|
- name: "override StartLimitBurst"
|
||||||
become: true
|
become: true
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
value: 100
|
value: 100
|
||||||
when:
|
when:
|
||||||
- (package_testing is defined) and (package_testing not in ['', 'false', 'False'])
|
- (package_testing is defined) and (package_testing not in ['', 'false', 'False'])
|
||||||
- ansible_os_family in ["RedHat", "Debian"]
|
- ansible_facts.os_family in ["RedHat", "Debian"]
|
||||||
|
|
||||||
- name: "systemctl daemon-reload"
|
- name: "systemctl daemon-reload"
|
||||||
become: true
|
become: true
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
when:
|
when:
|
||||||
- (package_testing is defined) and (package_testing not in ['', 'false', 'False'])
|
- (package_testing is defined) and (package_testing not in ['', 'false', 'False'])
|
||||||
- ansible_os_family in ["RedHat", "Debian"]
|
- ansible_facts.os_family in ["RedHat", "Debian"]
|
||||||
|
|
||||||
- name: "search for test scripts"
|
- name: "search for test scripts"
|
||||||
become: false
|
become: false
|
||||||
|
|
6
tests/ansible/vagrant/alma-9/Vagrantfile
vendored
Normal file
6
tests/ansible/vagrant/alma-9/Vagrantfile
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
common = '../Vagrantfile.common'
|
||||||
|
load common if File.exists?(common)
|
||||||
|
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.box = "generic/alma9"
|
||||||
|
end
|
6
tests/ansible/vagrant/centos-9/Vagrantfile
vendored
Normal file
6
tests/ansible/vagrant/centos-9/Vagrantfile
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
common = '../Vagrantfile.common'
|
||||||
|
load common if File.exists?(common)
|
||||||
|
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.box = "generic/centos9s"
|
||||||
|
end
|
6
tests/ansible/vagrant/rocky-9/Vagrantfile
vendored
Normal file
6
tests/ansible/vagrant/rocky-9/Vagrantfile
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
common = '../Vagrantfile.common'
|
||||||
|
load common if File.exists?(common)
|
||||||
|
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.box = "generic/rocky9"
|
||||||
|
end
|
|
@ -129,9 +129,14 @@ teardown() {
|
||||||
|
|
||||||
./instance-crowdsec start
|
./instance-crowdsec start
|
||||||
fake_log >>"${tmpfile}"
|
fake_log >>"${tmpfile}"
|
||||||
sleep 2
|
|
||||||
|
# this could be simplified, but some systems are slow and we don't want to
|
||||||
|
# wait more than required
|
||||||
|
for ((idx = 0; idx < 20; idx++)); do
|
||||||
|
sleep .5
|
||||||
|
run -0 --separate-stderr cscli decisions list -o json
|
||||||
|
run -0 jq --exit-status '.[].decisions[0] | [.value,.type] == ["1.1.1.172","captcha"]' <(output) && break
|
||||||
|
done
|
||||||
rm -f -- "${tmpfile}"
|
rm -f -- "${tmpfile}"
|
||||||
run -0 --separate-stderr cscli decisions list -o json
|
[[ "${status}" -eq 0 ]] || fail "captcha not triggered"
|
||||||
run -0 jq -c '.[].decisions[0] | [.value,.type]' <(output)
|
|
||||||
assert_output '["1.1.1.172","captcha"]'
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,14 +58,17 @@ make_init_data() {
|
||||||
|
|
||||||
"${TEST_DIR}/instance-crowdsec" start
|
"${TEST_DIR}/instance-crowdsec" start
|
||||||
|
|
||||||
"${CSCLI}" decisions delete --all
|
for ((i=0; i<10; i++)); do
|
||||||
|
sleep .5
|
||||||
loop_max=15
|
"${CSCLI}" decisions delete --all && break
|
||||||
for ((i = 0; i <= loop_max; i++)); do
|
|
||||||
sleep 2
|
|
||||||
[[ $("${CSCLI}" alerts list -o json) != "null" ]] && break
|
|
||||||
done
|
done
|
||||||
[[ $("${CSCLI}" alerts list -a -o json) != "null" ]] || die "could not get community data"
|
|
||||||
|
for ((i=0; i<15; i++)); do
|
||||||
|
sleep 2
|
||||||
|
[[ $("${CSCLI}" alerts list -a -o json) != "null" ]] && break
|
||||||
|
done
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
[[ "$?" -ne "0" ]] && die "could not get community data"
|
||||||
|
|
||||||
"${TEST_DIR}/instance-crowdsec" stop
|
"${TEST_DIR}/instance-crowdsec" stop
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue