Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloudinit- terraform #432

Merged
merged 27 commits into from
Oct 29, 2018
Merged

Cloudinit- terraform #432

merged 27 commits into from
Oct 29, 2018

Conversation

MalloZup
Copy link
Contributor

@MalloZup MalloZup commented Sep 25, 2018

Ubuntu 18.04 with cloudinit

TOdos:

  • after discussion on irc would be nice to have a DISK resize to 200G for ubuntu image.

Requirements of this PR:

  • we need the 0.5.0 version of terraform-libvirt-provider in sumaform before merging this.

@MalloZup MalloZup self-assigned this Sep 28, 2018
@MalloZup MalloZup requested a review from moio September 28, 2018 08:19
@MalloZup MalloZup changed the title WIP: Ubuntu cloudinit Cloudinit- terraform Sep 28, 2018
@MalloZup MalloZup changed the title Cloudinit- terraform Cloudinit- terraform Sep 28, 2018
@uyuni-project uyuni-project deleted a comment from moio Oct 2, 2018
@uyuni-project uyuni-project deleted a comment from moio Oct 2, 2018
@MalloZup MalloZup mentioned this pull request Oct 2, 2018
3 tasks
@MalloZup MalloZup changed the title Cloudinit- terraform Wip: Cloudinit- terraform Oct 15, 2018
@MalloZup MalloZup changed the title Wip: Cloudinit- terraform Cloudinit- terraform Oct 17, 2018
# We fetch the latest ubuntu release image from their mirrors
resource "libvirt_volume" "ubuntu-1804_volume" {
name = "${var.name_prefix}ubuntu-1804"
source = "https://cloud-images.ubuntu.com/releases/18.04/release/ubuntu-18.04-server-cloudimg-amd64.img"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can try that out

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be awesome 👍

disable_root: false

# NOTE: This is distro specific.
apt_update: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this silently ignored on platforms that do not support this flag?

Copy link
Contributor Author

@MalloZup MalloZup Oct 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at moment it our SLES images are not using cloudinit, even if we pass it.

To me, i think that when we switch to JEOS/SLES we will need to have 2 different cloudinit files because of the pkg names differs.
Imho this is something that we can postpone and openining an ISSUE as follow-up of this

Copy link
Contributor Author

@MalloZup MalloZup Oct 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not only the pkgs name but i think other things differ so we might have 2 files in case or add a different mechanism to create that. But again imho the JEOS SLES is a big step which might provide lot of work for doing that. ( so i would not design for having the support for jeos right now afaik)



runcmd:
- sed -i '/PermitRootLogin/s/.*/PermitRootLogin yes/' /etc/ssh/sshd_config
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this ssh_pwauth + disable_root?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't work for SLES JEOS.. so we might remove it since is ubuntu specific ( i think should work)

i might also change the name to cloud_init.ubuntu

modules/libvirt/host/main.tf Outdated Show resolved Hide resolved
@@ -10,7 +10,11 @@ include:
minimal_package_update:
pkg.latest:
- pkgs:
{%- if grains['os_family'] == 'Debian' %}
- salt-common
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yop

@uyuni-project uyuni-project deleted a comment from moio Oct 17, 2018
@uyuni-project uyuni-project deleted a comment from moio Oct 17, 2018
@uyuni-project uyuni-project deleted a comment from moio Oct 17, 2018
@@ -23,6 +35,7 @@ resource "libvirt_domain" "domain" {
count = "${var.count}"
qemu_agent = true

cloudinit = "${libvirt_cloudinit_disk.minimalconf.id}"
Copy link
Contributor Author

@MalloZup MalloZup Oct 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moio this works only for ubuntu if we add a sles client

* module.minssh-sles12sp3.libvirt_domain.domain: Resource 'libvirt_cloudinit_disk.minimalconf' not found for variable 'libvirt_cloudinit_disk.minimalconf.id'

any thoughts how is this condition if exists in HCL ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is due because we create it only for ubuntu and it can be that ubuntu hasn't create the disk..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In terraform 0.12 ternary conditions will not evaluate both sides so this becomes a possibility.

For now, I think this will only work if the provider accepts an array, like the network_interface or disk attributes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on the provider cloudinit is not typelist. https://github.com/dmacvicar/terraform-provider-libvirt/blob/c37707c37dd95b2e941888073192eeb69a24c78f/libvirt/resource_libvirt_domain.go#L98

To me the pragmatic way at this time is that we waste a little space ( creating cloudinit.disk) for each image and for terraform v12 we can change this. ( we open an issue as reminder).

Changing the libvirt-provider for such a feature is not worth and will take more time then expected.. 😄

I think comparing back in the time where we create downladed all qcow for all clients, we can tollorate this and user will even don\t remark that.

Just some numbers here:

-rw-r--r-- 1 qemu qemu 364K Oct 17 17:05 sles12sp3_jeos_cloudinit.iso

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slice() or ternary... no if's, it's a declarative language 🙉

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I will ultimately accept this temporarily (until terraform 0.12, or all images really use cloud-init, whichever comes first).

@MalloZup
Copy link
Contributor Author

I think having some kb more is not a pb @moio

@MalloZup
Copy link
Contributor Author

Ping

@moio
Copy link
Contributor

moio commented Oct 19, 2018

Plan is to have a look today

@moio
Copy link
Contributor

moio commented Oct 19, 2018

Travis is broken BTW, please fix it

@MalloZup
Copy link
Contributor Author

MalloZup commented Oct 19, 2018

I cannot fix Travis ( and there is no need to fix it, since is more the rieviw at moment important)

@MalloZup
Copy link
Contributor Author

If I fix travis I need to revert , but before we need agreement

Copy link
Contributor

@Bischoff Bischoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from a few nitpicks (see inline), LGTM.

@@ -46,3 +46,15 @@ module "minion" {
count = 1
// see modules/libvirt/minion/variables.tf for possible values
}

module "min-ubuntu" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the other ones, we have the version embedded:

module "min-sles12sp3" {
module "min-centos7" {

do the same, for example min-ubuntu1804 ?

@@ -11,7 +11,7 @@ resource "libvirt_volume" "centos7_volume" {

resource "libvirt_volume" "opensuse423_volume" {
name = "${var.name_prefix}opensuse423"
source = "https://download.opensuse.org/repositories/systemsmanagement:/sumaform:/images:/libvirt/images/opensuse423.x86_64.qcow2"
source = "http://download.opensuse.org/repositories/systemsmanagement:/sumaform:/images:/libvirt/images/opensuse423.x86_64.qcow2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no https ?

If unrelated to ubuntu but needed, maybe in a different PR...

@@ -72,6 +72,6 @@ variable "bridge" {

variable "images" {
description = "list of images to be uploaded to the libvirt host, leave default for all"
default = ["centos7", "opensuse423", "sles15", "sles11sp4", "sles12", "sles12sp1", "sles12sp2", "sles12sp3", "sles-es7"]
default = ["centos7", "opensuse423", "ubuntu-1804", "sles15", "sles11sp4", "sles12", "sles12sp1", "sles12sp2", "sles12sp3", "sles-es7"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alphabetical order: move it after sles ?

modules/libvirt/host/main.tf Outdated Show resolved Hide resolved
@@ -23,6 +35,7 @@ resource "libvirt_domain" "domain" {
count = "${var.count}"
qemu_agent = true

cloudinit = "${libvirt_cloudinit_disk.minimalconf.id}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slice() or ternary... no if's, it's a declarative language 🙉

type = "pty"
target_type = "virtio"
target_port = "1"
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that one in a separate PR if we get it to work... 😆

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tested on an existing mirror (after the VM has been re-built with this PR code, without changes to the volumes): virsh console works as expected.

@moio
Copy link
Contributor

moio commented Oct 29, 2018

I am not totally happy with this PR, as we currently use different mechanisms for different OSs (custom images without cloud-init and upstream images with cloud-init in libvirt, custom images with cloud-init in openstack, custom images without cloud-init in AWS).

Nevertheless we need this and we have to start somewhere, so I am accepting.

@MalloZup please see the commits I added on top, which among other things address all comments from @Bischoff.

Thanks a lot for getting this off the ground! 🚀

@moio moio merged commit 50c9a4d into uyuni-project:master Oct 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants