41 lines
774 B
HCL
41 lines
774 B
HCL
data "local_file" "ssh_pub_key" {
|
|
filename = "${path.module}/data/id_rsa.pub"
|
|
}
|
|
|
|
locals {
|
|
common_cloud_init = <<EOF
|
|
#cloud-config
|
|
chpasswd:
|
|
list: |
|
|
ubuntu:ubuntu
|
|
${var.username}:${var.username}
|
|
expire: false
|
|
packages:
|
|
- qemu-guest-agent
|
|
- nfs-common
|
|
- avahi-daemon
|
|
timezone: America/Vancouver
|
|
|
|
users:
|
|
- default
|
|
- name: ubuntu
|
|
groups: sudo
|
|
shell: /bin/bash
|
|
ssh-authorized-keys:
|
|
- ${trimspace(data.local_file.ssh_pub_key.content)}
|
|
sudo: ALL=(ALL) NOPASSWD:ALL
|
|
- name: ${var.username}
|
|
groups: sudo
|
|
shell: /bin/bash
|
|
ssh_import_id:
|
|
- ${var.ssh_import_id}
|
|
sudo: ALL=(ALL) NOPASSWD:ALL
|
|
|
|
power_state:
|
|
delay: now
|
|
mode: reboot
|
|
message: Rebooting after cloud-init completion
|
|
condition: true
|
|
EOF
|
|
}
|