Skip to content

Instantly share code, notes, and snippets.

@sdorsett
Created September 20, 2017 14:48
Show Gist options
  • Save sdorsett/681b27128aefbe85d8860d03dddfbee0 to your computer and use it in GitHub Desktop.
Save sdorsett/681b27128aefbe85d8860d03dddfbee0 to your computer and use it in GitHub Desktop.
Vagrantfile and script files for installing powercli core on Centos 7 vm using vagrant-vcenter provider
#!/bin/bash
cd /tmp/
# install curl from source with openssl support
sudo yum install openssl openssl-devel -y
sudo yum groupinstall "Development Tools" -y
curl -sSL -o curl-7.55.1.tar.gz https://curl.haxx.se/download/curl-7.55.1.tar.gz
tar -zxvf curl-7.55.1.tar.gz
cd curl-7.55.1
./configure --with-ssl=/usr/bin
make
sudo make install
# update path for curl
sudo chmod 775 /etc/ld.so.conf.d
sudo tee /etc/ld.so.conf.d/libcurl.conf << 'EOF'
/usr/local/lib
EOF
sudo chmod 755 /etc/ld.so.conf.d
sudo ldconfig
# install .net
cd /tmp/
sudo yum install libunwind libicu -y
curl -sSL -o dotnet.tar.gz https://go.microsoft.com/fwlink/?LinkID=835019
sudo mkdir -p /opt/dotnet
sudo tar zxf dotnet.tar.gz -C /opt/dotnet
sudo ln -s /opt/dotnet/dotnet /usr/local/bin
# install powershell alpha
yum -y install https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-alpha.14/powershell-6.0.0_alpha.14-1.el7.centos.x86_64.rpm
#!/bin/bash
# install powercli
cd /tmp/
curl -sSL -o PowerCLI_Core.zip https://download3.vmware.com/software/vmw-tools/powerclicore/PowerCLI_Core.zip
yum -y install unzip
mkdir -p ~/.local/share/powershell/Modules
unzip PowerCLI_Core.zip && unzip 'PowerCLI.*.zip' -d ~/.local/share/powershell/Modules
sudo ldconfig
# create powershell script to disable certificate validation and run it
sudo tee ~/set-powercli-config.ps1 << 'EOF'
Get-Module -ListAvailable PowerCLI* | Import-Module
Set-PowerCLIConfiguration -InvalidCertificateAction ignore -confirm:$false
EOF
powershell -f ~/set-powercli-config.ps1
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure('2') do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
config.vm.define :'centos7-powercli' do |m|
m.vm.box = 'standorsett/centos-7'
m.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__args: ["--verbose", "--archive", "--delete", "-z", "--links"]
m.vm.hostname = 'centos7-powercli'
m.vm.provider :vcenter do |vcenter|
vcenter.hostname = '192.168.1.10'
vcenter.username = 'administrator@vsphere.local'
vcenter.password = 'VMware123!'
vcenter.folder_name = 'Vagrant/Deployed'
vcenter.datacenter_name = 'datacenter'
vcenter.computer_name = 'cluster'
vcenter.datastore_name = 'local-datastore'
vcenter.template_folder_name = 'Vagrant/Templates'
vcenter.network_name = 'VM Network'
vcenter.linked_clones = true
vcenter.enable_vm_customization = true
vcenter.num_cpu = 2
vcenter.memory = 4096
end
m.nfs.functional = false
end
config.vm.provision :shell do |shell|
shell.path = "install-powercli-dependencies.sh"
end
config.vm.provision :shell do |shell|
shell.path = "install-powercli.sh"
shell.privileged = false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment