Hi,
What is the correct way to add users to linux VM instantiated from template?
Hi,
What is the correct way to add users to linux VM instantiated from template?
The quickest way is to add a START_SCRIPT in context. Didn’t try but it
should be something like
CONTEXT = [
START_SCRIPT="useradd -m -s /bin/bash test_user ; echo -e \"pass\npass\"
| passwd test_user"
]
You could even combine it with user inputs to ask the user for the passwd
(just add another var in CONTEXT with the user input value and source the
context.sh script to get it)
It seems that START_SCRIPT is run every time VM reboots.
Is there a way to run certain scripts just once when VM is started for the first time after instatiating from template?
You can easily add a “state file” for example create a file /.configured
and make your script check for it, or maybe just check if any of the
configurations was already performed.
I have also added start_script in VM template and instantiated a VM like below: