-
Notifications
You must be signed in to change notification settings - Fork 71
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
Cloudinit- terraform #432
Conversation
803b41c
to
3a451ec
Compare
modules/libvirt/base/main.tf
Outdated
# 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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why server
and not minimal
?
http://cloud-images.ubuntu.com/minimal/releases/bionic/release/
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
modules/libvirt/host/cloud_init.cfg
Outdated
|
||
|
||
runcmd: | ||
- sed -i '/PermitRootLogin/s/.*/PermitRootLogin yes/' /etc/ssh/sshd_config |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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
salt/default/minimal.sls
Outdated
@@ -10,7 +10,11 @@ include: | |||
minimal_package_update: | |||
pkg.latest: | |||
- pkgs: | |||
{%- if grains['os_family'] == 'Debian' %} | |||
- salt-common |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have just noticed that salt
is a dependency of salt-minion
on all RPM distros.
https://build.opensuse.org/package/view_file/openSUSE:Factory/salt/salt.spec?expand=1
https://build.opensuse.org/package/view_file/systemsmanagement:saltstack:products:next/salt/salt.spec?expand=1
https://build.opensuse.org/package/view_file/systemsmanagement:saltstack:products:develop/salt/salt.spec?expand=1
And Ubuntu ones:
https://packages.ubuntu.com/bionic/salt-minion
So I would take the chance to remove this completely and leave only salt-minion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yop
modules/libvirt/host/main.tf
Outdated
@@ -23,6 +35,7 @@ resource "libvirt_domain" "domain" { | |||
count = "${var.count}" | |||
qemu_agent = true | |||
|
|||
cloudinit = "${libvirt_cloudinit_disk.minimalconf.id}" |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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..
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 🙉
There was a problem hiding this comment.
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).
I think having some kb more is not a pb @moio |
Ping |
Plan is to have a look today |
Travis is broken BTW, please fix it |
I cannot fix Travis ( and there is no need to fix it, since is more the rieviw at moment important) |
If I fix travis I need to revert , but before we need agreement |
There was a problem hiding this 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.
main.tf.libvirt.example
Outdated
@@ -46,3 +46,15 @@ module "minion" { | |||
count = 1 | |||
// see modules/libvirt/minion/variables.tf for possible values | |||
} | |||
|
|||
module "min-ubuntu" { |
There was a problem hiding this comment.
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
?
modules/libvirt/base/main.tf
Outdated
@@ -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" |
There was a problem hiding this comment.
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...
modules/libvirt/base/variables.tf
Outdated
@@ -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"] |
There was a problem hiding this comment.
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
@@ -23,6 +35,7 @@ resource "libvirt_domain" "domain" { | |||
count = "${var.count}" | |||
qemu_agent = true | |||
|
|||
cloudinit = "${libvirt_cloudinit_disk.minimalconf.id}" |
There was a problem hiding this comment.
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" | ||
} |
There was a problem hiding this comment.
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... 😆
There was a problem hiding this comment.
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.
d499a7c
to
ce0d146
Compare
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! 🚀 |
Ubuntu 18.04 with cloudinit
TOdos:
Requirements of this PR:
0.5.0
version of terraform-libvirt-provider in sumaform before merging this.