Skip to content

Instantly share code, notes, and snippets.

@gavincampbell
Last active February 10, 2022 03:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gavincampbell/a9b920ff7b1c7f3547aeeca46e186050 to your computer and use it in GitHub Desktop.
Save gavincampbell/a9b920ff7b1c7f3547aeeca46e186050 to your computer and use it in GitHub Desktop.
Vagrantfile for SQL Server on Linux with WideWorldImporters sample database and tSQLt framework included
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.network "forwarded_port", guest:1433, host:1433
config.vm.provider :libvirt do |libvirt|
libvirt.memory = "4096"
end
config.vm.provision "shell",
inline: <<-SHELL
yum -y update
curl https://packages.microsoft.com/config/rhel/7/mssql-server.repo > /etc/yum.repos.d/mssql-server.repo
curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/msprod.repo
curl https://github.com/Microsoft/sql-server-samples/releases/download/wide-world-importers-v1.0/WideWorldImporters-Full.bak > /vagrant/DbBackup/WideWorldImporters-Full.bak
yum install -y epel-release
yum install -y tcping
export ACCEPT_EULA=y
yum install -y mssql-server mssql-tools unixODBC-devel
export SA_PASSWORD='Vagrant2017'
/opt/mssql/bin/mssql-conf setup accept-eula
while ! tcping localhost 1433;do sleep 1; done
/opt/mssql-tools/bin/sqlcmd -Usa -PVagrant2017 -i /vagrant/Restore-DB.sql
/opt/mssql-tools/bin/sqlcmd -Usa -PVagrant2017 -dWideWorldImporters -i /vagrant/tSQLt/SetClrEnabled.sql
/opt/mssql-tools/bin/sqlcmd -Usa -PVagrant2017 -dWideWorldImporters -i /vagrant/tSQLt/tSQLt.class.sql
SHELL
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment