Skip to content

Instantly share code, notes, and snippets.

@boxrick
Created May 4, 2018 14:41
Show Gist options
  • Save boxrick/31da7f1c98bccdf6d255893a4ef295a7 to your computer and use it in GitHub Desktop.
Save boxrick/31da7f1c98bccdf6d255893a4ef295a7 to your computer and use it in GitHub Desktop.
Remote Vagrantfile Test
# Get current role name, and append branch name and build number if set
current_role = File.basename(File.expand_path("..", Dir.pwd))
if ENV['BRANCH_NAME'] && ENV['BUILD_NUMBER']
current_role << "-#{ENV['BRANCH_NAME']}-#{ENV['BUILD_NUMBER']}"
end
Vagrant.configure("2") do |config|
config.vm.define "bionic", primary: true do |bionic|
# Virtualbox provider
bionic.vm.provider "virtualbox" do |v, override|
# Ubuntu Bionic 18.04
override.vm.box = "ubuntu/bionic64"
end
bionic.vm.provider "docker" do |d, override|
# Docker runs as root
override.ssh.username = 'root'
# Systemd needs privileged
d.privileged = true
# Custom image with ssh and systemd inside
# Ubuntu Bionic 18.04
d.image = "boxrick/bionic-docker-ansible"
# We can ssh to this docker image and it stays running forever
d.has_ssh = true
d.remains_running = true
end
end
config.vm.define "xenial", autostart: false do |xenial|
# Virtualbox provider
xenial.vm.provider "virtualbox" do |v, override|
# Ubuntu Xenial 16.04
override.vm.box = "ubuntu/xenial64"
end
# Docker provider
xenial.vm.provider :docker do |d, override|
# Docker runs as root
override.ssh.username = 'root'
# Systemd needs privileged
d.privileged = true
# Custom image with ssh and systemd inside
# Ubuntu Xenial 16.04
d.image = "boxrick/xenial-docker-ansible"
# We can ssh to this docker image and it stays running forever
d.has_ssh = true
d.remains_running = true
end
end
config.vm.define "centos7", autostart: false do |centos7|
# Virtualbox provider
centos7.vm.provider "virtualbox" do |v, override|
# Centos 7
override.vm.box = "centos/7"
end
# Docker provider
centos7.vm.provider :docker do |d, override|
# Docker runs as root
override.ssh.username = 'root'
# Systemd needs privileged
d.privileged = true
# Custom image with ssh and systemd inside
# Centos7
d.image = "boxrick/centos7-docker-ansible"
# We can ssh to this docker image and it stays running forever
d.has_ssh = true
d.remains_running = true
end
end
config.vm.provision "ansible" do |ansible|
# Pull requirements
ansible.galaxy_roles_path = ".vagrant/roles"
#ansible.galaxy_role_file = "requirements.yml"
# Run playbook
ansible.playbook = "test.yml"
# Set verbosity
ansible.verbose = true
# Increase default threads and allow pipelining for speed
ansible.raw_arguments = ['-T 25', '-e pipelining=True']
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment