[pve-devel] [PATCH qemu-server] fix #2068: allow disabling of package_upgrade for cloud-init

Dietmar Maurer dietmar at proxmox.com
Tue Jan 29 16:42:09 CET 2019


CI has hundreds of options, and we should not try to configure all
that stuff with proxmox. This was intentionally left out. 

I think the user should configure such things inside the vm instead.

> On January 29, 2019 at 3:18 PM David Limbeck <d.limbeck at proxmox.com> wrote:
> 
> 
> package_upgrade default is still 'true'. adds a new generic option 'cioptions'
> that takes a list of property strings and is easy to extend. for now only
> 'package_upgrade=<true/false>' is supported. registers a new format
> 'pve-qm-cioptions' for parsing in different files.
> 
> tested with ubuntu 18.10.
> 
> Signed-off-by: David Limbeck <d.limbeck at proxmox.com>
> ---
>  PVE/API2/Qemu.pm            |  1 +
>  PVE/QemuServer.pm           | 18 ++++++++++++++++++
>  PVE/QemuServer/Cloudinit.pm |  4 +++-
>  3 files changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
> index 148ea1a..7fee88e 100644
> --- a/PVE/API2/Qemu.pm
> +++ b/PVE/API2/Qemu.pm
> @@ -295,6 +295,7 @@ my $cloudinitoptions = {
>      cipassword => 1,
>      citype => 1,
>      ciuser => 1,
> +    cioptions => 1,
>      nameserver => 1,
>      searchdomain => 1,
>      sshkeys => 1,
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index bc3bb1d..c5e2309 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -616,6 +616,18 @@ EODESCR
>      },
>  };
>  
> +my $cioptions_fmt = {
> +    package_upgrade => {
> +	type => 'string',
> +	optional => 1,
> +	description => 'cloud-init: Enable/Disable package upgrade on boot.',
> +	default => 'true',
> +	enum => [qw(true false)]
> +    }
> +};
> +
> +PVE::JSONSchema::register_format('pve-qm-cioptions', $cioptions_fmt);
> +
>  my $confdesc_cloudinit = {
>      citype => {
>  	optional => 1,
> @@ -633,6 +645,12 @@ my $confdesc_cloudinit = {
>  	type => 'string',
>  	description => 'cloud-init: Password to assign the user. Using this is generally not recommended. Use ssh keys instead. Also note that older cloud-init versions do not support hashed passwords.',
>      },
> +    cioptions => {
> +	optional => 1,
> +	type => 'string',
> +	format => 'pve-qm-cioptions',
> +	description => 'cloud-init: specify other options that are supported as a list of key=value pairs (e.g. package_upgrade=false,...).'
> +    },
>      searchdomain => {
>  	optional => 1,
>  	type => 'string',
> diff --git a/PVE/QemuServer/Cloudinit.pm b/PVE/QemuServer/Cloudinit.pm
> index 5be820c..5f777a1 100644
> --- a/PVE/QemuServer/Cloudinit.pm
> +++ b/PVE/QemuServer/Cloudinit.pm
> @@ -132,7 +132,9 @@ sub cloudinit_userdata {
>  	$content .= "  - default\n";
>      }
>  
> -    $content .= "package_upgrade: true\n";
> +    my $cioptions = $conf->{cioptions} ? PVE::JSONSchema::parse_property_string('pve-qm-cioptions', $conf->{cioptions}) : {};
> +    my $package_upgrade = $cioptions->{package_upgrade} // 'true'; # default
> +    $content .= "package_upgrade: $package_upgrade\n";
>  
>      return $content;
>  }
> -- 
> 2.11.0
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel




More information about the pve-devel mailing list