Adding some ansible code
This commit is contained in:
2
ESXi/ansible/ansible.cfg
Normal file
2
ESXi/ansible/ansible.cfg
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
[defaults]
|
||||||
|
inventory = inventory.yml
|
||||||
41
ESXi/ansible/dc/tasks/main.yml
Normal file
41
ESXi/ansible/dc/tasks/main.yml
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Hostname -> DC
|
||||||
|
win_hostname:
|
||||||
|
name: dc
|
||||||
|
register: res
|
||||||
|
|
||||||
|
- name: Reboot
|
||||||
|
win_reboot:
|
||||||
|
when: res.reboot_required
|
||||||
|
|
||||||
|
- name: Install git
|
||||||
|
win_chocolatey:
|
||||||
|
name: git
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Check if existing DetectionLab directory
|
||||||
|
win_stat:
|
||||||
|
path: 'c:\DetectionLab'
|
||||||
|
register: dir
|
||||||
|
|
||||||
|
- name: Git clone Detectionlab
|
||||||
|
win_shell: git clone https://github.com/clong/DetectionLab.git
|
||||||
|
args:
|
||||||
|
chdir: 'c:\'
|
||||||
|
when: not dir.stat.exists
|
||||||
|
|
||||||
|
- name: Copy scripts to c:\vagrant
|
||||||
|
win_shell: Copy-Item -Recurse c:\DetectionLab\Vagrant c:\vagrant
|
||||||
|
|
||||||
|
- name: Provision
|
||||||
|
win_shell: .\\provision.ps1
|
||||||
|
args:
|
||||||
|
chdir: 'c:\vagrant\scripts'
|
||||||
|
|
||||||
|
- name: reboot server
|
||||||
|
win_reboot:
|
||||||
|
msg: "Installing AD. Rebooting..."
|
||||||
|
pre_reboot_delay: 15
|
||||||
|
reboot_timeout: 600
|
||||||
|
post_reboot_delay: 420
|
||||||
4
ESXi/ansible/detectionlab.yml
Normal file
4
ESXi/ansible/detectionlab.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
- hosts: dc
|
||||||
|
roles:
|
||||||
|
- dc
|
||||||
6
ESXi/ansible/group_vars/all.yml
Normal file
6
ESXi/ansible/group_vars/all.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
ansible_user: vagrant
|
||||||
|
ansible_password: vagrant
|
||||||
|
ansible_port: 5985
|
||||||
|
ansible_connection: winrm
|
||||||
|
ansible_winrm_transport: basic
|
||||||
|
ansible_winrm_server_cert_validation: ignore
|
||||||
4
ESXi/ansible/inventory.yml
Normal file
4
ESXi/ansible/inventory.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
dc:
|
||||||
|
hosts:
|
||||||
|
192.168.3.189:
|
||||||
36
ESXi/main.tf
36
ESXi/main.tf
@@ -47,8 +47,14 @@ resource "esxi_guest" "dc" {
|
|||||||
}
|
}
|
||||||
network_interfaces {
|
network_interfaces {
|
||||||
virtual_network = var.nat_network
|
virtual_network = var.nat_network
|
||||||
|
mac_address = "00:50:56:a1:b1:c3"
|
||||||
|
nic_type = "e1000"
|
||||||
|
}
|
||||||
|
network_interfaces {
|
||||||
|
virtual_network = var.hostonly_network
|
||||||
|
mac_address = "00:50:56:a1:b1:c4"
|
||||||
|
nic_type = "e1000"
|
||||||
}
|
}
|
||||||
|
|
||||||
guest_startup_timeout = 45
|
guest_startup_timeout = 45
|
||||||
guest_shutdown_timeout = 30
|
guest_shutdown_timeout = 30
|
||||||
}
|
}
|
||||||
@@ -73,14 +79,20 @@ resource "esxi_guest" "wef" {
|
|||||||
clone_from_vm = "WindowsServer2016"
|
clone_from_vm = "WindowsServer2016"
|
||||||
|
|
||||||
network_interfaces {
|
network_interfaces {
|
||||||
virtual_network = "var.vm_network"
|
virtual_network = var.vm_network
|
||||||
mac_address = "00:50:56:a1:b1:c3"
|
mac_address = "00:50:56:a1:b2:c2"
|
||||||
nic_type = "e1000"
|
nic_type = "e1000"
|
||||||
}
|
}
|
||||||
network_interfaces {
|
network_interfaces {
|
||||||
virtual_network = "var.nat_network"
|
virtual_network = var.nat_network
|
||||||
|
mac_address = "00:50:56:a1:b3:c3"
|
||||||
|
nic_type = "e1000"
|
||||||
|
}
|
||||||
|
network_interfaces {
|
||||||
|
virtual_network = var.hostonly_network
|
||||||
|
mac_address = "00:50:56:a1:b4:c4"
|
||||||
|
nic_type = "e1000"
|
||||||
}
|
}
|
||||||
|
|
||||||
guest_startup_timeout = 45
|
guest_startup_timeout = 45
|
||||||
guest_shutdown_timeout = 30
|
guest_shutdown_timeout = 30
|
||||||
}
|
}
|
||||||
@@ -106,14 +118,20 @@ resource "esxi_guest" "win10" {
|
|||||||
clone_from_vm = "Windows10"
|
clone_from_vm = "Windows10"
|
||||||
|
|
||||||
network_interfaces {
|
network_interfaces {
|
||||||
virtual_network = "var.vm_network"
|
virtual_network = var.vm_network
|
||||||
mac_address = "00:50:56:a1:b1:c4"
|
mac_address = "00:50:56:a2:b1:c2"
|
||||||
nic_type = "e1000"
|
nic_type = "e1000"
|
||||||
}
|
}
|
||||||
network_interfaces {
|
network_interfaces {
|
||||||
virtual_network = "var.nat_network"
|
virtual_network = var.nat_network
|
||||||
|
mac_address = "00:50:56:a2:b1:c3"
|
||||||
|
nic_type = "e1000"
|
||||||
|
}
|
||||||
|
network_interfaces {
|
||||||
|
virtual_network = var.hostonly_network
|
||||||
|
mac_address = "00:50:56:a2:b1:c4"
|
||||||
|
nic_type = "e1000"
|
||||||
}
|
}
|
||||||
|
|
||||||
guest_startup_timeout = 45
|
guest_startup_timeout = 45
|
||||||
guest_shutdown_timeout = 30
|
guest_shutdown_timeout = 30
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,3 +26,7 @@ variable "vm_network" {
|
|||||||
variable "nat_network" {
|
variable "nat_network" {
|
||||||
default = "NAT Network"
|
default = "NAT Network"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "hostonly_network" {
|
||||||
|
default = "HostOnly Network"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user