-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from CiscoDevNet/dev
CSR1000v 17.2 support and Day0 configuration support
- Loading branch information
Showing
9 changed files
with
146 additions
and
37 deletions.
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,54 @@ | ||
resource "template_dir" "cloudinit" { | ||
for_each = var.device_list | ||
source_dir = var.cloudinit_path | ||
destination_dir = "${path.cwd}/ISO/${each.key}" | ||
|
||
vars = { | ||
ipv4_address = lookup(each.value, "ipv4_address", "dhcp") | ||
ipv4_gateway = lookup(each.value, "ipv4_gateway", "") | ||
day0 = lookup(each.value, "day0", "") | ||
otp = lookup(each.value, "otp", "") | ||
vbond = lookup(each.value, "vbond", "") | ||
uuid = lookup(each.value, "uuid", "") | ||
org = lookup(each.value, "org", "") | ||
} | ||
} | ||
|
||
resource "null_resource" "iso" { | ||
for_each = var.device_list | ||
|
||
triggers = { | ||
cloudinit = fileexists("${var.cloudinit_path}/ciscosdwan_cloud_init.cfg") ? filemd5("${var.cloudinit_path}/ciscosdwan_cloud_init.cfg") : "" | ||
data_dir = "${path.cwd}/ISO/${each.key}" | ||
iso_file = "${path.cwd}/ISO/${each.key}.iso" | ||
} | ||
|
||
provisioner "local-exec" { | ||
command = "mkisofs -output ${self.triggers.iso_file} -volid cidata -joliet -rock ${self.triggers.data_dir}/ciscosdwan_cloud_init.cfg" | ||
} | ||
|
||
# Requires terraform 0.12.23+ for issue #24139 fix (for_each destroy provisioner in module) | ||
provisioner "local-exec" { | ||
when = destroy | ||
command = "rm ${self.triggers.iso_file}" | ||
on_failure = continue | ||
} | ||
|
||
depends_on = [ | ||
template_dir.cloudinit | ||
] | ||
} | ||
|
||
resource "vsphere_file" "iso" { | ||
for_each = var.device_list | ||
|
||
datacenter = var.datacenter | ||
datastore = var.iso_datastore | ||
source_file = "${path.cwd}/ISO/${each.key}.iso" | ||
destination_file = "${var.iso_path}/${var.folder}/${each.key}.iso" | ||
|
||
depends_on = [ | ||
null_resource.iso, | ||
template_dir.cloudinit | ||
] | ||
} |
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
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,50 @@ | ||
%{ if day0 != "" }${day0}%{ else } | ||
Content-Type: multipart/mixed; boundary="===============3067523750048488884==" | ||
MIME-Version: 1.0 | ||
|
||
--===============3067523750048488884== | ||
Content-Type: text/cloud-config; charset="us-ascii" | ||
MIME-Version: 1.0 | ||
Content-Transfer-Encoding: 7bit | ||
Content-Disposition: attachment; filename="cloud-config" | ||
|
||
#cloud-config | ||
vinitparam: | ||
%{ if otp != "" }- otp : ${otp}%{ else }- otp : none%{ endif } | ||
%{ if vbond != "" }- vbond : ${vbond}%{ else }- vbond : 1.1.1.1%{ endif } | ||
%{ if uuid != "" }- uuid : ${uuid}%{ else }- uuid : none%{ endif } | ||
%{ if org != "" }- org : ${org}%{ else }- org : none%{ endif } | ||
|
||
--===============3067523750048488884== | ||
Content-Type: text/cloud-boothook; charset="us-ascii" | ||
MIME-Version: 1.0 | ||
Content-Transfer-Encoding: 7bit | ||
Content-Disposition: attachment; filename="config-CSR-725caea2-41a4-497c-821d-a2e280be40a0.txt" | ||
|
||
#cloud-boothook | ||
|
||
hostname | ||
logging persistent immediate filesize 8192 size 1000000 | ||
aaa authentication login default local | ||
aaa authorization exec default local none | ||
interface GigabitEthernet1 | ||
%{ if ipv4_address != "dhcp" }ip address ${ipv4_address}%{ else }ip address dhcp%{ endif } | ||
no shutdown | ||
exit | ||
%{ if ipv4_gateway != "" }ip route 0.0.0.0 0.0.0.0 ${ipv4_gateway}%{ else }!%{ endif } | ||
username admin privilege 15 secret 0 admin | ||
service password-encryption | ||
crypto key generate rsa label ssh-key modulus 2048 | ||
ip ssh version 2 | ||
ip ssh rsa keypair-name ssh-key | ||
ip tcp window-size 8192 | ||
ip ssh window-size 8192 | ||
line vty 0 20 | ||
transport input ssh | ||
exit | ||
ip domain | ||
ip scp server enable | ||
line bty 0 4 | ||
login local | ||
transport input ssh | ||
%{ endif } |
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
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