Made sense of terraform's cloud-init temmplate example with docker installation

This commit is contained in:
Michele Cereda
2023-01-18 01:23:35 +01:00
parent 2a1ff4c556
commit 1ebba00b3e
3 changed files with 33 additions and 14 deletions

View File

@@ -12,12 +12,17 @@ data "cloudinit_config" "azurerm_linux_virtual_machine" {
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"
# }
part {
content = templatefile(
"${path.module}/templates/docker-ce.yaml.tftpl",
{
user = "azureuser"
}
)
content_type = "text/cloud-config"
merge_type = "dict(recurse_array,no_replace)+list(append)"
filename = "docker"
}
}
data "cloudinit_config" "oci_core_instance" {
@@ -33,13 +38,13 @@ data "cloudinit_config" "oci_core_instance" {
part {
content = templatefile(
"${path.module}/templates/boinc-client.oci-core-instance.yaml.tftpl",
"${path.module}/templates/docker-ce.yaml.tftpl",
{
user = "opc"
}
)
content_type = "text/cloud-config"
merge_type = "dict(recurse_array,no_replace)+list(append)"
filename = "n-th.yaml"
filename = "docker"
}
}

View File

@@ -1,6 +0,0 @@
#cloud-config
packages:
- boinc-client
# Something about user ${user}

View File

@@ -0,0 +1,20 @@
#cloud-config
packages:
- docker-ce
runcmd:
# Give the user permissions to use Docker without `sudo`ing.
# The 'users' module overrode *both* the SSH keys *and* group assignments in
# previous tests. (┛◉Д◉)┛彡┻━┻
- grep -qE '^docker:' /etc/group && usermod -a -G docker ${user} || true
yum_repos:
docker-ce:
name: Docker CE Stable - $basearch
enabled: true
baseurl: https://download.docker.com/linux/rhel/$releasever/$basearch/stable
priority: 1
gpgcheck: true
gpgkey: https://download.docker.com/linux/rhel/gpg