Skip to content

Instantly share code, notes, and snippets.

@double16
Last active August 2, 2017 20:49
Show Gist options
  • Save double16/81572c74684c18ace981c21042fbc397 to your computer and use it in GitHub Desktop.
Save double16/81572c74684c18ace981c21042fbc397 to your computer and use it in GitHub Desktop.
Test Vagrant Boxes using Docker
version: 2
jobs:
build:
working_directory: /home/linux-dev-workstation
docker:
- image: pdouble16/vagrant-build-base:latest
user: root
steps:
- checkout
- setup_remote_docker
# The 'test' here is that Vagrant can build the box. We should add more steps after this to ensure the software
# we installed is in working order.
- run:
name: Test Vagrant Up
command: |
vagrant up --provider docker --provision
unless $::virtual == 'docker' {
include virtualbox
package { "kernel-devel-${::kernelrelease}": }
->Exec<| title == 'vboxdrv' |>
}
unless $::virtual == 'docker' {
package { 'docker':
ensure => present,
}
->service { 'docker':
ensure => running,
enable => true,
}
}
override.vm.box = nil
docker.image = "jdeathe/centos-ssh:centos-7-2.2.3"
docker.remains_running = true
config.vm.provider :docker do |docker, override|
override.vm.box = nil
override.vm.allowed_synced_folder_types = :rsync
docker.image = "jdeathe/centos-ssh:centos-7-2.2.3"
docker.name = "linux-dev-workstation"
docker.remains_running = true
docker.has_ssh = true
docker.env = {
:SSH_USER => 'vagrant',
:SSH_SUDO => 'ALL=(ALL) NOPASSWD:ALL',
:LANG => 'en_US.UTF-8',
:LANGUAGE => 'en_US:en',
:LC_ALL => 'en_US.UTF-8',
:SSH_INHERIT_ENVIRONMENT => 'true',
}
# There is no newline after the existing insecure key, so the new key ends up on the same line and breaks SSH
override.ssh.insert_key = false
override.ssh.proxy_command = "docker run -i --rm --link linux-dev-workstation alpine/socat - TCP:linux-dev-workstation:22,retry=3,interval=2"
end
override.vm.allowed_synced_folder_types = :rsync
docker.has_ssh = true
docker.env = {
:SSH_USER => 'vagrant',
:SSH_SUDO => 'ALL=(ALL) NOPASSWD:ALL',
:LANG => 'en_US.UTF-8',
:LANGUAGE => 'en_US:en',
:LC_ALL => 'en_US.UTF-8',
:SSH_INHERIT_ENVIRONMENT => 'true',
}
# There is no newline after the existing insecure key, so the new key ends up on the same line and breaks SSH
override.ssh.insert_key = false
docker.name = "linux-dev-workstation"
override.ssh.proxy_command = "docker run -i --rm --link linux-dev-workstation alpine/socat - TCP:linux-dev-workstation:22,retry=3,interval=2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment