-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcyhy_nmap_cloud_init.tf
More file actions
114 lines (104 loc) · 3.84 KB
/
cyhy_nmap_cloud_init.tf
File metadata and controls
114 lines (104 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# cloud-init commands for configuring the cyhy user, setting up the cyhy-runner
# volume, and setting the hostname
data "cloudinit_config" "cyhy_nmap_cloud_init_tasks" {
count = local.nmap_total_instance_count
base64_encode = true
gzip = true
part {
content = templatefile("${path.module}/cloud-init/set_hostname.tpl.yml", {
# Note that the hostname here is identical to what is set in
# the corresponding DNS A record.
fqdn = "portscan${count.index + 1}.${aws_route53_zone.cyhy_private_zone.name}"
hostname = "portscan${count.index + 1}"
})
content_type = "text/cloud-config"
filename = "set_hostname.yml"
merge_type = "list(append)+dict(recurse_array)+str()"
}
part {
content = templatefile("${path.module}/cloud-init/configure_cloudwatch_agent.tpl.yml", {
cloudwatch_agent_log_group_base_name = local.cyhy_cloudwatch_agent_log_group_base
})
content_type = "text/cloud-config"
filename = "configure_cloudwatch_agent.yml"
merge_type = "list(append)+dict(recurse_array)+str()"
}
part {
content = templatefile("${path.module}/cloud-init/chown_directory.tpl.sh", {
group = var.cyhy_user_info.name
is_mount_point = false
owner = var.cyhy_user_info.name
path = var.cyhy_user_info.home
})
content_type = "text/x-shellscript"
filename = "00_cyhy_nmap_chown_cyhy_directory.sh"
}
part {
content = templatefile("${path.module}/cloud-init/chown_directory.tpl.sh", {
group = var.cyhy_user_info.name
is_mount_point = false
owner = var.cyhy_user_info.name
path = "/var/log/cyhy"
})
content_type = "text/x-shellscript"
filename = "00_cyhy_nmap_chown_cyhy_log_directory.sh"
}
part {
content = templatefile("${path.module}/cloud-init/disk_setup.tpl.sh", {
device_name = "/dev/xvdb"
fs_type = "ext4"
label = "cyhy_runner"
mount_options = "defaults"
mount_point = "${var.cyhy_user_info.home}/runner"
num_disks = 2
})
content_type = "text/x-shellscript"
filename = "01_cyhy_runner_disk_setup.sh"
}
part {
content = templatefile("${path.module}/cloud-init/chown_directory.tpl.sh", {
group = var.cyhy_user_info.name
is_mount_point = true
owner = var.cyhy_user_info.name
path = "${var.cyhy_user_info.home}/runner"
})
content_type = "text/x-shellscript"
filename = "02_cyhy_nmap_chown_runner_directory.sh"
}
# Fix the DHCP options in the Canonical Netplan configuration
# created by cloud-init.
#
# The issue is that Netplan uses a default of false for
# dhcp4-overrides.use-domains, and cloud-init does not explicitly
# set this key or provide any way to do so.
#
# See these issues for more details:
# - cisagov/skeleton-packer#300
# - canonical/cloud-init#4764
part {
content = templatefile(
"${path.module}/cloud-init/fix_dhcp.tpl.py", {
netplan_config = "/etc/netplan/50-cloud-init.yaml"
})
content_type = "text/x-shellscript"
filename = "fix_dhcp.py"
merge_type = "list(append)+dict(recurse_array)+str()"
}
# Now that the DHCP options in the Canonical Netplan configuration
# created by cloud-init have been fixed, reapply the Netplan
# configuration.
#
# The issue is that Netplan uses a default of false for
# dhcp4-overrides.use-domains, and cloud-init does not explicitly
# set this key or provide any way to do so.
#
# See these issues for more details:
# - cisagov/skeleton-packer#300
# - canonical/cloud-init#4764
part {
content = file("${path.module}/cloud-init/fix_dhcp.yml")
content_type = "text/cloud-config"
filename = "fix_dhcp.yml"
merge_type = "list(append)+dict(recurse_array)+str()"
}
}