generated from CC/VMServiceTemplate
new vars pass docker compose in cloud init
This commit is contained in:
@@ -4,7 +4,7 @@ resource "proxmox_virtual_environment_file" "cloud_config" {
|
||||
node_name = var.node_name
|
||||
|
||||
source_raw {
|
||||
file_name = "${var.vm_name}_vm.cloud-config.yaml" # The name of the snippet file
|
||||
file_name = "${var.vm_name}_vm.cloud-config.yaml"
|
||||
data = <<-EOF
|
||||
#cloud-config
|
||||
hostname: ${var.vm_name}
|
||||
@@ -19,26 +19,39 @@ resource "proxmox_virtual_environment_file" "cloud_config" {
|
||||
users:
|
||||
- default
|
||||
- name: cloud
|
||||
groups:
|
||||
groups:
|
||||
- sudo
|
||||
- docker
|
||||
shell: /bin/bash
|
||||
ssh-authorized-keys:
|
||||
- "${var.vm_user_sshkey}" # +++ Needs to be put into a variable injected by git actions secrets
|
||||
- "${var.vm_user_sshkey}"
|
||||
sudo: ALL=(ALL) NOPASSWD:ALL
|
||||
|
||||
packages:
|
||||
- qemu-guest-agent
|
||||
- qemu-guest-agent
|
||||
- apt-transport-https
|
||||
- ca-certificates
|
||||
- curl
|
||||
- gnupg
|
||||
- lsb-release
|
||||
- unattended-upgrades
|
||||
- unattended-upgrades
|
||||
- rsync
|
||||
|
||||
write_files:
|
||||
- path: /home/cloud/docker-compose.yml
|
||||
owner: cloud:cloud
|
||||
permissions: '0644'
|
||||
content: |
|
||||
${indent(10, var.compose_file_content)}
|
||||
|
||||
- path: /home/cloud/.env
|
||||
owner: cloud:cloud
|
||||
permissions: '0600'
|
||||
content: |
|
||||
${indent(10, var.env_file_content)}
|
||||
|
||||
runcmd:
|
||||
- systemctl enable qemu-guest-agent
|
||||
- systemctl enable qemu-guest-agent
|
||||
- mkdir -p /etc/apt/keyrings
|
||||
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
||||
- echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||
@@ -46,7 +59,8 @@ resource "proxmox_virtual_environment_file" "cloud_config" {
|
||||
- apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
||||
- systemctl enable docker
|
||||
- systemctl start docker
|
||||
- reboot
|
||||
- chown -R cloud:cloud /home/cloud
|
||||
- [ bash, -c, "cd /home/cloud && docker compose up -d" ]
|
||||
EOF
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
proxmox = {
|
||||
source = "bpg/proxmox"
|
||||
version = "0.106.0"
|
||||
#url = https://registry.terraform.io/providers/bpg/proxmox/latest/docs/guides/clone-vm
|
||||
}
|
||||
aws = {
|
||||
source = "hashicorp/aws"
|
||||
version = "6.38.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -110,7 +110,7 @@ variable "vm_name" {
|
||||
variable "vm_user_sshkey" {
|
||||
description = "Admin user SSH key of the VM"
|
||||
type = string
|
||||
default = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDRlWaLBt/qmWY01Cd6jN/YxLnlT+6lg+evEdN/dIajirdTj1rCbAdlG3WYvo+4BpN17HK3/eGQpGUMbgI/8MVd8YPODcD34gaNX0w2v66BwHx+S6BZUpz5T2IoQT0JtSv/TtFICoff5gXdNRpfd4eWsmTioEqLA6oToJLE4dn3jvAzFi9y7fyLqvuoQMmPidYYJjGT30eiULtXNspoEP+GmuWmVEu+znzMWaKDWKdOsii4Cv1aWCRKSDDRzDBrZI2mP+Vm4HDQBdgDYRw4ehumMDtfaSjyJCnrk691bIM+wxzICuIEecg5kq5HcUPvo2mFyWPAEXb5xlXnuopYEBd7 Generated By NeoServer"
|
||||
default = ""
|
||||
}
|
||||
|
||||
|
||||
@@ -137,4 +137,15 @@ variable "vm_user" {
|
||||
description = "Admin user of the VM"
|
||||
type = string
|
||||
default = "cloud"
|
||||
}
|
||||
|
||||
variable "compose_file_content" {
|
||||
description = "Rendered contents of docker-compose.yml to write to the VM"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "env_file_content" {
|
||||
description = "Rendered contents of .env to write to the VM"
|
||||
type = string
|
||||
sensitive = true
|
||||
}
|
||||
Reference in New Issue
Block a user