github.com/crowdsecurity/crowdsec@v1.6.1/test/ansible/vagrant/common (about) 1 # vim: set ft=ruby: 2 # frozen_string_literal: true 3 4 def find_ansible_cfg 5 path = Pathname.new(Dir.pwd) 6 until path.root? 7 ansible_cfg = path + 'ansible.cfg' 8 return path if ansible_cfg.exist? 9 path = path.parent 10 end 11 nil # return nil if not found 12 end 13 14 Vagrant.configure('2') do |config| 15 config.vm.define 'crowdsec' 16 17 if ARGV.any? { |arg| arg == 'up' || arg == 'provision' } && !ARGV.include?('--no-provision') 18 unless ENV['DB_BACKEND'] 19 $stderr.puts "\e[31mThe DB_BACKEND environment variable is not defined. Please set up the environment and try again.\e[0m" 20 exit 1 21 end 22 end 23 24 config.vm.provision 'shell', path: 'bootstrap' if File.exist?('bootstrap') 25 config.vm.synced_folder '.', '/vagrant', disabled: true 26 27 config.vm.provider :libvirt do |libvirt| 28 libvirt.cpus = 1 29 libvirt.memory = 1536 30 end 31 32 path = find_ansible_cfg 33 if !path 34 puts "ansible.cfg not found" 35 end 36 37 config.vm.provision 'ansible' do |ansible| 38 # ansible.verbose = 'vvvv' 39 ansible.config_file = (path + 'ansible.cfg').to_s 40 ansible.playbook = (path + 'run_all.yml').to_s 41 ansible.compatibility_mode = "2.0" 42 end 43 44 # same as above, to run the steps separately 45 46 # config.vm.provision 'ansible' do |ansible| 47 # ansible.config_file = (path + 'ansible.cfg').to_s 48 # ansible.playbook = (path + 'provision_dependencies.yml').to_s 49 # ansible.compatibility_mode = "2.0" 50 # end 51 52 # config.vm.provision 'ansible' do |ansible| 53 # ansible.config_file = (path + 'ansible.cfg').to_s 54 # ansible.playbook = (path + 'provision_test_suite.yml').to_s 55 # ansible.compatibility_mode = "2.0" 56 # end 57 58 # config.vm.provision 'ansible' do |ansible| 59 # ansible.config_file = (path + 'ansible.cfg').to_s 60 # ansible.playbook = (path + 'install_binary_package.yml').to_s 61 # ansible.compatibility_mode = "2.0" 62 # end 63 64 # config.vm.provision 'ansible' do |ansible| 65 # ansible.config_file = (path + 'ansible.cfg').to_s 66 # ansible.playbook = (path + 'prepare_tests.yml').to_s 67 # ansible.compatibility_mode = "2.0" 68 # end 69 70 # config.vm.provision 'ansible' do |ansible| 71 # ansible.config_file = (path + 'ansible.cfg').to_s 72 # ansible.playbook = (path + 'run_tests.yml').to_s 73 # ansible.compatibility_mode = "2.0" 74 # end 75 end