I am trying to customize the photon os 3.0 ova as same as guest customization which is done on windows or linux vm.
Here is the requirement. Is something possible to script it?
You might consider enabling network debugging.
My sample 'network' script contains the following commented lines.
"#mkdir -p /etc/systemd/system/systemd-networkd.service.d/",
"#cat > /etc/systemd/system/systemd-networkd.service.d/10-loglevel-debug.conf << EOF",
"#[Service]",
"#Environment=SYSTEMD_LOG_LEVEL=debug",
"#EOF",
"#systemctl daemon-reload",
"#systemctl restart systemd-networkd",
"#systemd-delta --type=extended",
"",
Remove the comment character, and check what the logs say.
On photon network debugging you can find more info at Network Debugging
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You could start with my posts Deploy Photon 2.0 – Part 1 and Deploy Photon 2.0 – Part 2
It contains most of your requirements.
In the meantime, I also have presented during the VMworld US session, named 'PowerCLI Deep Dive', how to use cloud-init to deploy and customise Photon.
On the same subject, there is my chapter in The PowerShell Conference Book Volume 2, that discusses this use of cloud-init further.
Note that this book is currently not completely published yet.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
I have gone through your post part 1 Deploy Photon 2.0 – Part 1 but when i try to execute the New-PhotonTemplate cmdlet its give error ConvertFrom-Json : Invalid JSON primitive: .
Steps I followed
1. Created a json file with required parameters.
2.Saved Invoke-VMScriptPlus & Set-VMKeystrokes scripts in .psm1 format and imported as module (Import-Module "C:\My Data\PhotonOVA\Invoke-photon.psm1" -Force -Scope Global)
3.Executed like this New-PhotonTemplate -JSONPath "C:\My Data\PhotonOVA\Input.json" -LogFile "C:\My Data\PhotonOVA\log.txt"
Error:
I have attached the json flie what i have created in this thread.
You seem to have a syntax error in the JSON file.
That last part should be
{
"Name": "PowerCLI",
"Script": ["docker pull vmware/powerclicore"],
"Environment": ["MSG=Hellow World"]
}
]
I attached the corrected file
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I got same error after using attached json file.
Just noticed there was a 2nd syntax error in the JSON file.
Corrected file attached.
As a hint, you can use the online JSONLint page to validate your JSON files.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I just executed this in ISE but giving same error
I suspect you missed my last update.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Oops I missed it. Right after posting my reply I got this update.
Now its working
I will execute complete script and post you update
I tried like this but why it is not taking .json flie path into $JSONPath variable. Due to this its showing argument is empty.
There are 2 errors:
I will update the JSON template in my post.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This time I can able to import ovf but its failing at guest customization.
Keystrokes also send successfully as I can see password changed to desired one which i mentioned json file.
That 1st error seems to indicate that the default harddisk size is bigger than what you specified in the JSON file.
Which OVA file are you using?
The Invoke-VMScriptPlus errors come from the fact that you only added 1 script to the JSON file (under Code).
But under Template.CustomisationCode you are calling 4 scripts, hence the 3 errors complaining about an empty ScriptText parameter value.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Which OVA file are you using?
photon-hw11-3.0-26156e2.ova. Its version 3.0
I have corrected 1st error of default harddisk size by changing it to 20GB
Now I can able to deploy the vm and keystrokes are issued correctly(Password change is done) but its failing at guest customization.
I have validated the json file and its showing valid but I received exception message at line 323 in invoke-vmscriptplus
Attached .json file which is used.
Your JSON file is ok now.
That error is most probably from Invoke-VMScriptPlus.
I had something similar on occasion.
Do you get that same error at every run?
With me that error most of the time didn't occur on subsequent runs.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I have executed twice and I got same error.
At first execution I even got Exception calling "PutUsbScanCodes" but after second time executing I didn't see that error.
And the photon VM's root password has been changed, even when you get the error?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
At first execution when i received (Exception calling "PutUsbScanCodes" )the password is not changed but in second time execution the password has changed.
Should I close complete powershell session and retry?
Yes, please try that
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
With new session I tried twice but received different errors with each try.
Sometimes its accepting keystrokes but failing to take script text and in second attempt keystrokes send correctly but failed with exception error.