jenkinsci/openstack-cloud-plugin

How to change the username and userhome for the VM

Closed this issue · 4 comments

Hallo @olivergondza,

I am using the OpenStack Cloud Plugin 2.51 to launch instance automatically with a Windows Server 2019 image. It works no problem with the Maschine provisioning and connection with Jenkins automatically.

The problem is that this machine should connect to the network drive with a certain credential so that the Jenkins Jobs necessary data are possible with svn to check out. But my Jenkins Jobs failed always because the network drive cannot be reached with the current username: cloudbase-init.

Actually I have already in the image set up for a local user with name and credential. But it seems like that through this plugin generated new machine used default the username cloudbase-init and user.home is also C:\Users\cloudbase-init. I have also checked the other parameter on the Jenkins agent system information page. Under the list of the environment variables, I see the following Infos:

TEMP| C:\Users\CLOUDB1\AppData\Local\Temp
TMP | C:\Users\CLOUDB
1\AppData\Local\Temp
UATDATA | C:\Windows\CCM\UATData\D9F8C395-CAB8-491d-B8AC-179A1FE1BE77
USERDOMAIN | WORKER-1
USERNAME | cloudbase-init
USERPROFILE | C:\Users\cloudbase-init

Do you know how can I change all of these default settings with cloud and cloudbase to my local user? Perhaps code in the UserData file? I have no idea about it and am looking forward to your reply.

@Xeuhua, I am quite far from a windows expert, please bare that in mind.

  • Using user data to distribute credentials is strictly speaking insecure. Make sure you understand the implication before opting to do that: https://wiki.openstack.org/wiki/OSSN/OSSN-0074

  • Yes, using userdata is a good way to create user and its configuration so Jenkins can log in as that user afterwards. Explore what kinds of user data script does your windows image accept, and then how to set all those things you need. All I know it is doable in PowerShell, but it is not quite a joyful experience.

HTH

Hi @olivergondza, Thank you so much for your reply!
I have read the troubleshooting part in the readme.txt about userData and the link you have send.

  • Yes, you are absolutely right about that the credential setting in userdata is unsafe. Nevertheless I've tried briefly to fit the network drive seperat with another <lokaluser> with credential in PowerShell. Unfortunately it doesn't work that easily. So i guss i can forget this way.

  • Speaking about userdata I have found this cloudbase-init doc https://cloudbase-init.readthedocs.io/en/latest/userdata.html. According to this doc To create and configure local users are possible with a Cloud-config YAML configuration. Do you know if it's even possible? When yes, where I can adjust such yaml file? Because as far as i know, this plugin suppots only Powershell as syntax for userdata file.

Sincerely yours

@Xeuhua, this plugin (and even OpenStack to the best of my knowledge) is agnostic of the content of the "user data". The cloudbase-init is required inside the image to read and interpret it. I might be wrong, but I think windows cloudbase-init does not support #cloud-config userdata "dialect" (same as the one for linux would likely not support PowerShell, etc.).

Hallo @olivergondza, #cloud-config userdata for windows are supported by the OpenStack Dashboard that I used. But this may be just a special case. Anyway, I solved the problem with Bach command net use with a pipeline. Thanks a lot for the answer.