FOG 1.5.4 API host module settings
-
Hi,
when i create a new host via the api i figured out that the host module settings of this new host are all not enabled.
All of these modules are enabled at fog server level. If i create the new host via the gui or the pxe menu (full host registration) they
are also enabled.My question now is if somebody can give me an example how i can enable these settings on the new host via the api after the
new host creation task. I use windows powershell to access the fog api, based on this forum post.Any help is appreciated!
-
@katerkarlo99 when creating the host via api, you can associate snapins, printers, groups, and modules using the ids of the relevant item as an array using the respective key as the object identifier.
For example, creating a host with associating the client modules your data element would be:
{ "macs" : [ "00:01:02:03:04:05" ], "name" : "hostname", "modules" : [ 1,2,3,4,5,6,7,8,9,10,11,12 ] }
Or very similar.
The api call would be to
/fog/host/create
of POST request. -
Hi Tom,
thanks for the answer, this works fine during the host creation.
I’ve tryed to activate the modules after the host creation by creating a moduleassociation for the newly created host object.
For example:#Hostname Changer $TaskdataSet = @{ "hostID" = $HostID "moduleID" = "9" "state" = "1" } Try{ $taskdataToSend = ConvertTo-JSON($TaskdataSet) New-FogObject -type object -coreObject moduleassociation -jsonData $TaskdataSet }Catch{Write-Host "Failed to create Module association for Module 4 in Fog" -ForegroundColor Red $error[0] | Format-List -Force Exit 1 }
But i think this was the wrong way. Could you tell me the right way to activate the modules after the host creation step?
And one further question:
If i try to define a ‘AllSnapin task’ for the new created host it doesn’t work.
So my last step should be the deployment of the already, successfully assigned snapins after the hostname was
changed (which is now working if i activate the hostchanger module during the host creation step). That’s why i try to create a “AllSnapin” task for
the newly created host object like this:#Create Snapin Tasks for new Host $HostID = $createHostResult.id $TaskURL = $baseUri + "/host/" + $HostID + "/task" $TaskdataSet = @{ "hostname" = $createHostResult.name "taskTypeID" = $AllSnapinID } Try{ $taskdataToSend = ConvertTo-JSON($TaskdataSet) $TaskResult = Invoke-RestMethod -Method Post -Uri $TaskURL -Headers $headers -Body $taskdataToSend -ContentType "application/json" }Catch{Write-Host "Failed to create All Snapin Task in Fog" -ForegroundColor Red $error[0] | Format-List -Force Exit 1 }
But this dosen’t work, i guess because the deployment task is in the queue for the new host? Would it be the right way to create the “AllSnapin Task”
after the deployment task has finished? Is that the clue?Thank you for your support!
-
@Tom-Elliott said in FOG 1.5.4 API host module settings:
@katerkarlo99 when creating the host via api, you can associate snapins, printers, groups, and modules using the ids of the relevant item as an array using the respective key as the object identifier.
For example, creating a host with associating the client modules your data element would be:
{ "macs" : [ "00:01:02:03:04:05" ], "name" : "hostname", "modules" : [ 1,2,3,4,5,6,7,8,9,10,11,12 ] }
Or very similar.
The api call would be to
/fog/host/create
of POST request.Did you all ever get this figured out in Powershell?
I’m trying to activate hostname changer as well so the computer automatically joins the domain. In the PowerShell script I got from this forum, it has the force AD, but if the hostname changer is not selected by default, it won’t join the domain. If you got this working, can you please tell me what you did exactly? -
Pinging @JJ-Fullmer on this.
-
@Sebastian-Roth said in FOG 1.5.4 API host module settings:
Pinging @JJ-Fullmer on this.
Thanks Sebastian,
Appreciate you and everyone else assisting. I’m still learning PowerShell up to this day
and like the fact the scripts on this forum is making Fog work even more dynamic. -
@Sebastian-Roth said in FOG 1.5.4 API host module settings:
Pinging @JJ-Fullmer on this.
All,
I figured this out! I got hostname changer via PowerShell. So here’s what I did to resolve it.
So with the script I got from this forum last week, I know it had the Json in a splat format. I’m so so with PowerShell
and doing a lot better than a few years back. So basically what KaterKarlo said, he has moduleid = 9.It wasn’t working for me. To get the correct name and ID number, I ended up going to my fog server via the browser, then right click on the browser and view page source did a search for hostname changer. Then it came up the name modules and the value of 9. I finally ended up putting it with the rest of the splat and joined it with no issues:
“modules” = 9
I hope this helps someone as well if they need to get the values of a host.
But thank you guys always for pointing me in the right direction. -
@Jamaal Glad you got it figured out, sorry I didn’t see this early as adding it to the host splat that you convert to json adds it to the json data that @Tom-Elliott references here. I will make a note about adding something with setting modules to my module in the future
-
@JJ-Fullmer said in FOG 1.5.4 API host module settings:
@Jamaal Glad you got it figured out, sorry I didn’t see this early as adding it to the host splat that you convert to json adds it to the json data that @Tom-Elliott references here. I will make a note about adding something with setting modules to my module in the future
Look, I made a note https://github.com/darksidemilk/FogApi/issues/1
-
@jj-fullmer said in FOG 1.5.4 API host module settings:
@JJ-Fullmer said in FOG 1.5.4 API host module settings:
@Jamaal Glad you got it figured out, sorry I didn’t see this early as adding it to the host splat that you convert to json adds it to the json data that @Tom-Elliott references here. I will make a note about adding something with setting modules to my module in the future
Look, I made a note https://github.com/darksidemilk/FogApi/issues/1
@Jamaal I also finally did something with this. I hope to at some point develop this a lot further and have dynamic parameters for snapins and groups when adding a host in powershell. But for now there is at least a basic
new-foghost
function that will create a host with a given name and mac list and enable the modules that you have set as default in your fog server.This is published in version 2103.2.12
https://www.powershellgallery.com/packages/FogApi/2103.2.12
https://github.com/darksidemilk/FogApi/releases/tag/2103.2.12