# This is the vagrant mixin # By including it with the line below (see double hashes), we guarantee that our # vagrant infrastructure shares the same characteristics ## eval(IO.read("../vagrant.mixin"), binding) require 'yaml' if File.exist?("../config.yaml") data = YAML.load_file("../config.yaml") else data = YAML.load_file("../../config.yaml") end ip = data['hosts'][config.vm.hostname] config.vm.box_url = data['vagrants'][config.vm.box] config.vm.network "private_network", :ip => ip config.vm.provision "shell", inline: "echo #{ip} > /etc/publicip" playbook_base = "../../../orchestration.workloads" playbook_path = "#{playbook_base}/#{client}" config.vm.provider :virtualbox do |provider, override| if defined?(mount_repo) then if defined?(mount_dest) then config.vm.synced_folder mount_repo, mount_dest else config.vm.synced_folder mount_repo, "/data/repo" end end end # run ansible against the box config.vm.provision "ansible" do |ansible| if defined?(playbook) then ansible.playbook = "#{playbook_path}/#{playbook}.yml" else ansible.playbook = "#{playbook_path}/#{config.vm.hostname}.yml" end # ansible vault key file ansible_keyfile = "#{playbook_path}/ansible.vault.key" if File.exist?(ansible_keyfile) then ansible.vault_password_file = ansible_keyfile end ENV['ANSIBLE_CONFIG'] = File.absolute_path("#{playbook_base}/ansible.cfg") if ENV['DEBUG'] != nil then ansible.verbose = 'vv' end if ENV['ANSIBLE_TAGS'] != nil then ansible.tags = ENV['ANSIBLE_TAGS'] end if ENV['ANSIBLE_START_TASK'] != nil then ansible.start_at_task = ENV['ANSIBLE_START_TASK'] end # ansible variables specifically set when vagranting! if defined?(ansible_extras) then ansible.extra_vars = ansible_extras end # # if any variables are defined in the vagrant files, then add them to the ansible # # extra vars hash for use in provisioning # if defined? ansible_extras then # ansible.extra_vars = ansible.extra_vars.merge(ansible_extras) # end end