mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-16 14:33:17 +02:00
79 lines
3 KiB
YAML
79 lines
3 KiB
YAML
# vim: set ft=yaml.ansible:
|
|
---
|
|
|
|
- name: "Set make_cmd = make (!bsd)"
|
|
ansible.builtin.set_fact:
|
|
make_cmd: make
|
|
when:
|
|
- ansible_facts.system not in ['FreeBSD', 'OpenBSD']
|
|
|
|
- name: "Set make_cmd = gmake (bsd)"
|
|
ansible.builtin.set_fact:
|
|
make_cmd: gmake
|
|
when:
|
|
- ansible_facts.system in ['FreeBSD', 'OpenBSD']
|
|
|
|
- name: "Build crowdsec from sources, prepare test environment and fixture"
|
|
become: false
|
|
block:
|
|
- name: "Make bats-build bats-fixture"
|
|
ansible.builtin.command:
|
|
# static build and we don't have to mess with LD_LIBRARY_PATH
|
|
cmd: "{{ make_cmd }} bats-build bats-fixture BUILD_STATIC=1"
|
|
chdir: "{{ ansible_env.HOME }}/crowdsec"
|
|
creates: "{{ ansible_env.HOME }}/crowdsec/test/local-init/init-config-data.tar"
|
|
environment:
|
|
DB_BACKEND: "{{ lookup('ansible.builtin.env', 'DB_BACKEND') }}"
|
|
# daemonize -> /usr/bin or /usr/local/sbin
|
|
# pidof -> /usr/sbin
|
|
# bash -> /opt/bash/bin
|
|
PATH: "/opt/bash/bin:{{ ansible_env.PATH }}:{{ golang_install_dir }}/bin/:/usr/sbin:/usr/local/sbin"
|
|
rescue:
|
|
- name: "Read crowdsec.log"
|
|
ansible.builtin.slurp:
|
|
path: "{{ ansible_env.HOME }}/crowdsec/test/local/var/log/crowdsec.log"
|
|
register: crowdsec_log
|
|
- name: "Show crowdsec.log"
|
|
ansible.builtin.fail:
|
|
msg: "{{ crowdsec_log['content'] | b64decode }}"
|
|
when: (package_testing is not defined) or (package_testing in ['', 'false', 'False'])
|
|
|
|
- name: "Prepare test environment and fixture for binary package"
|
|
become: true
|
|
block:
|
|
- name: "Make bats-environment bats-check-requirements bats-fixture"
|
|
ansible.builtin.command:
|
|
cmd: "{{ make_cmd }} bats-environment bats-check-requirements bats-fixture"
|
|
chdir: "{{ ansible_env.HOME }}/crowdsec"
|
|
creates: "{{ ansible_env.HOME }}/crowdsec/test/local-init/init-config-data.tar"
|
|
environment:
|
|
PACKAGE_TESTING: "{{ package_testing }}"
|
|
DB_BACKEND: "{{ lookup('ansible.builtin.env', 'DB_BACKEND') }}"
|
|
# daemonize -> /usr/bin or /usr/local/sbin
|
|
# pidof -> /usr/sbin
|
|
# bash -> /opt/bash/bin
|
|
PATH: "/opt/bash/bin:{{ ansible_env.PATH }}:{{ golang_install_dir }}/bin/:/usr/sbin:/usr/local/sbin"
|
|
rescue:
|
|
- name: "Read crowdsec.log"
|
|
ansible.builtin.slurp:
|
|
path: "/var/log/crowdsec.log"
|
|
register: crowdsec_log
|
|
- name: "Show crowdsec.log"
|
|
ansible.builtin.fail:
|
|
msg: "{{ crowdsec_log['content'] | b64decode }}"
|
|
when: (package_testing is defined) and (package_testing not in ['', 'false', 'False'])
|
|
|
|
- name: "Debug - show environment"
|
|
become: false
|
|
block:
|
|
- name: "Look for .environment.sh"
|
|
ansible.builtin.slurp:
|
|
src: "{{ ansible_env.HOME }}/crowdsec/test/.environment.sh"
|
|
changed_when: true
|
|
register: envfile
|
|
- name: "Show .environment.sh"
|
|
ansible.builtin.debug:
|
|
msg: "{{ envfile['content'] | b64decode }}"
|
|
- name: "Show environment variables"
|
|
ansible.builtin.debug:
|
|
msg: "{{ ansible_env | to_nice_yaml }}"
|