mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-05-27 18:02:59 +00:00
cloud-init: add ciuser and cipassword config options
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
41cd94a01e
commit
7b42f95142
@ -546,6 +546,17 @@ my $confdesc_cloudinit = {
|
|||||||
description => 'Specifies the cloud-init configuration format.',
|
description => 'Specifies the cloud-init configuration format.',
|
||||||
enum => ['configdrive2', 'nocloud'],
|
enum => ['configdrive2', 'nocloud'],
|
||||||
},
|
},
|
||||||
|
ciuser => {
|
||||||
|
optional => 1,
|
||||||
|
type => 'string',
|
||||||
|
description => "cloud-init: User name to change ssh keys and password for instead of the image's configured default user.",
|
||||||
|
},
|
||||||
|
cipassword => {
|
||||||
|
optional => 1,
|
||||||
|
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.',
|
||||||
|
},
|
||||||
searchdomain => {
|
searchdomain => {
|
||||||
optional => 1,
|
optional => 1,
|
||||||
type => 'string',
|
type => 'string',
|
||||||
|
@ -61,16 +61,15 @@ sub cloudinit_userdata {
|
|||||||
|
|
||||||
my $fqdn = get_fqdn($conf);
|
my $fqdn = get_fqdn($conf);
|
||||||
|
|
||||||
my $content = <<"EOF";
|
my $content = "#cloud-config\n";
|
||||||
#cloud-config
|
$content .= "manage_resolv_conf: true\n";
|
||||||
manage_resolv_conf: true
|
|
||||||
EOF
|
|
||||||
|
|
||||||
my $username = 'blub';
|
my $username = $conf->{ciuser};
|
||||||
my $encpw = PVE::Tools::encrypt_pw('foo');
|
my $password = $conf->{cipassword};
|
||||||
|
|
||||||
$content .= "user: $username\n" if defined($username);
|
$content .= "user: $username\n" if defined($username);
|
||||||
$content .= "password: $encpw\n" if defined($encpw);
|
$content .= "disable_root: False\n" if defined($username) && $username eq 'root';
|
||||||
|
$content .= "password: $password\n" if defined($password);
|
||||||
|
|
||||||
if (defined(my $keys = $conf->{sshkeys})) {
|
if (defined(my $keys = $conf->{sshkeys})) {
|
||||||
$keys = URI::Escape::uri_unescape($keys);
|
$keys = URI::Escape::uri_unescape($keys);
|
||||||
@ -84,9 +83,10 @@ EOF
|
|||||||
$content .= "chpasswd:\n";
|
$content .= "chpasswd:\n";
|
||||||
$content .= " expire: False\n";
|
$content .= " expire: False\n";
|
||||||
|
|
||||||
# FIXME: we probably need an option to disable this?
|
if (!defined($username) || $username ne 'root') {
|
||||||
$content .= "users:\n";
|
$content .= "users:\n";
|
||||||
$content .= " - default\n";
|
$content .= " - default\n";
|
||||||
|
}
|
||||||
|
|
||||||
$content .= "package_upgrade: true\n";
|
$content .= "package_upgrade: true\n";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user