Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stgarf/a84a6992a540d45bb0fe9e5da5af16ee to your computer and use it in GitHub Desktop.
Save stgarf/a84a6992a540d45bb0fe9e5da5af16ee to your computer and use it in GitHub Desktop.
Make chef test-kitchen, VirtualBox, Vagrant DNS work over VPN with NAT
  • Testing convering before adding any VirtualBox NAT settings:
$ kitchen list                                                                               20 ↵  2582  13:31:22
Instance          Driver   Provisioner  Verifier  Transport  Last Action  Last Error
default-centos-6  Vagrant  ChefZero     Busser    Ssh        Converged    <None>
default-centos-7  Vagrant  ChefZero     Busser    Ssh        Created      Kitchen::ActionFailed
server-centos-6   Vagrant  ChefZero     Busser    Ssh        Created      Kitchen::ActionFailed
server-centos-7   Vagrant  ChefZero     Busser    Ssh        Created      Kitchen::ActionFailed
proxy-centos-6    Vagrant  ChefZero     Busser    Ssh        Converged    <None>
proxy-centos-7    Vagrant  ChefZero     Busser    Ssh        Created      Kitchen::ActionFailed

Only two of six test kitchen platforms seem to have passed... Okay.

  • Dig up what settings can be set for VirtualBox:
$ VBoxManage modifyvm --help 2>&1 | grep nat
                            [--nic<1-N> none|null|nat|bridged|intnet|hostonly|
                                        generic|natnetwork]
                            [--nat-network<1-N> <network name>]
                            [--natnet<1-N> <network>|default]
                            [--natsettings<1-N> [<mtu>],[<socksnd>],
                            [--natpf<1-N> [<rulename>],tcp|udp,[<hostip>],
                            [--natpf<1-N> delete <rulename>]
                            [--nattftpprefix<1-N> <prefix>]
                            [--nattftpfile<1-N> <file>]
                            [--nattftpserver<1-N> <ip>]
                            [--natbindip<1-N> <ip>
                            [--natdnspassdomain<1-N> on|off]
                            [--natdnsproxy<1-N> on|off]
                            [--natdnshostresolver<1-N> on|off]
                            [--nataliasmode<1-N> default|[log],[proxyonly],
  • Add them to the cookbook in a local override file $HOME/.kitchen/config.yml reference:

A global configuration file will also be looked for in $HOME/.kitchen/config.yml to set preferred defaults for all your projects.

driver:
  name: vagrant
  customize:
    natdnshostresolver1: "on"
    natdnsproxy1: "on"
  • Test converging, kitchen conv:
$ kitchen list
Instance          Driver   Provisioner  Verifier  Transport  Last Action  Last Error
default-centos-6  Vagrant  ChefZero     Busser    Ssh        Converged    <None>
default-centos-7  Vagrant  ChefZero     Busser    Ssh        Converged    <None>
server-centos-6   Vagrant  ChefZero     Busser    Ssh        Converged    <None>
server-centos-7   Vagrant  ChefZero     Busser    Ssh        Converged    <None>
proxy-centos-6    Vagrant  ChefZero     Busser    Ssh        Converged    <None>
proxy-centos-7    Vagrant  ChefZero     Busser    Ssh        Converged    <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment