Skip to main content
  1. Notes/
  2. Vagrant/

Vagrant init

144 words
Table of Contents

Init
#

vagrant init

Simple config
#

Vagrant.configure(2) do |config|
  config.vm.box = "rhel7.1"
  config.vm.box_url = "http://content.example.com/puppet3.6/x86_64/dvd/vagrant/rhel-server-libvirt-7.1-1.x86_64.box"
  config.vm.hostname = "sandbox.example.com"
end

Bit more config
#

ENV["LC_ALL"] = "en_US.UTF-8"
Vagrant.configure("2") do |config|
  config.vm.box = "generic/centos7"
  config.vm.hostname = "puppy1.doubtfull.snd"
  config.vm.synced_folder "puppet/ssl", "/var/tmp/puppet_ssl", type: "rsync", owner: "root", group: "root", rsync__rsync_path: "sudo rsync"
  config.vm.provision "shell", inline: <<-SHELL
    echo 'LANG="en_US.UTF-8"' > /etc/locale.conf
    echo "unset PROMPT_COMMAND" >> /root/.bashrc
    echo "10.0.0.165 foreman.doubtfull.snd" >> /etc/hosts
    echo ">> Install needed packages"
    yum install -q -y rsync vim-enhanced bash-completion deltarpm epel-release
    yum -y install https://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm
    yum -y install puppet
    rsync -av /var/tmp/puppet_ssl/ /var/lib/puppet/ssl/
  SHELL
  config.vm.provision "puppet_server" do |puppet|
    puppet.puppet_server = 'foreman.doubtfull.snd'
    puppet.options = '--onetime --verbose --waitforcert=10 --no-usecacheonfailure --no-daemonize'
  end
end

Adding instructions
#

config.vm.provision "shell", inline: <<-SHELL
  sudo cp /home/vagrant/sync/etc/yum.repos.d/* /etc/yum.repos.d
  sudo yum install -y puppet
SHELL

Adding puppet
#

config.vm.provision "puppet_server" do |puppet|
  puppet.puppet_server = 'serverc.lab.example.com'
  puppet.options = '--onetime --verbose --waitforcert=10 --no-usecacheonfailure --no-daemonize'
end