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

The administrator account password cannot be injected when creating a virtual machine #158

Open
yule-sun opened this issue Nov 4, 2024 · 6 comments

Comments

@yule-sun
Copy link

yule-sun commented Nov 4, 2024

I installed cloudbase-init 1.1.6 on Windows in an ovirt virtual environment and packaged it into a template. When I used this templateto create a new virtual machine, I configured the administrator password. The content of the virtual machine's configdirve directory config-2\openstack\latest\user_data.json is as follows.
#cloud-config
output:
all: '>> /var/log/cloud-init-output.log'
password: Idpbg123456.
disable_root: 0
runcmd:

  • 'sed -i ''/^datasource_list: /d'' /etc/cloud/cloud.cfg; echo ''datasource_list:
    ["NoCloud", "ConfigDrive"]'' >> /etc/cloud/cloud.cfg'
    timezone: Asia/Shanghai
    ssh_deletekeys: 'false'
    ssh_pwauth: true
    chpasswd:
    expire: false
    user: administrator

However, after the virtual machine is started, I need to log in for the first time to set the administrator's password. It has not been changed to the password I set myself.
Below is the startup log file. Can you help analyze the reason why the administrator password injection failed?
cloudbase-init.txt

@ader1990
Copy link
Member

ader1990 commented Nov 4, 2024

Hello @yule-sun,

Please check the current capabilities implemented in cloudbase-init regarding to user-data in cloud-config format: https://cloudbase-init.readthedocs.io/en/latest/userdata.html

In your case, as you provided the key user, which is not supported in cloudbase-init, cloudbase-init did not use that information.

2024-11-01 06:33:09.222 6984 ERROR cloudbaseinit.plugins.common.userdataplugins.cloudconfig [-] Plugin 'output' is currently not supported
2024-11-01 06:33:09.222 6984 ERROR cloudbaseinit.plugins.common.userdataplugins.cloudconfig [-] Plugin 'password' is currently not supported
2024-11-01 06:33:09.222 6984 ERROR cloudbaseinit.plugins.common.userdataplugins.cloudconfig [-] Plugin 'disable_root' is currently not supported
2024-11-01 06:33:09.222 6984 ERROR cloudbaseinit.plugins.common.userdataplugins.cloudconfig [-] Plugin 'ssh_deletekeys' is currently not supported
2024-11-01 06:33:09.222 6984 ERROR cloudbaseinit.plugins.common.userdataplugins.cloudconfig [-] Plugin 'ssh_pwauth' is currently not supported
2024-11-01 06:33:09.222 6984 ERROR cloudbaseinit.plugins.common.userdataplugins.cloudconfig [-] Plugin 'chpasswd' is currently not supported
2024-11-01 06:33:09.222 6984 ERROR cloudbaseinit.plugins.common.userdataplugins.cloudconfig [-] Plugin 'user' is currently not supported

I suggest using the users and groups keys to achieve the same result.

Thank you.

@yule-sun
Copy link
Author

yule-sun commented Nov 5, 2024

Thank you very much for your answer.
My user_data.json file is not written by me manually, but it is automatically generated when I create a virtual machine.
Snipaste_2024-11-05_10-03-33
Snipaste_2024-11-05_10-03-14

I tried to modify the two configuration files of cloud-base and changed user=administrator. As a result, after the newly created virtual machine, the password of the Administrator account was reset to a random password. I urgently want to know the reason for this. Can you help analyze it?
cloudbase-init.log
cloudbase-init-unattend.log

@ader1990
Copy link
Member

ader1990 commented Nov 5, 2024

Hello,

If the username has been changed to Administrator, the plugin SetUserPasswordPlugin will set a random password if the metadata does not contain a password. Also, as the ovirt env does not set the cloudbase-init compatible cloud-config userdata, which should contain the users key values according to the documentation in https://cloudbase-init.readthedocs.io/en/latest/userdata.html, there is currently no way to set the username/password, unless this feature is implemented in cloudbase-init.

To implement the feature, changes are needed in the https://github.com/cloudbase/cloudbase-init/tree/master/cloudbaseinit/plugins/common/userdataplugins/cloudconfigplugins, to have the user and passwd keywords used for the user/password creation.

Can you please share the full config-drive contents from the Ovirt environment, to see how this feature can be implemented?

Thanks you.

@yule-sun
Copy link
Author

yule-sun commented Nov 6, 2024

Thank you very much for your reply.
This is the user_data.json
image

This is the meta_data.json
image

I created a new virtual machine. Before the virtual machine IP address took effect, I logged into the server and was prompted to change the Administrator password for the first login. However, after I logged in, the password of the Administrator account was reset to a random password. I want to know why this happened?
cloudbase-init-unattend.log
cloudbase-init.log

@yule-sun
Copy link
Author

yule-sun commented Nov 6, 2024

I don't know where to modify the user_data.json file because it is automatically generated when the computer boots. I also can't find a place to modify the chpasswd module. How should I set it up next to inject a password into the Administrator?

@ader1990
Copy link
Member

ader1990 commented Nov 8, 2024

Hello @yule-sun,

According to https://www.ovirt.org/develop/release-management/features/virt/cloud-init-integration.html, there is no UI integration for the users key, required by cloudbase-init. But https://github.com/oVirt/ovirt-engine/blob/master/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml#L432 -> you can define programatically maybe the users key, according to the documentation from https://cloudbase-init.readthedocs.io/en/latest/userdata.html. I currently do not have an OVirt deployment where I can check. If that is not possible, the only way is to have the required features implemented in Cloudbase-Init.

Thanks.

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

No branches or pull requests

2 participants