Monday, January 24, 2022

Windows-11 + Vagrant + Hyper-V + Ubuntu-20.04 + KVM + CentOS-8.2

   - in this blog-post :

I'm installing Vagrant in Windows 11 ;

With Vagrant I'm creating and starting a VM in Hyper-V ;

In Hyper-V : I'm installing Ubuntu-20.04

In Ubuntu with KVM , QEMU and Libvirt : 

    - I'm playing with 3 CentOS-8.2 boxes .


Enable Hyper-V and Install Vagrant on Windows 10|11:

https://computingforgeeks.com/enable-hyper-v-and-install-vagrant-in-windows/

<<

Ensure you are running Powershell as Administrator:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

Enable-WindowsOptionalFeature -Online -FeatureName "SMB1Protocol" -All

>>


Downlolad and install Vagrant :

https://www.vagrantup.com/downloads

https://releases.hashicorp.com/vagrant/2.2.19/vagrant_2.2.19_x86_64.msi

https://releases.hashicorp.com/vagrant/2.2.19/vagrant_2.2.19_i686.msi



After reboot - adding our ( Ubuntu ) Vagrant Box into Hyper-V :

( Ensure you are still running Powershell as Administrator ) 


PS C:\Windows\system32>

PS C:\Windows\system32> vagrant init generic/ubuntu2004

A `Vagrantfile` has been placed in this directory. You are now

ready to `vagrant up` your first virtual environment! Please read

the comments in the Vagrantfile as well as documentation on

`vagrantup.com` for more information on using Vagrant.

PS C:\Windows\system32>

PS C:\Windows\system32>

PS C:\Windows\system32> vagrant up --provider hyperv

Bringing machine 'default' up with 'hyperv' provider...

==> default: Verifying Hyper-V is enabled...

==> default: Verifying Hyper-V is accessible...

==> default: Box 'generic/ubuntu2004' could not be found. Attempting to find and install...

default: Box Provider: hyperv

default: Box Version: >= 0

==> default: Loading metadata for box 'generic/ubuntu2004'

default: URL: https://vagrantcloud.com/generic/ubuntu2004

==> default: Adding box 'generic/ubuntu2004' (v3.6.4) for provider: hyperv

Downloading:

https://vagrantcloud.com/generic/boxes/ubuntu2004/versions/3.6.4/providers/hyperv.box

default: Calculating and comparing box checksum...

==> default: Successfully added box 'generic/ubuntu2004' (v3.6.4) for 'hyperv'!

==> default: Importing a Hyper-V instance

default: Creating and registering the VM...

default: Successfully imported VM

default: Configuring the VM...

default: Setting VM Enhanced session transport type to disabled/default (VMBus)

==> default: Starting the machine...

==> default: Waiting for the machine to report its IP address...

default: Timeout: 120 seconds

default: IP: 172.23.90.135

==> default: Waiting for machine to boot. This may take a few minutes...

default: SSH address: 172.23.90.135:22

default: SSH username: vagrant

default: SSH auth method: private key

default:

default: Vagrant insecure key detected. Vagrant will automatically replace

default: this with a newly generated keypair for better security.

default:

default: Inserting generated public key within guest...

default: Removing insecure key from the guest if it's present...

default: Key inserted! Disconnecting and reconnecting using new SSH key...

==> default: Machine booted and ready!

PS C:\Windows\system32>






PS C:\Windows\system32>

PS C:\Windows\system32> vagrant status

Current machine states:

              default running (hyperv)

PS C:\Windows\system32>

PS C:\Windows\system32>

PS C:\Windows\system32> vagrant ssh default

vagrant@ubuntu2004:~$

vagrant@ubuntu2004:~$ sudo su -

root@ubuntu2004:~#

root@ubuntu2004:~# cat /etc/*rele*

DISTRIB_ID=Ubuntu

DISTRIB_RELEASE=20.04

DISTRIB_CODENAME=focal

DISTRIB_DESCRIPTION="Ubuntu 20.04.3 LTS"

NAME="Ubuntu"

VERSION="20.04.3 LTS (Focal Fossa)"

ID=ubuntu

ID_LIKE=debian

PRETTY_NAME="Ubuntu 20.04.3 LTS"

VERSION_ID="20.04"

HOME_URL="https://www.ubuntu.com/"

SUPPORT_URL="https://help.ubuntu.com/"

BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"

PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"

VERSION_CODENAME=focal

UBUNTU_CODENAME=focal

root@ubuntu2004:~#


root@ubuntu2004:~# sudo apt update && sudo apt -y upgrade

root@ubuntu2004:~# apt install -y qemu-kvm libvirt-daemon-system bridge-utils genisoimage

root@ubuntu2004:~# systemctl status libvirtd

root@ubuntu2004:~# apt install libguestfs-tools libguestfs-xfs virt-top


root@ubuntu2004:~# apt install sshpass

root@ubuntu2004:~# apt install net-tools

root@ubuntu2004:~# apt install virtinst


# uncomment user & group "root" & restart libvirtd service : 

root@ubuntu2004:~# cat /etc/libvirt/qemu.conf | grep root

# By default libvirt runs VMs as non-root and uses AppArmor profiles

# root, /dev/vhost-net, /dev/vhost-vsock and /dev/vhost-scsi access is

# running as root would have direct access to this file. If changing this

# to run as root, you may want to remove this access from

user = "root"

group = "root"

# Minimum must be greater than 0, however when QEMU is not running as root,

# and uses; alternative is 'root'

root@ubuntu2004:~#

root@ubuntu2004:~# systemctl restart libvirtd


root@ubuntu2004:~/kvm# pwd

/root/kvm

root@ubuntu2004:~/kvm#


# virt-builder -l

# export LIBGUESTFS_BACKEND=direct


# virt-builder centos-8.2 --format qcow2 --size 12G \

   -o centos82a.qcow2 --root-password password


# virt-builder centos-8.2 --format qcow2 \

   -o centos82b.qcow2 --root-password password


# qemu-img resize /root/kvm/centos82b.qcow2 12G



root@ubuntu2004:~/kvm# virt-builder centos-8.2 \


            --format qcow2 --size 
12G -o centos82c.qcow2 \

            --root-password password

[   3.3] Downloading: http://builder.libguestfs.org/centos-8.2.xz

[   7.4] Planning how to build this image

[   7.4] Uncompressing

[  35.6] Resizing (using virt-resize) to expand the disk to 12.0G

[ 165.0] Opening the new disk

[ 185.1] Setting a random seed

[ 185.3] Setting passwords

[ 195.2] Finishing off

Output file: centos82c.qcow2

Output size: 12.0G

Output format: qcow2

Total usable space: 11.3G

Free space: 9.9G (87%)

root@ubuntu2004:~/kvm#

root@ubuntu2004:~/kvm#


root@ubuntu2004:~/kvm# 

     virt-install --name centos82a --ram 1024 \

                  --disk path=/root/kvm/centos82a.qcow2 \

                  --vcpus 1 --os-type linux --os-variant centos8 \

                  --network bridge=virbr0 --graphics none \

                  --serial pty --console pty --boot hd --import


# virt-install --name centos82b --ram 2048 \

               --disk path=/root/kvm/centos82b.qcow2 \

               --vcpus 2 --os-type linux --os-variant centos8 \

               --network bridge=virbr0 --graphics none \

               --serial pty --console pty --boot hd –import


#  virsh setmaxmem centos82b 8G

#  virsh setmem centos82b 6G --config


root@ubuntu2004:~/kvm# virt-install --name centos82c --ram 2048 \

      --disk path=/root/kvm/centos82c.qcow2 --vcpus 2 \

      --os-type linux --os-variant centos8 --network bridge=virbr0 \

      --graphics none --serial pty --console pty --boot hd --import




CentOS Linux 8 (Core)

Kernel 4.18.0-193.6.3.el8_2.x86_64 on an x86_64


localhost login: root

[root@localhost ~]#

[root@localhost ~]# passwd root



root@ubuntu2004:~#

root@ubuntu2004:~# arp -n

Address HWtype HWaddress Flags Mask Iface

172.23.80.1 ether 00:15:5d:36:52:16 C eth0

192.168.122.197 ether 52:54:00:5d:75:91 C virbr0

root@ubuntu2004:~#

root@ubuntu2004:~#


root@ubuntu2004:~# virsh start centos82b

Domain centos82b started


root@ubuntu2004:~# virsh shutdown centos82b

Domain centos82b is being shutdown



root@ubuntu2004:~#

root@ubuntu2004:~# virsh list --all

Id Name State

----------------------------

1 centos82c running

- centos82a shut off

- centos82b shut off


root@ubuntu2004:~#

root@ubuntu2004:~#

root@ubuntu2004:~# ssh root@192.168.122.197

The authenticity of host '192.168.122.197 (192.168.122.197)' can't be established.

ECDSA key fingerprint is SHA256:LAo3p2USa4Dmy5F3nTpkX7Uugs7ElZVhgb6Oh5ZJO+8.

Are you sure you want to continue connecting (yes/no/[fingerprint])? yes

Warning: Permanently added '192.168.122.197' (ECDSA) to the list of known hosts.

root@192.168.122.197's password:

Last login: Mon Jan 24 16:10:00 2022

[root@localhost ~]#

[root@localhost ~]# logout

Connection to 192.168.122.197 closed.

root@ubuntu2004:~#

root@ubuntu2004:~#

root@ubuntu2004:~# sshpass -p"toor" ssh root@192.168.122.197

Last login: Mon Jan 24 16:13:15 2022 from 192.168.122.1

[root@localhost ~]#


[root@localhost ~]# cat /etc/*rele*

CentOS Linux release 8.2.2004 (Core)

Derived from Red Hat Enterprise Linux 8.2 (Source)

NAME="CentOS Linux"

VERSION="8 (Core)"

ID="centos"

ID_LIKE="rhel fedora"

VERSION_ID="8"

PLATFORM_ID="platform:el8"

PRETTY_NAME="CentOS Linux 8 (Core)"

ANSI_COLOR="0;31"

CPE_NAME="cpe:/o:centos:centos:8"

HOME_URL="https://www.centos.org/"

BUG_REPORT_URL="https://bugs.centos.org/"


CENTOS_MANTISBT_PROJECT="CentOS-8"

CENTOS_MANTISBT_PROJECT_VERSION="8"

REDHAT_SUPPORT_PRODUCT="centos"

REDHAT_SUPPORT_PRODUCT_VERSION="8"


CentOS Linux release 8.2.2004 (Core)

CentOS Linux release 8.2.2004 (Core)

cpe:/o:centos:centos:8

[root@localhost ~]#




KVM on CentOS-7.5

https://www.server-world.info/en/note?os=CentOS_7&p=kvm&f=1

https://www.server-world.info/en/note?os=CentOS_7&p=kvm&f=2

https://www.server-world.info/en/note?os=CentOS_7&p=kvm&f=4

https://www.server-world.info/en/note?os=CentOS_7&p=kvm&f=9


Other nice KVM articles :

https://ostechnix.com/manage-kvm-virtual-machines-with-virsh-program/

https://ostechnix.com/how-to-find-the-ip-address-of-a-kvm-virtual-machine/

https://libguestfs.org/virt-builder.1.html

https://yping88.medium.com/building-and-installing-terraform-provider-for-libvirt-a08a29f93135

https://yping88.medium.com/provisioning-multiple-linux-distributions-using-terraform-provider-for-libvirt-632186f1c007

https://blog.programster.org/kvm-cheatsheet

https://linux.goffinet.org/administration/virtualisation-linux/virtualisation-kvm/


Monday, January 10, 2022

PostgreSQL Patroni HAProxy ViP

High Availability and Automatic Failover in PostgreSQL on Kubernetes, On-premise and Cloud

https://www.youtube.com/watch?v=97rwCskemXo&list=PLWhC0zeznqknTPmcSrKmnV75Zr3QLfq7e&index=28


HAProxy can be configured to check via Patroni api who is the new master after a switchover : 
below picture is from above video at minute 26:23




Same ideea of a Load Balancer who uses health checks in order to find the master ==>> 

Design A Highly Available PostgreSQL Cluster With Patroni In GCP — Part 1 : 

<<
Do we need HA Proxy:
To use Patroni, we need at least 3 nodes. In case of failover, we need some Virtual(or floating) IP address to make the application continue to access the database. To reduce this dependency, the HA proxy will always talk to the master node. Here is how HA proxy knows who is the master. In HA proxy, we need to give health check port. 8008 is the default Patroni rest API port. HA proxy will send a GET Request to all the nodes in the cluster in 8008 port. Only the Master node will give 200 OK status. Other nodes will return 503 Server Unavailable.
>>

Alternative to HAProxy is  ViP-Manager : 
https://github.com/cybertec-postgresql/vip-manager

Saturday, January 8, 2022

Using Vagrant for Windows VMs provisioning

Using Vagrant for Windows VMs provisioning - Dots and Brackets: Code Blog

https://codeblog.dotsandbrackets.com/vagrant-windows/


https://app.vagrantup.com/mwrock

"mwrock/windows2016"


Vagrant.configure("2") do |config|

  config.vm.box = "mwrock/windows2016"

  config.vm.hostname = "host-win"

  winClientIP = "192.168.99.103"

  config.vm.network "private_network", ip: winClientIP

end



https://app.vagrantup.com/mwrock/boxes/Windows2016

Vagrantfile

Vagrant.configure("2") do |config|

  config.vm.box = "mwrock/Windows2016"

end


vagrant init mwrock/Windows2016

vagrant up



https://app.vagrantup.com/StefanScherer/boxes/windows_2019

"StefanScherer/windows_2019"


Vagrantfile

Vagrant.configure("2") do |config|

  config.vm.box = "StefanScherer/windows_2019"

end


vagrant init StefanScherer/windows_2019

vagrant up


Windows Server 2019 Eval with Desktop

Packer templates at :

https://github.com/StefanScherer/packer-windows/releases/tag/2021.05.15



HowTo build Windows 10/11/2016/2019/2022 base Vagrant boxes 

Sunday, March 21, 2021

PostgreSQL High Availability with Patroni and ETCD


Building an Enterprise-Grade PostgreSQL Setup Using Open Source Tools
https://www.percona.com/blog/2018/10/19/postgresql-building-enterprise-grade-setup-with-open-source/
https://www.veritas.com/content/support/en_US/doc/129277259-129955710-0/v129957708-129955710 

Set Up Highly Available PostgreSQL12 Cluster on CentOS, RHEL 8
https://www.techsupportpk.com/2020/02/how-to-create-highly-available-postgresql-cluster-centos-rhel-8.html   

Set Up a Highly Available PostgreSQL12 Cluster on CentOS, RHEL 7   
https://www.techsupportpk.com/2020/02/how-to-create-highly-available-postgresql-cluster-using-patroni-haproxy-centos-rhel-7.html   


The simplest Patroni PostgreSQL HA is with One ETCD instance and Two PostgreSQL ( instances )   https://www.cybertec-postgresql.com/en/patroni-setting-up-a-highly-available-postgresql-cluster/


My favourite Patroni introduction :
https://www.cybertec-postgresql.com/en/postgresql-high-availability-and-patroni-an-introduction/


Nice article about ETCD Cluster : 
https://www.cybertec-postgresql.com/en/introduction-and-how-to-etcd-clusters-for-patroni/


Other useful Links with more information regarding the subject :
https://www.youtube.com/watch?v=FiWZuEVlSLc
https://digitalis.io/blog/postgresql/part1-postgresql-ha-patroni-etcd-haproxy/

https://www.programmersought.com/article/4066235751/

https://www.techsupportpk.com/2020/02/how-to-create-highly-available-postgresql-cluster-centos-rhel-8.html

https://www.alibabacloud.com/blog/how-to-set-up-a-highly-available-postgresql-cluster-using-patroni-on-ubuntu-16-04_594477

https://blog.dbi-services.com/postgresql-high-availabilty-patroni-ectd-haproxy-keepalived/


PostgreSQL Cluster Patroni ETCD
https://www.youtube.com/watch?v=SBRo0l7fc_Q
https://github.com/jamalshahverdiev/vagrant-codes-in-practice/tree/master/vagrant-jenkins-gitlab
   by Jamal Shahverdiev


How to Set Up a High Available PostgreSQL Cluster Using Patroni
https://miro.medium.com/max/1400/1*MKVdFmARn20kBlKcnSx_9w.png
https://medium.com/@neslisah.demirci/how-to-set-up-a-high-available-postgresql-cluster-using-patroni-d7044a754d2f

   - Load Balancing with Primary + Replica - HAProxy
https://github.com/zalando/patroni/blob/master/postgres1.yml
https://github.com/zalando/patroni/blob/master/postgres0.yml

https://dzone.com/articles/managing-high-availability-in-postgresql-part-iii



---

Articles from books : 

---

 - Preventing Split Brain
https://subscription.packtpub.com/book/data/9781838984854/1/ch01lvl1sec09/preventing-split-brain
 - Installing and configuring pgBackRest
https://subscription.packtpub.com/book/data/9781838984854/8/ch08lvl1sec98/installing-and-configuring-pgbackrest

 ( PostgreSQL 12 High Availability Cookbook - Third Edition : By Shaun Thomas - February 2020 ) 

---


PITR on a patroni-pgbackrest stack
https://medium.com/@Gowtham_Raj_Elangovan/pitr-on-a-patroni-pgbackrest-stack-9472846d8559

How to configure a Patroni Cluster to use pgbackrest
https://community.pivotal.io/s/article/How-to-Configure-a-Patroni-Cluster-to-use-pgbackrest?language=en_US

Point-in-time-recovery (PITR) with Patroni
https://community.pivotal.io/s/article/Point-in-time-recovery-PITR-with-Patroni

Q: Is it possible to perform PITR recovery with Patroni using pgBackrest?
A: As of pgBackrest 2.23 and Patroni 1.6.4, it is only possible to perform a PITR if you bootstrap the cluster. 

How to use pgbackrest to bootstrap or add replica to HA Patroni
https://community.pivotal.io/s/article/How-to-Use-pgbackrest-to-bootstrap-or-add-replica-to-HA-Patroni


How to configure a Patroni Cluster to use pgbackrest
https://community.pivotal.io/s/article/How-to-Configure-a-Patroni-Cluster-to-use-pgbackrest

An ultimate guide to upgrading your PostgreSQL installation
https://www.youtube.com/watch?v=CzhVkdnbQBU
https://youtu.be/CzhVkdnbQBU?t=2528
by Ilya Kosmodemiansky

Cluster PostgreSQL mutualisé : les choix techniques Sigma
https://www.sigma.fr/2020/05/26/2-cluster-postgresql-mutualise-les-choix-techniques-sigma/


Sunday, February 28, 2021

PostgreSQL Data ModeL

 

A postgreSQL Data ModeL related to customer's order : 


CREATE TABLE customer (
    c_since timestamp with time zone NOT NULL,
    c_id integer NOT NULL,
    c_w_id integer NOT NULL,
    c_d_id smallint NOT NULL,
    c_payment_cnt smallint NOT NULL,
    c_delivery_cnt smallint NOT NULL,
    c_first character varying(16) NOT NULL,
    c_middle character(2) NOT NULL,
    c_last character varying(16) NOT NULL,
    c_street_1 character varying(20) NOT NULL,
    c_street_2 character varying(20) NOT NULL,
    c_city character varying(20) NOT NULL,
    c_state character(2) NOT NULL,
    c_zip character(9) NOT NULL,
    c_phone character(16) NOT NULL,
    c_credit character(2) NOT NULL,
    c_credit_lim numeric(12,2) NOT NULL,
    c_discount numeric(4,4) NOT NULL,
    c_balance numeric(12,2) NOT NULL,
    c_ytd_payment numeric(12,2) NOT NULL,
    c_data character varying(500) NOT NULL,

    CONSTRAINT customer_i1 PRIMARY KEY (c_w_id, c_d_id, c_id)
);
CREATE UNIQUE INDEX customer_i2 ON customer USING btree (c_w_id, c_d_id, c_last, c_first, c_id);

CREATE TABLE district (
    d_w_id integer NOT NULL,
    d_next_o_id integer NOT NULL,
    d_id smallint NOT NULL,
    d_ytd numeric(12,2) NOT NULL,
    d_tax numeric(4,4) NOT NULL,
    d_name character varying(10) NOT NULL,
    d_street_1 character varying(20) NOT NULL,
    d_street_2 character varying(20) NOT NULL,
    d_city character varying(20) NOT NULL,
    d_state character(2) NOT NULL,
    d_zip character(9) NOT NULL,

    CONSTRAINT district_i1 PRIMARY KEY (d_w_id, d_id)
);

CREATE TABLE history (
    h_date timestamp with time zone NOT NULL,
    h_c_id integer,
    h_c_w_id integer NOT NULL,
    h_w_id integer NOT NULL,
    h_c_d_id smallint NOT NULL,
    h_d_id smallint NOT NULL,
    h_amount numeric(6,2) NOT NULL,
    h_data character varying(24) NOT NULL
);

CREATE TABLE item (
    i_id integer NOT NULL,
    i_im_id integer NOT NULL,
    i_name character varying(24) NOT NULL,
    i_price numeric(5,2) NOT NULL,
    i_data character varying(50) NOT NULL,

    CONSTRAINT item_i1 PRIMARY KEY (i_id)
);

CREATE TABLE new_order (
    no_w_id integer NOT NULL,
    no_o_id integer NOT NULL,
    no_d_id smallint NOT NULL,

    CONSTRAINT new_order_i1 PRIMARY KEY (no_w_id, no_d_id, no_o_id)
);

CREATE TABLE order_line (
    ol_delivery_d timestamp with time zone,
    ol_o_id integer NOT NULL,
    ol_w_id integer NOT NULL,
    ol_i_id integer NOT NULL,
    ol_supply_w_id integer NOT NULL,
    ol_d_id smallint NOT NULL,
    ol_number smallint NOT NULL,
    ol_quantity smallint NOT NULL,
    ol_amount numeric(6,2),
    ol_dist_info character(24),

    CONSTRAINT order_line_i1 PRIMARY KEY (ol_w_id, ol_d_id, ol_o_id, ol_number)
);

CREATE TABLE orders (
    o_entry_d timestamp with time zone NOT NULL,
    o_id integer NOT NULL,
    o_w_id integer NOT NULL,
    o_c_id integer NOT NULL,
    o_d_id smallint NOT NULL,
    o_carrier_id smallint,
    o_ol_cnt smallint NOT NULL,
    o_all_local smallint NOT NULL,

    CONSTRAINT orders_i1 PRIMARY KEY (o_w_id, o_d_id, o_id)
);
CREATE UNIQUE INDEX orders_i2 ON orders USING btree (o_w_id, o_d_id, o_c_id, o_id);

CREATE TABLE stock (
    s_i_id integer NOT NULL,
    s_w_id integer NOT NULL,
    s_ytd integer NOT NULL,
    s_quantity smallint NOT NULL,
    s_order_cnt smallint NOT NULL,
    s_remote_cnt smallint NOT NULL,
    s_dist_01 character(24) NOT NULL,
    s_dist_02 character(24) NOT NULL,
    s_dist_03 character(24) NOT NULL,
    s_dist_04 character(24) NOT NULL,
    s_dist_05 character(24) NOT NULL,
    s_dist_06 character(24) NOT NULL,
    s_dist_07 character(24) NOT NULL,
    s_dist_08 character(24) NOT NULL,
    s_dist_09 character(24) NOT NULL,
    s_dist_10 character(24) NOT NULL,
    s_data character varying(50) NOT NULL,

    CONSTRAINT stock_i1 PRIMARY KEY (s_w_id, s_i_id)
);

CREATE TABLE warehouse (
    w_id integer NOT NULL,
    w_name character varying(10) NOT NULL,
    w_street_1 character varying(20) NOT NULL,
    w_street_2 character varying(20) NOT NULL,
    w_city character varying(20) NOT NULL,
    w_state character(2) NOT NULL,
    w_zip character(9) NOT NULL,
    w_tax numeric(4,4) NOT NULL,
    w_ytd numeric(12,2) NOT NULL,

    CONSTRAINT warehouse_i1 PRIMARY KEY (w_id)
);

https://www.enterprisedb.com/blog/postgresql-tproc-c-benchmarks-postgresql-12-vs-postgresql-13-performance


MS SQLS port 1433


PowersheLL commands for Microsoft SQL Server :  


Get-Service | Where-Object {$_.Name -like "*SQL*"}
gsv | where {$_.Name -like "*SQL*"}



Get-NetTCPConnection | Where-Object {$_.LocalPort -like "143*"}
Test-NetConnection -ComputerName localhost -Port 1433




Monday, February 15, 2021

Install Microsoft SQL Server with PowersheLL DSC

 

Get-Host
Install-Module -Name SqlServerDsc
Get-DscResource -Module SqlServerDsc
New-Item -Path C:\SQL2017 -ItemType Directory
$mountResult = Mount-DiskImage -ImagePath 'C:\vagrant\SQLServer2017-x64-ENU.iso' -PassThru
$volumeInfo = $mountResult | Get-Volume
echo $volumeInfo
$driveInfo = Get-PSDrive -Name $volumeInfo.DriveLetter
echo $driveInfo
Copy-Item -Path ( Join-Path -Path $driveInfo.Root -ChildPath '*' ) -Destination C:\SQL2017\ -Recurse
Dismount-DiskImage -ImagePath 'C:\vagrant\SQLServer2017-x64-ENU.iso'


cd C:\vagrant\scripts\
PS C:\vagrant\scripts\> dir
    Directory: C:\Scripts\MSSQLS
Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        2/14/2021   5:20 AM            627 SQLInstallConfiguration.ps1


. .\SQLInstallConfiguration.ps1
SQLInstall

Start-DscConfiguration -Path C:\Scripts\MSSQLS\SQLInstall -Wait -Force -Verbose
Test-DscConfiguration
Get-Service -Name *SQL*

Get-Command -ModuleName sqlserver


sqlcmd
SELECT @@SERVERNAME
go

SELECT @@VERSION
go


Vagrantfile
Vagrant.configure("2") do |config|
  config.vm.box = "StefanScherer/windows_2019"
  config.vm.network "private_network", ip: "192.168.20.19"
end


SQLServer2017-x64-ENU.iso
   - downloaded from : 
https://www.microsoft.com/en-us/sql-server/sql-server-downloads
https://www.microsoft.com/en-us/evalcenter/evaluate-sql-server-2019

https://www.google.com/search?q=download+Microsoft+Command+Line+Utilities+for+SQL+Server
   Microsoft Command Line Utilities 14.0 for SQL Server
   https://www.microsoft.com/en-us/download/details.aspx?id=53591

About sqlcmd Utility
https://docs.microsoft.com/en-us/sql/tools/sqlcmd-utility?view=sql-server-2017

Download the latest version of sqlcmd Utility
https://go.microsoft.com/fwlink/?linkid=2142258

Download ODBC Driver for SQL Server
https://docs.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-2017

Install SQL Server with PowerShell Desired State Configuration
https://docs.microsoft.com/en-us/sql/database-engine/install-windows/install-sql-server-with-powershell-desired-state-configuration?view=sql-server-ver15