#!/usr/bin/env ruby
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure('2') do |config|
  config.omnibus.chef_version = '11.16.4'
  config.berkshelf.enabled = true
  config.vm.define 'vagrant' do |node|
    node.vm.box = 'chef/ubuntu-14.04'
    node.vm.hostname = 'vagrant'
    node.vm.network :private_network, ip: '10.10.10.10'
    node.vm.provision :chef_solo do |chef|
      chef.log_level = :debug
      chef.json = {
        'rabbitmq' => {
          'disabled_users' => [],
          'enabled_users' => [
            {
              'name' => 'guest',
              'password' => 'guest',
              'tag' => 'administrator',
              'rights' => [
                {
                  'vhost' => '/',
                  'conf'  => '.*',
                  'write' => '.*',
                  'read'  => '.*'
                }
              ]
            }
          ]
        },
        'franz' => {
          'opts' => {
            'debug' => false,
            'trace' => true
          },
          'config' => {
            'test' => {
              'checkpoint' => '/etc/franz/test.*.checkpoint',
              'checkpoint_interval' => 20,
              'input' => {
                'ignore_before' => 0,
                'discover_bound' => 10_000,
                'watch_bound' => 1_000,
                'tail_bound' => 1_000,
                'discover_interval' => 15,
                'watch_interval' => 5,
                'eviction_interval' => 300,
                'flush_interval' => 30,
                'configs' => [
                  {
                    'type' => 'franz',
                    'includes' => %w[ /var/log/franz/*.log ],
                    'json?' => true
                  }
                ]
              },
              'output' => {
                'rabbitmq' => {
                  'exchange' => {
                    'name' => 'franz'
                  },
                  'connection' => {
                    'host' => 'localhost',
                    'port' => 5672
                  }
                }
              }
            }
          }
        }
      }
      chef.run_list = %w(
        recipe[apt]
        recipe[bjn_rabbitmq]
        recipe[bjn_ruby]
        recipe[bjn_franz]
      )
    end
  end
end