mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-09 05:44:23 +00:00
Added terraform cloud-init example
This commit is contained in:
45
terraform/multi-part cloud-init/data.tf
Normal file
45
terraform/multi-part cloud-init/data.tf
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# https://registry.terraform.io/providers/hashicorp/cloudinit/latest/docs
|
||||||
|
# https://github.com/chrusty/terraform-multipart-userdata/blob/master/example/cloudinit.tf
|
||||||
|
|
||||||
|
data "cloudinit_config" "azurerm_linux_virtual_machine" {
|
||||||
|
# Disabled only to make the rendered config readable in the outputs.
|
||||||
|
gzip = false
|
||||||
|
base64_encode = false
|
||||||
|
|
||||||
|
part {
|
||||||
|
content = file("${path.module}/files/base.yaml")
|
||||||
|
content_type = "text/cloud-config"
|
||||||
|
filename = "base"
|
||||||
|
}
|
||||||
|
|
||||||
|
# part {
|
||||||
|
# content = file("${path.module}/templates/n-th.yaml")
|
||||||
|
# content_type = "text/cloud-config"
|
||||||
|
# merge_type = "dict(recurse_array,no_replace)+list(append)"
|
||||||
|
# filename = "n-th.yaml"
|
||||||
|
# }
|
||||||
|
}
|
||||||
|
|
||||||
|
data "cloudinit_config" "oci_core_instance" {
|
||||||
|
# Disabled only to make the rendered config readable in the outputs.
|
||||||
|
gzip = false
|
||||||
|
base64_encode = false
|
||||||
|
|
||||||
|
part {
|
||||||
|
content = file("${path.module}/files/base.yaml")
|
||||||
|
content_type = "text/cloud-config"
|
||||||
|
filename = "base"
|
||||||
|
}
|
||||||
|
|
||||||
|
part {
|
||||||
|
content = templatefile(
|
||||||
|
"${path.module}/templates/boinc-client.oci-core-instance.yaml.tftpl",
|
||||||
|
{
|
||||||
|
user = "opc"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
content_type = "text/cloud-config"
|
||||||
|
merge_type = "dict(recurse_array,no_replace)+list(append)"
|
||||||
|
filename = "n-th.yaml"
|
||||||
|
}
|
||||||
|
}
|
||||||
4
terraform/multi-part cloud-init/files/base.yaml
Normal file
4
terraform/multi-part cloud-init/files/base.yaml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#cloud-config
|
||||||
|
|
||||||
|
package_reboot_if_required: false
|
||||||
|
package_upgrade: false
|
||||||
12
terraform/multi-part cloud-init/main.tf
Normal file
12
terraform/multi-part cloud-init/main.tf
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# resource "azurerm_linux_virtual_machine" "vm" {
|
||||||
|
# user_data = data.cloudinit_config.azurerm_linux_virtual_machine.rendered
|
||||||
|
# …
|
||||||
|
# }
|
||||||
|
|
||||||
|
# resource "oci_core_instance" "instance" {
|
||||||
|
# …
|
||||||
|
# metadata = {
|
||||||
|
# …
|
||||||
|
# user_data = data.cloudinit_config.oci_core_instance.rendered
|
||||||
|
# }
|
||||||
|
# }
|
||||||
7
terraform/multi-part cloud-init/outputs.tf
Normal file
7
terraform/multi-part cloud-init/outputs.tf
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
output "cloudinit_config_azurerm_linux_virtual_machine" {
|
||||||
|
value = data.cloudinit_config.azurerm_linux_virtual_machine.rendered
|
||||||
|
}
|
||||||
|
|
||||||
|
output "cloudinit_config_oci_core_instance" {
|
||||||
|
value = data.cloudinit_config.oci_core_instance.rendered
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#cloud-config
|
||||||
|
|
||||||
|
packages:
|
||||||
|
- boinc-client
|
||||||
|
|
||||||
|
# Something about user ${user}
|
||||||
Reference in New Issue
Block a user