2022-09-06 09:33:50 +00:00
|
|
|
# vim: set ft=ruby:
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-07-04 10:26:32 +00:00
|
|
|
def find_ansible_cfg
|
|
|
|
path = Pathname.new(Dir.pwd)
|
|
|
|
until path.root?
|
|
|
|
ansible_cfg = path + 'ansible.cfg'
|
|
|
|
return path if ansible_cfg.exist?
|
|
|
|
path = path.parent
|
|
|
|
end
|
|
|
|
nil # return nil if not found
|
|
|
|
end
|
|
|
|
|
2022-09-06 09:33:50 +00:00
|
|
|
Vagrant.configure('2') do |config|
|
|
|
|
config.vm.define 'crowdsec'
|
|
|
|
|
2023-09-29 10:58:35 +00:00
|
|
|
if ARGV.any? { |arg| arg == 'up' || arg == 'provision' } && !ARGV.include?('--no-provision')
|
2023-07-04 10:26:32 +00:00
|
|
|
unless ENV['DB_BACKEND']
|
|
|
|
$stderr.puts "\e[31mThe DB_BACKEND environment variable is not defined. Please set up the environment and try again.\e[0m"
|
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-09-29 10:58:35 +00:00
|
|
|
config.vm.provision 'shell', path: 'bootstrap' if File.exist?('bootstrap')
|
2023-07-04 10:26:32 +00:00
|
|
|
config.vm.synced_folder '.', '/vagrant', disabled: true
|
|
|
|
|
2022-09-06 09:33:50 +00:00
|
|
|
config.vm.provider :libvirt do |libvirt|
|
|
|
|
libvirt.cpus = 1
|
|
|
|
libvirt.memory = 1536
|
|
|
|
end
|
|
|
|
|
2023-07-04 10:26:32 +00:00
|
|
|
path = find_ansible_cfg
|
|
|
|
if !path
|
|
|
|
puts "ansible.cfg not found"
|
|
|
|
end
|
2022-09-06 09:33:50 +00:00
|
|
|
|
|
|
|
config.vm.provision 'ansible' do |ansible|
|
|
|
|
# ansible.verbose = 'vvvv'
|
2023-07-04 10:26:32 +00:00
|
|
|
ansible.config_file = (path + 'ansible.cfg').to_s
|
|
|
|
ansible.playbook = (path + 'run_all.yml').to_s
|
|
|
|
ansible.compatibility_mode = "2.0"
|
2022-09-06 09:33:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# same as above, to run the steps separately
|
|
|
|
|
2023-07-04 10:26:32 +00:00
|
|
|
# config.vm.provision 'ansible' do |ansible|
|
|
|
|
# ansible.config_file = (path + 'ansible.cfg').to_s
|
|
|
|
# ansible.playbook = (path + 'provision_dependencies.yml').to_s
|
|
|
|
# ansible.compatibility_mode = "2.0"
|
2022-09-06 09:33:50 +00:00
|
|
|
# end
|
|
|
|
|
2023-07-04 10:26:32 +00:00
|
|
|
# config.vm.provision 'ansible' do |ansible|
|
|
|
|
# ansible.config_file = (path + 'ansible.cfg').to_s
|
|
|
|
# ansible.playbook = (path + 'provision_test_suite.yml').to_s
|
|
|
|
# ansible.compatibility_mode = "2.0"
|
2022-09-06 09:33:50 +00:00
|
|
|
# end
|
|
|
|
|
2023-07-04 10:26:32 +00:00
|
|
|
# config.vm.provision 'ansible' do |ansible|
|
|
|
|
# ansible.config_file = (path + 'ansible.cfg').to_s
|
|
|
|
# ansible.playbook = (path + 'install_binary_package.yml').to_s
|
|
|
|
# ansible.compatibility_mode = "2.0"
|
2022-09-12 14:07:14 +00:00
|
|
|
# end
|
|
|
|
|
2023-07-04 10:26:32 +00:00
|
|
|
# config.vm.provision 'ansible' do |ansible|
|
|
|
|
# ansible.config_file = (path + 'ansible.cfg').to_s
|
|
|
|
# ansible.playbook = (path + 'prepare_tests.yml').to_s
|
|
|
|
# ansible.compatibility_mode = "2.0"
|
2022-09-06 09:33:50 +00:00
|
|
|
# end
|
|
|
|
|
2023-07-04 10:26:32 +00:00
|
|
|
# config.vm.provision 'ansible' do |ansible|
|
|
|
|
# ansible.config_file = (path + 'ansible.cfg').to_s
|
|
|
|
# ansible.playbook = (path + 'run_tests.yml').to_s
|
|
|
|
# ansible.compatibility_mode = "2.0"
|
2022-09-06 09:33:50 +00:00
|
|
|
# end
|
|
|
|
end
|