-
Notifications
You must be signed in to change notification settings - Fork 757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Full support for vmware_esxi provider #210
Open
viris
wants to merge
15
commits into
Orange-Cyberdefense:main
Choose a base branch
from
viris:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
dc6b387
make setup_proxmox.sh executable
fsacer c344a06
fix goad.sh in docs
fsacer 49afc71
add provider files for vmware_esxi
fsacer efe40a5
add setup and checks for vmware_esxi
fsacer a01595e
add vmware_esxi support in goad.sh
fsacer 976831b
add vmware_esxi docs
fsacer f92a187
apply shellcheck fixes
fsacer 1bed72d
enable check for vagrant-env
fsacer 09bbde5
improve documentation
fsacer 58f0368
mention the vagrant account in provisioning
fsacer c36dc58
add ovftool check
fsacer 50a9be1
force good error handling when env is not okay
fsacer 7fba45e
fix env list formatting
fsacer e725831
add a link to check script for ovftool
fsacer 20f1356
add esxi logo to easilly make docs distinguishable
fsacer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export GOAD_VAGRANT_ESXIHOSTNAME='10.10.10.10' | ||
export GOAD_VAGRANT_ESXIUSERNAME='root' | ||
export GOAD_VAGRANT_ESXIPASSWORD='password' | ||
export GOAD_VAGRANT_ESXINETNAT='VM Network' | ||
export GOAD_VAGRANT_ESXINETDOM='GOAD-LAN' | ||
export GOAD_VAGRANT_ESXISTORE='datastore1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
Vagrant.configure("2") do |config| | ||
|
||
# Uncomment this depending on the provider you want to use | ||
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'vmware_esxi' | ||
|
||
# auto-load .env if vagrant-env installed | ||
if Vagrant.has_plugin?("vagrant-env") then | ||
config.env.enable # Enable vagrant-env(.env) | ||
end | ||
|
||
boxes = [ | ||
# windows server 2019 | ||
{ :name => "GOAD-DC01", :ip => "192.168.56.10", :box => "StefanScherer/windows_2019", :box_version => "2021.05.15", :os => "windows"}, | ||
# windows server 2019 | ||
{ :name => "GOAD-DC02", :ip => "192.168.56.11", :box => "StefanScherer/windows_2019", :box_version => "2021.05.15", :os => "windows"}, | ||
# windows server 2019 | ||
{ :name => "GOAD-SRV02", :ip => "192.168.56.22", :box => "StefanScherer/windows_2019", :box_version => "2021.05.15", :os => "windows"}, | ||
] | ||
|
||
# disable rdp forwarded port inherited from StefanScherer box | ||
config.vm.network :forwarded_port, guest: 3389, host: 3389, id: "rdp", auto_correct: true, disabled: true | ||
|
||
# no autoupdate if vagrant-vbguest is installed | ||
if Vagrant.has_plugin?("vagrant-vbguest") then | ||
config.vbguest.auto_update = false | ||
end | ||
|
||
config.vm.boot_timeout = 600 | ||
config.vm.graceful_halt_timeout = 600 | ||
config.winrm.retry_limit = 30 | ||
config.winrm.retry_delay = 10 | ||
|
||
boxes.each do |box| | ||
config.vm.define box[:name] do |target| | ||
# BOX | ||
target.vm.provider :vmware_esxi do |v| | ||
v.esxi_hostname = ENV['GOAD_VAGRANT_ESXIHOSTNAME'] | ||
v.esxi_username = ENV['GOAD_VAGRANT_ESXIUSERNAME'] | ||
v.esxi_password = ENV['GOAD_VAGRANT_ESXIPASSWORD'] | ||
v.esxi_virtual_network = [ ENV['GOAD_VAGRANT_ESXINETNAT'], ENV['GOAD_VAGRANT_ESXINETDOM'] ] | ||
v.guest_numvcpus = '4' | ||
v.guest_memsize = '6000' | ||
v.guest_name = box[:name] | ||
v.esxi_disk_store = ENV['GOAD_VAGRANT_ESXISTORE'] | ||
end | ||
target.vm.box_download_insecure = box[:box] | ||
target.vm.box = box[:box] | ||
if box.has_key?(:box_version) | ||
target.vm.box_version = box[:box_version] | ||
end | ||
|
||
# issues/49 | ||
target.vm.synced_folder '.', '/vagrant', disabled: true | ||
|
||
# OS specific | ||
if box[:os] == "windows" | ||
target.vm.guest = :windows | ||
target.vm.communicator = "winrm" | ||
target.vm.provision :shell, :path => "../../../../vagrant/Install-WMF3Hotfix.ps1", privileged: false | ||
target.vm.provision :shell, :path => "../../../../vagrant/ConfigureRemotingForAnsible.ps1", privileged: false | ||
|
||
# fix ip for vmware | ||
if ENV['VAGRANT_DEFAULT_PROVIDER'] == "vmware_esxi" | ||
target.vm.provision :shell, :path => "../../../../vagrant/fix_ip.ps1", privileged: false, args: box[:ip] | ||
end | ||
|
||
else | ||
target.vm.communicator = "ssh" | ||
end | ||
|
||
if box.has_key?(:forwarded_port) | ||
# forwarded port explicit | ||
box[:forwarded_port] do |forwarded_port| | ||
target.vm.network :forwarded_port, guest: forwarded_port[:guest], host: forwarded_port[:host], host_ip: "127.0.0.1", id: forwarded_port[:id] | ||
end | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
[default] | ||
; Note: ansible_host *MUST* be an IPv4 address or setting things like DNS | ||
; servers will break. | ||
; ------------------------------------------------ | ||
; sevenkingdoms.local | ||
; ------------------------------------------------ | ||
dc01 ansible_host=192.168.56.10 dns_domain=dc01 dict_key=dc01 | ||
; ------------------------------------------------ | ||
; north.sevenkingdoms.local | ||
; ------------------------------------------------ | ||
dc02 ansible_host=192.168.56.11 dns_domain=dc01 dict_key=dc02 | ||
srv02 ansible_host=192.168.56.22 dns_domain=dc02 dict_key=srv02 | ||
|
||
[all:vars] | ||
; domain_name : folder inside ad/ | ||
domain_name=GOAD-Light | ||
|
||
force_dns_server=no | ||
dns_server=x.x.x.x | ||
two_adapters=yes | ||
|
||
; adapter created by vagrant and vmware (uncomment if you use vmware) | ||
nat_adapter=Ethernet0 | ||
domain_adapter=Ethernet1 | ||
|
||
; winrm connection (windows) | ||
ansible_user=vagrant | ||
ansible_password=vagrant | ||
ansible_connection=winrm | ||
ansible_winrm_server_cert_validation=ignore | ||
ansible_winrm_operation_timeout_sec=400 | ||
ansible_winrm_read_timeout_sec=500 | ||
# ansible_winrm_transport=basic | ||
# ansible_port=5985 | ||
|
||
; proxy settings (the lab need internet for some install, if you are behind a proxy you should set the proxy here) | ||
enable_http_proxy=no | ||
ad_http_proxy=http://x.x.x.x:xxxx | ||
ad_https_proxy=http://x.x.x.x:xxxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export GOAD_VAGRANT_ESXIHOSTNAME='10.10.10.10' | ||
export GOAD_VAGRANT_ESXIUSERNAME='root' | ||
export GOAD_VAGRANT_ESXIPASSWORD='password' | ||
export GOAD_VAGRANT_ESXINETNAT='VM Network' | ||
export GOAD_VAGRANT_ESXINETDOM='GOAD-LAN' | ||
export GOAD_VAGRANT_ESXISTORE='datastore1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
Vagrant.configure("2") do |config| | ||
|
||
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'vmware_esxi' | ||
|
||
# auto-load .env if vagrant-env installed | ||
if Vagrant.has_plugin?("vagrant-env") then | ||
config.env.enable # Enable vagrant-env(.env) | ||
end | ||
|
||
boxes = [ | ||
# windows server 2019 | ||
{ :name => "GOAD-DC01", :ip => "192.168.56.10", :box => "StefanScherer/windows_2019", :box_version => "2021.05.15", :os => "windows"}, | ||
# windows server 2019 | ||
{ :name => "GOAD-DC02", :ip => "192.168.56.11", :box => "StefanScherer/windows_2019", :box_version => "2021.05.15", :os => "windows"}, | ||
# windows server 2016 | ||
{ :name => "GOAD-DC03", :ip => "192.168.56.12", :box => "StefanScherer/windows_2016", :box_version => "2017.12.14", :os => "windows"}, | ||
# windows server 2019 | ||
{ :name => "GOAD-SRV02", :ip => "192.168.56.22", :box => "StefanScherer/windows_2019", :box_version => "2020.07.17", :os => "windows"}, | ||
# windows server 2016 | ||
{ :name => "GOAD-SRV03", :ip => "192.168.56.23", :box => "StefanScherer/windows_2016", :box_version => "2019.02.14", :os => "windows"} | ||
] | ||
|
||
if ENV.has_key?('GOAD_VAGRANT_OPTIONS') and ENV['GOAD_VAGRANT_OPTIONS'].include? "elk" | ||
boxes.append( | ||
{ :name => "GOAD-ELK", :ip => "192.168.56.50", :box => "bento/ubuntu-18.04", :os => "linux", :forwarded_port => [ | ||
{:guest => 22, :host => 2210, :id => "ssh"} ] | ||
} | ||
) | ||
end | ||
|
||
# disable rdp forwarded port inherited from StefanScherer box | ||
config.vm.network :forwarded_port, guest: 3389, host: 3389, id: "rdp", auto_correct: true, disabled: true | ||
|
||
# no autoupdate if vagrant-vbguest is installed | ||
if Vagrant.has_plugin?("vagrant-vbguest") then | ||
config.vbguest.auto_update = false | ||
end | ||
|
||
config.vm.boot_timeout = 600 | ||
config.vm.graceful_halt_timeout = 600 | ||
config.winrm.retry_limit = 30 | ||
config.winrm.retry_delay = 10 | ||
|
||
boxes.each do |box| | ||
config.vm.define box[:name] do |target| | ||
# BOX | ||
target.vm.provider :vmware_esxi do |v| | ||
v.esxi_hostname = ENV['GOAD_VAGRANT_ESXIHOSTNAME'] | ||
v.esxi_username = ENV['GOAD_VAGRANT_ESXIUSERNAME'] | ||
v.esxi_password = ENV['GOAD_VAGRANT_ESXIPASSWORD'] | ||
v.esxi_virtual_network = [ ENV['GOAD_VAGRANT_ESXINETNAT'], ENV['GOAD_VAGRANT_ESXINETDOM'] ] | ||
v.guest_numvcpus = '4' | ||
v.guest_memsize = '6000' | ||
v.guest_name = box[:name] | ||
v.esxi_disk_store = ENV['GOAD_VAGRANT_ESXISTORE'] | ||
end | ||
target.vm.box_download_insecure = box[:box] | ||
target.vm.box = box[:box] | ||
if box.has_key?(:box_version) | ||
target.vm.box_version = box[:box_version] | ||
end | ||
|
||
# issues/49 | ||
target.vm.synced_folder '.', '/vagrant', disabled: true | ||
|
||
# OS specific | ||
if box[:os] == "windows" | ||
target.vm.guest = :windows | ||
target.vm.communicator = "winrm" | ||
target.vm.provision :shell, :path => "../../../../vagrant/Install-WMF3Hotfix.ps1", privileged: false | ||
target.vm.provision :shell, :path => "../../../../vagrant/ConfigureRemotingForAnsible.ps1", privileged: false | ||
|
||
# fix ip for vmware | ||
if ENV['VAGRANT_DEFAULT_PROVIDER'] == "vmware_esxi" | ||
target.vm.provision :shell, :path => "../../../../vagrant/fix_ip.ps1", privileged: false, args: box[:ip] | ||
end | ||
|
||
else | ||
target.vm.communicator = "ssh" | ||
end | ||
|
||
if box.has_key?(:forwarded_port) | ||
# forwarded port explicit | ||
box[:forwarded_port] do |forwarded_port| | ||
target.vm.network :forwarded_port, guest: forwarded_port[:guest], host: forwarded_port[:host], host_ip: "127.0.0.1", id: forwarded_port[:id] | ||
end | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
[default] | ||
; Note: ansible_host *MUST* be an IPv4 address or setting things like DNS | ||
; servers will break. | ||
; ------------------------------------------------ | ||
; sevenkingdoms.local | ||
; ------------------------------------------------ | ||
dc01 ansible_host=192.168.56.10 dns_domain=dc01 dict_key=dc01 | ||
;ws01 ansible_host=192.168.56.30 dns_domain=dc01 dict_key=ws01 | ||
; ------------------------------------------------ | ||
; north.sevenkingdoms.local | ||
; ------------------------------------------------ | ||
dc02 ansible_host=192.168.56.11 dns_domain=dc01 dict_key=dc02 | ||
srv02 ansible_host=192.168.56.22 dns_domain=dc02 dict_key=srv02 | ||
; ------------------------------------------------ | ||
; essos.local | ||
; ------------------------------------------------ | ||
dc03 ansible_host=192.168.56.12 dns_domain=dc03 dict_key=dc03 | ||
srv03 ansible_host=192.168.56.23 dns_domain=dc03 dict_key=srv03 | ||
; ------------------------------------------------ | ||
; Other | ||
; ------------------------------------------------ | ||
elk ansible_host=192.168.56.50 ansible_connection=ssh | ||
|
||
[all:vars] | ||
; domain_name : folder inside ad/ | ||
domain_name=GOAD | ||
|
||
force_dns_server=no | ||
dns_server=x.x.x.x | ||
two_adapters=yes | ||
|
||
; adapter created by vagrant and vmware (uncomment if you use vmware) | ||
nat_adapter=Ethernet0 | ||
domain_adapter=Ethernet1 | ||
|
||
; winrm connection (windows) | ||
ansible_user=vagrant | ||
ansible_password=vagrant | ||
ansible_connection=winrm | ||
ansible_winrm_server_cert_validation=ignore | ||
ansible_winrm_operation_timeout_sec=400 | ||
ansible_winrm_read_timeout_sec=500 | ||
# ansible_winrm_transport=basic | ||
# ansible_port=5985 | ||
|
||
; proxy settings (the lab need internet for some install, if you are behind a proxy you should set the proxy here) | ||
enable_http_proxy=no | ||
ad_http_proxy=http://x.x.x.x:xxxx | ||
ad_https_proxy=http://x.x.x.x:xxxx | ||
|
||
[elk_server:vars] | ||
; ssh connection (linux) | ||
ansible_ssh_user=vagrant | ||
ansible_ssh_private_key_file=./.vagrant/machines/elk/virtualbox/private_key | ||
ansible_ssh_port=22 | ||
ansible_ssh_common_args='-o StrictHostKeyChecking=no' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export GOAD_VAGRANT_ESXIHOSTNAME='10.10.10.10' | ||
export GOAD_VAGRANT_ESXIUSERNAME='root' | ||
export GOAD_VAGRANT_ESXIPASSWORD='password' | ||
export GOAD_VAGRANT_ESXINETNAT='VM Network' | ||
export GOAD_VAGRANT_ESXINETDOM='GOAD-LAN' | ||
export GOAD_VAGRANT_ESXISTORE='datastore1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
Vagrant.configure("2") do |config| | ||
|
||
# Uncomment this depending on the provider you want to use | ||
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'vmware_esxi' | ||
|
||
# auto-load .env if vagrant-env installed | ||
if Vagrant.has_plugin?("vagrant-env") then | ||
config.env.enable # Enable vagrant-env(.env) | ||
end | ||
|
||
boxes = [ | ||
{ :name => "NHA-DC01", :ip => "192.168.58.10", :box => "mayfly/windows_server2019", :os => "windows"}, | ||
{ :name => "NHA-DC02", :ip => "192.168.58.20", :box => "mayfly/windows_server2019", :os => "windows"}, | ||
{ :name => "NHA-SRV01", :ip => "192.168.58.21", :box => "mayfly/windows_server2019", :os => "windows"}, | ||
{ :name => "NHA-SRV02", :ip => "192.168.58.22", :box => "mayfly/windows_server2019", :os => "windows"}, | ||
{ :name => "NHA-SRV03", :ip => "192.168.58.23", :box => "mayfly/windows_server2019", :os => "windows"} | ||
] | ||
|
||
# disable forwarded port | ||
config.vm.network "forwarded_port", guest: 3389, host: 3389, id: 'rdp', auto_correct: true, disabled: true | ||
config.vm.network "forwarded_port", guest: 22, host: 2222, id: 'ssh', auto_correct: true, disabled: true | ||
|
||
# no autoupdate if vagrant-vbguest is installed | ||
if Vagrant.has_plugin?("vagrant-vbguest") then | ||
config.vbguest.auto_update = false | ||
end | ||
|
||
config.vm.boot_timeout = 600 | ||
config.vm.graceful_halt_timeout = 600 | ||
config.winrm.retry_limit = 30 | ||
config.winrm.retry_delay = 10 | ||
|
||
boxes.each do |box| | ||
config.vm.define box[:name] do |target| | ||
# BOX | ||
target.vm.provider :vmware_esxi do |v| | ||
v.esxi_hostname = ENV['GOAD_VAGRANT_ESXIHOSTNAME'] | ||
v.esxi_username = ENV['GOAD_VAGRANT_ESXIUSERNAME'] | ||
v.esxi_password = ENV['GOAD_VAGRANT_ESXIPASSWORD'] | ||
v.esxi_virtual_network = [ ENV['GOAD_VAGRANT_ESXINETNAT'], ENV['GOAD_VAGRANT_ESXINETDOM'] ] | ||
v.guest_numvcpus = '4' | ||
v.guest_memsize = '6000' | ||
v.guest_name = box[:name] | ||
v.esxi_disk_store = ENV['GOAD_VAGRANT_ESXISTORE'] | ||
end | ||
target.vm.box_download_insecure = box[:box] | ||
target.vm.box = box[:box] | ||
if box.has_key?(:box_version) | ||
target.vm.box_version = box[:box_version] | ||
end | ||
|
||
# issues/49 | ||
target.vm.synced_folder '.', '/vagrant', disabled: true | ||
|
||
# OS specific | ||
if box[:os] == "windows" | ||
target.vm.guest = :windows | ||
target.vm.communicator = "winrm" | ||
target.vm.provision :shell, :path => "../../../../vagrant/Install-WMF3Hotfix.ps1", privileged: false | ||
target.vm.provision :shell, :path => "../../../../vagrant/ConfigureRemotingForAnsible.ps1", privileged: false | ||
|
||
# fix ip for vmware | ||
if ENV['VAGRANT_DEFAULT_PROVIDER'] == "vmware_esxi" | ||
target.vm.provision :shell, :path => "../../../../vagrant/fix_ip.ps1", privileged: false, args: box[:ip] | ||
end | ||
|
||
else | ||
target.vm.communicator = "ssh" | ||
end | ||
|
||
if box.has_key?(:forwarded_port) | ||
# forwarded port explicit | ||
box[:forwarded_port] do |forwarded_port| | ||
target.vm.network :forwarded_port, guest: forwarded_port[:guest], host: forwarded_port[:host], host_ip: "127.0.0.1", id: forwarded_port[:id] | ||
end | ||
end | ||
|
||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given that the vagrant-env plugin is necessarily installed if you go through goad.sh and that the configuration will be missing if you go through
vagrant up
without the vagrant-env plugin, wouldn't it be better to replace this condition with an error directly if the plugin isn't present? (if this is the case, you'd have to make the change to the other files too)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be, though it's not strictly necessary, I usually sourced the env file manually during testing, but made them compatible with the
vagrant-env
plugin, if env file is not modified and present in environment provisioning will fail anyhow. Maybe this needs to be documented more thoroughly?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking clearer error handling will suffice. Also will add this to docs.