diff --git a/README.md b/README.md index 3324cb0..b27f538 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,10 @@ libvirt provider depends on mkisofs security_driver = none for ubuntu host, link github issue. https://github.com/dmacvicar/terraform-provider-libvirt/issues/546 +Other +---------------------------------------- + +Create a password hash. +```shell +python3 -c 'import crypt; print(crypt.crypt("test", crypt.mksalt(crypt.METHOD_SHA512)))' +``` diff --git a/cloud_init.cfg b/cloud_init.cfg index 10cbe9d..f3ff57c 100644 --- a/cloud_init.cfg +++ b/cloud_init.cfg @@ -1,20 +1,28 @@ #cloud-config # vim: syntax=yaml -# -# *********************** -# ---- for more examples look at: ------ -# ---> https://cloudinit.readthedocs.io/en/latest/topics/examples.html -# ****************************** -# -# This is the configuration syntax that the write_files module -# will know how to understand. encoding can be given b64 or gzip or (gz+b64). -# The content will be decoded accordingly and then written to the path that is -# provided. -# -# Note: Content strings here are truncated for example purposes. -ssh_pwauth: True + +users: + - name: admin + # If we don't supress the user group then cloud init will fail because there + # is allready an admin group in the ubuntu base image. + no_user_group: true + groups: users, admin, sudo + shell: /usr/bin/bash + sudo: ALL=(ALL) NOPASSWD:ALL + ssh_authorized_keys: + - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDfDcjMFmWd6qy9KIlnIHNbEfeNLHC885UUH3jGwESmMTpFfPUn01t9hq5GGaFDrBR55VgdKebAv2JSVl209+r3tE5XxUX5/s2Pu3o2283PiZhA+D18skL7fzaolygOY8mxi9CZSDFia//lLbqT/OE45VGahVBRtda4gmjrade0XRKqjJUCkIo6huG9Ub6yP4gFtFU/C1rRvQo0hqT/imsMYU0Q5XzrKVWv3CpzA7EIQq8llU0fRGMuXWYYOXznPeqqf5BTbWhMWUXVS0o7Cz+zvbxwq1dOR1qHbJ8Vrkt30Cz5QEd159dIM3LHCtOHnveeOpkFo0RqkhQdpZM+2cKzESvivGNGP9h+PrSjcveADxVwDHcxguumUyM012M3yR8cK9KY+GqW5jPdAs13yXGTG4OWiQKeKEgX910l/FndhQi0tSpSEhIlfcEpa3k3P8RrhKJbwiRgR7Qvus4R/KU+lxKOiOr4RKyPQJobC0i0/bvqkw+UHWp4U0Hqivjsb6k= admin + - name: root + ssh_authorized_keys: + - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDfDcjMFmWd6qy9KIlnIHNbEfeNLHC885UUH3jGwESmMTpFfPUn01t9hq5GGaFDrBR55VgdKebAv2JSVl209+r3tE5XxUX5/s2Pu3o2283PiZhA+D18skL7fzaolygOY8mxi9CZSDFia//lLbqT/OE45VGahVBRtda4gmjrade0XRKqjJUCkIo6huG9Ub6yP4gFtFU/C1rRvQo0hqT/imsMYU0Q5XzrKVWv3CpzA7EIQq8llU0fRGMuXWYYOXznPeqqf5BTbWhMWUXVS0o7Cz+zvbxwq1dOR1qHbJ8Vrkt30Cz5QEd159dIM3LHCtOHnveeOpkFo0RqkhQdpZM+2cKzESvivGNGP9h+PrSjcveADxVwDHcxguumUyM012M3yR8cK9KY+GqW5jPdAs13yXGTG4OWiQKeKEgX910l/FndhQi0tSpSEhIlfcEpa3k3P8RrhKJbwiRgR7Qvus4R/KU+lxKOiOr4RKyPQJobC0i0/bvqkw+UHWp4U0Hqivjsb6k= admin + +ssh_pwauth: true +disable_root: false chpasswd: - list: | - root:terraform-libvirt-linux - expire: False + list: + expire: false +# Use this when it's determined that we need a bigger disk image. +# This must be used in conjuction with 'size' in 'libvirt_volume' +# growpart: +# mode: auto +# devices: ['/'] diff --git a/main.tf b/main.tf index a158472..295bcea 100644 --- a/main.tf +++ b/main.tf @@ -1,7 +1,9 @@ terraform { + required_version = ">= 0.13" required_providers { libvirt = { source = "dmacvicar/libvirt" + version = "0.6.11" } } } @@ -16,6 +18,8 @@ resource "libvirt_pool" "images" { path = var.disk-image-dir } +# Add 'size' when we need more space. It must be used in conjuction with +# 'growpart' in cloud-init as well. resource "libvirt_volume" "master-image" { name = "k8s-tf-master" pool = libvirt_pool.images.name @@ -39,10 +43,6 @@ data "template_file" "network_config" { template = file("${path.module}/network_config.cfg") } -# for more info about paramater check this out -# https://github.com/dmacvicar/terraform-provider-libvirt/blob/master/website/docs/r/cloudinit.html.markdown -# Use CloudInit to add our ssh-key to the instance -# you can add also meta_data field resource "libvirt_cloudinit_disk" "commoninit" { name = "commoninit.images" user_data = data.template_file.user_data.rendered