From 38998cee05817e6413f27480c20001aab50e6c7f Mon Sep 17 00:00:00 2001 From: Brian Wuchner Date: Sun, 28 Nov 2021 21:29:59 -0500 Subject: [PATCH 1/7] vRealize Automation SaltStack Config API wrapper Initial commit of SaltStackConfig module, a series of wrapper functions for the vRealize Automation SaltStack Config API. Signed-off-by: Brian Wuchner --- Modules/SaltStackConfig/SaltStackConfig.psd1 | Bin 0 -> 8444 bytes Modules/SaltStackConfig/SaltStackConfig.psm1 | Bin 0 -> 20620 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 Modules/SaltStackConfig/SaltStackConfig.psd1 create mode 100644 Modules/SaltStackConfig/SaltStackConfig.psm1 diff --git a/Modules/SaltStackConfig/SaltStackConfig.psd1 b/Modules/SaltStackConfig/SaltStackConfig.psd1 new file mode 100644 index 0000000000000000000000000000000000000000..df74969e04598ee83133a2e8c2f8f71c00fe4943 GIT binary patch literal 8444 zcmeI1Yfl?T6o%(>rT&MN_+U~M5*nH&Ra=FGkWeKl0&@8ZwsGBnO>F~7tNiu0?=#1T z+41gjaf4b_m1Xa)XXebgyyrIi=O5pNh46X!EIbawa2!5_QRs(W_&H2M5xxp{^j*>2 z>+m9+g*}aS!@P%W>sS*b3|6ZCDD=wYIGpgD}?bl4f<{(?tIt=-bu$Z?*bS z*wKn5(O%NNhoXBDSHQc1L6cI5; znhz%W;t-A2%`XD`J`9WDR%XLZVZG3v_ymZWXlI^5@UOadMG@QeHHz<;x9|_PajPWx z(cshYO5O!sll6hPyBqFl{R5$EHTu?pp6}{zHGC~S;E(rZ|CKnpr?GuKwe`EA{}1&2 zMl{SL+(v8S4jv3?7ukdr`E29sQABT@*W^19eN4xLs0-WiH0q;s#r<;{FD1>9*1Lwv z5v;oRY~&-VSPXy$Hc2t2*(!B0)by|@P2UoYG8fBwUX$$)bxlzhA0*0xmQg?h9bq`< zcs-7%$lyMdEQH(#5o2xfZsSBk@C~w#MSCdfhB=RO7a^``Pm|Ade>6q4?LoXb(LQ7Z zc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OV#dJGU!ZvP$DrE9}jY>74A%uGAlecrjmMj`fkI3Fq0bIqy|O`aHife@)+4 z^7`kxCh6Ff{nJ~-RB<**kC!@Szp?|KnCQHUGWgqolvR9%UoYkj)S9L^$=;V1{j|*M z;>0DL^f3IQc~pMQnzR1U=lwlC?M(}EV@ZqE@L|}nGp&nG9-6t_oYK4we^h+b@0O7` zA0iqNbyC+AKANWS{qXa+LZBsC5fi zq}&Nw%(<)^B<}pA97A+KCv5g8#=2} Q=DkmOMO8;1&+Ey*0J@E2;s5{u literal 0 HcmV?d00001 diff --git a/Modules/SaltStackConfig/SaltStackConfig.psm1 b/Modules/SaltStackConfig/SaltStackConfig.psm1 new file mode 100644 index 0000000000000000000000000000000000000000..243afd3c2639b883f520effb1bbb486354aaceaa GIT binary patch literal 20620 zcmeI4`%@dq5y$6Orz-!$9;hOyvP67IC3Re!GPch-Tz*i7*iI!W0zzl|ERZ8)_)TleeXAap`Ij@%3z;bC|kTH%StcGTk_9O}EJUVHIwsP^yl z*VXt{jlLf?HKL`tTUxiLc|XPxz_A#9A7_1}Hr8NlUspwh@IY7H*xJ$@hq~H~vwn)- zMffp}b({)~YKLdxdDsfys3-H&cK1ep96B(C&O5@rD+(52SA1Cww?sF%vlFTDO7!W7 zPtap|ND+Bo{(67Kx~ZT2+>{ov_uBL|(gY1RAUL|?qOkw@b9k*EhZfny-)V0AdV zBdGRu4WHW@Gtj6s&z8o$(-<3Nv)$ABMcPmaGQ<-GoLm6y@@dG#__C&RwGrrYG=I!KQdE9j$;js zt8aBR6!tvHb?-nk?8nw$=n0VY1rs{I628?pGGh|Riap`P4Bx32Qfc~cl3u9IR^UmM zzDS%)P+QWDUOy1c)@6mZ^!;2s^XFjv#|Xc{Jc(n@lcaSCM>v%*0q=x~kE`S5H2ye@ zZDH_Qe0eJPpXl1#fgQ<%maE|}vWm{%(=8x&5jwj?YzlwqJ&d~iS=am0WH{Z9Qn(+Q znz=Qi(?Ig$d~9kKa379(Z0O0MK1XUBM7z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+pw1(VyjEF6z4ywf<-)M6=8rrwpT7IZaV}(2tfH4= zHfy||+Xk~=c5c>rJUOzio~gl`3}b!dg=&YdWbbe5?}b_qg)b+^i1+Ky*3io%G-{7N zgF{h{Rm+~h{Q6m>1}I(iH&e6zAlfF zq?znJgm@A5-?aLtX8Db$$>KYY=N7*Fc4c`VwyA6v z6`Q@d1576j=6i+tUSU>?@6pZm>=nr4=MwF^h1_ypjjgXjLOkmG{b_N34(+UQepR=B zY8JmrU$^~pi+`HM&og=R$bMdHnAOVrxa+m{?5lYX$M^YmPh`z|Ncp?$-FWH-&%mjl z$GRi(<}^;B>S4+ntm`eX-1=UPukh%#oF~9v*n4j2B$W5eb4k48&-qZph&Qu5A60(q ziRa^I)pBfS^)+Ry!drPp-{#40i`>!gi+riio$wp|+Q^;oYyCdOuj2o&bp4fb^)5+d z<*RSRm!sC|YE}M``5%tf;2jFM%i68Da$7qsPTsUdF{_kM`^}5Kdnc8!i&C6_f(-@6bCrz@lb!9h}lv^W#`&Bw?uWL7iGa` ztXg+ZIltyemh7!^qez-P&t0Y!>S^SVSiP-&t$gIRsIsT^`OSm8oz{8?Jd$CB`c=}| zdWR;>pt_{)M_MN#qm9lpD^wxKjG5ATt46bmrwW)P}@#= literal 0 HcmV?d00001 From ba63d1643a78632453e6daf40cf8ac8a0f37e012 Mon Sep 17 00:00:00 2001 From: Brian Wuchner Date: Mon, 29 Nov 2021 06:48:29 -0500 Subject: [PATCH 2/7] Update SaltStackConfig.psd1 Increasing version number in manifest. Signed-off-by: Brian Wuchner --- Modules/SaltStackConfig/SaltStackConfig.psd1 | Bin 8444 -> 4224 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/Modules/SaltStackConfig/SaltStackConfig.psd1 b/Modules/SaltStackConfig/SaltStackConfig.psd1 index df74969e04598ee83133a2e8c2f8f71c00fe4943..d4c00348a2d14da760d3833ab13fa3662f9c491f 100644 GIT binary patch literal 4224 zcmc&%+in{-5PcV*e;B|IvI|SG9oKb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i#T!x9y0%>A_p;~VRC4+U!)tE4vsfjW4ib*9 zhBe>+Iy`Sgd|T!9Pw`#m;X1s}`clvt|G^yA$ijInU$j6r#7Nzq)q_7P2O&Je;)6!AV{U|#e1rqCnrB% z1Asq^oX9wu{%aCfyFL>3I_vg8Guq z8OFNX(X(}TL?z^Cscu5!)FuOcE}zdyQ=;e{m}$~!=5yAi4f@*p(I2(*e#6)ctuo9d zeskJhufu&keX^O=3r#bKo%DI`UoFKuQ18fpEbDfri1;7Fvlwn)svW~`uEl2T=DL3^ z1lS3voq)}&e{5N$RnJ8$d?75A5x{u~r?8xk%*(-lH;UQ0$VJ*Q1ms$**L}6FTvyb3 ztVl(@Uq0KJ*ADL0>!Q|dA{GRvWfUeG;J-3#1 z_NnWaycecYATwhv>|RVWA6#0E1h<^Cd)6vq*EZHKb1Vv#ZAcGOK52k*jsl*@LCkc0 zq;q-R^wgi>nb+hxOV#dJGU!ZvP$DrE9}jY>74A%uGAlecrjmMj`fkI3Fq0bIqy|O`aHife@)+4 z^7`kxCh6Ff{nJ~-RB<**kC!@Szp?|KnCQHUGWgqolvR9%UoYkj)S9L^$=;V1{j|*M z;>0DL^f3IQc~pMQnzR1U=lwlC?M(}EV@ZqE@L|}nGp&nG9-6t_oYK4we^h+b@0O7` zA0iqNbyC+AKANWS{qXa+LZBsC5fi zq}&Nw%(<)^B<}pA97A+KCv5g8#=2} Q=DkmOMO8;1&+Ey*0J@E2;s5{u From 95abde3a5a1504b215fb3566c61772975d2ad4cf Mon Sep 17 00:00:00 2001 From: Brian Wuchner Date: Mon, 29 Nov 2021 06:52:50 -0500 Subject: [PATCH 3/7] Update SaltStackConfig.psm1 Fixing help information in Connect-SscServer to be more descriptive. Signed-off-by: Brian Wuchner --- Modules/SaltStackConfig/SaltStackConfig.psm1 | Bin 20620 -> 10432 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/Modules/SaltStackConfig/SaltStackConfig.psm1 b/Modules/SaltStackConfig/SaltStackConfig.psm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;3JyNz|*0$x^PGyzPSGjKAr-DlxQiYK8xe+NWqbPjeY4kE%X7R&R&*v`DU@%oN&% z-MwlU9jin`$El&%7%8UyW4Y_`+fJ_)-?waa-`)k*e9WjV;}FE$$L=iKxRvO|(8KIp-0*{_Ct4(AO%Ydo=z z`}KD8P~-}CqHl6MY!8xlBD61R^(WEZ5F?Q>WH0nxAbe?`h6|=kkBn92s#ylG*XISb02}BI2?Pr(Ha8 zuGh-iS*(~^x7C`eg?Utao~+h+pw1(VyjEF6z4ywf<-)M6=8rrwpT7IZaV}(2tfH4= zHfy||+Xk~=c5c>rJUOzio~gl`3}b!dg=&YdWbbe5?}b_qg)b+^i1+Ky*3io%G-{7N zgF{h{Rm+~h{Q6m>1}I(iH&e6zAlfF zq?znJgm@A5-?aLtX8Db$$>KYY=N7*Fc4c`VwyA6v z6`Q@d1576j=6i+tUSU>?@6pZm>=nr4=MwF^h1_ypjjgXjLOkmG{b_N34(+UQepR=B zY8JmrU$^~pi+`HM&og=R$bMdHnAOVrxa+m{?5lYX$M^YmPh`z|Ncp?$-FWH-&%mjl z$GRi(<}^;B>S4+ntm`eX-1=UPukh%#oF~9v*n4j2B$W5eb4k48&-qZph&Qu5A60(q ziRa^I)pBfS^)+Ry!drPp-{#40i`>!gi+riio$wp|+Q^;oYyCdOuj2o&bp4fb^)5+d z<*RSRm!sC|YE}M``5%tf;2jFM%i68Da$7qsPTsUdF{_kM`^}5Kdnc8!i&C6_f(-@6bCrz@lb!9h}lv^W#`&Bw?uWL7iGa` ztXg+ZIltyemh7!^qez-P&t0Y!>S^SVSiP-&t$gIRsIsT^`OSm8oz{8?Jd$CB`c=}| zdWR;>pt_{)M_MN#qm9lpD^wxKjG5ATt46bmrwW)P}@#= From ded1ce575db03abfbfc6011597c38df386eddb9a Mon Sep 17 00:00:00 2001 From: Brian Wuchner Date: Wed, 1 Dec 2021 11:58:39 -0500 Subject: [PATCH 4/7] Resolving some of the items from PR comments. Many thanks to @kamennikolov for his time to review and provide such helpful comments! This commit address many of the comments from PR 502 in the module psm1 file. Also updated module manifest to rev version number, changed FunctionsToExport to address Get-SscMinion --> Get-SscMinionCache name change. Signed-off-by: Brian Wuchner --- Modules/SaltStackConfig/SaltStackConfig.psd1 | 4 +- Modules/SaltStackConfig/SaltStackConfig.psm1 | 125 ++++++++++--------- 2 files changed, 66 insertions(+), 63 deletions(-) diff --git a/Modules/SaltStackConfig/SaltStackConfig.psd1 b/Modules/SaltStackConfig/SaltStackConfig.psd1 index d4c0034..96cc64a 100644 --- a/Modules/SaltStackConfig/SaltStackConfig.psd1 +++ b/Modules/SaltStackConfig/SaltStackConfig.psd1 @@ -17,7 +17,7 @@ SPDX-License-Identifier: BSD-2-Clause RootModule = 'SaltStackConfig.psm1' # Version number of this module. -ModuleVersion = '0.0.2' +ModuleVersion = '0.0.3' # Supported PSEditions # CompatiblePSEditions = @() @@ -74,7 +74,7 @@ PowerShellVersion = '4.0' # NestedModules = @() # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. -FunctionsToExport = @('Connect-SscServer', 'Disconnect-SscServer', 'Get-SscCommand', 'Get-SscData', 'Get-SscJob', 'Get-SscMaster', 'Get-SscMinion', 'Get-SscReturn', 'Get-SscSchedule') +FunctionsToExport = @('Connect-SscServer', 'Disconnect-SscServer', 'Get-SscCommand', 'Get-SscData', 'Get-SscJob', 'Get-SscMaster', 'Get-SscMinionCache', 'Get-SscReturn', 'Get-SscSchedule') # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. CmdletsToExport = @() diff --git a/Modules/SaltStackConfig/SaltStackConfig.psm1 b/Modules/SaltStackConfig/SaltStackConfig.psm1 index 8b0be46..8fb8565 100644 --- a/Modules/SaltStackConfig/SaltStackConfig.psm1 +++ b/Modules/SaltStackConfig/SaltStackConfig.psm1 @@ -12,10 +12,10 @@ Function Connect-SscServer { Twitter: @bwuch =========================================================================== .SYNOPSIS - This function will allow you to connect to a vRealize Automation SaltStack Config API. - A global variable will be set with the Servername & Cookie/Header value for use by other functions. + Use this function to create the cookie/header to connect to SaltStack Config RaaS API .DESCRIPTION - Use this function to create the cookie/header to connect to SaltStack Config + This function will allow you to connect to a vRealize Automation SaltStack Config RaaS API. + A global variable will be set with the Servername & Cookie/Header value for use by other functions. .EXAMPLE PS C:\> Connect-SscServer -Server 'salt.example.com' -Username 'root' -Password 'VMware1!' This will default to internal user authentication. @@ -32,18 +32,18 @@ Function Connect-SscServer { $loginBody = @{'username'=$username; 'password'=$password; 'config_name'=$AuthSource} try { - $webRequest = Invoke-WebRequest -Uri "https://$server/account/login" -SessionVariable ws -Headers $header + $webRequest = Invoke-WebRequest -Uri "https://$server/account/login" -SessionVariable ws $ws.headers.Add('X-Xsrftoken', $webRequest.headers.'x-xsrftoken') $webRequest = Invoke-WebRequest -Uri "https://$server/account/login" -WebSession $ws -method POST -body (ConvertTo-Json $loginBody) $webRequestJson = ConvertFrom-JSON $webRequest.Content $global:DefaultSscConnection = New-Object psobject -property @{ "SscWebSession"=$ws; "SscServer"=$server; "ConnectionDetail"=$webRequestJson } # Return a few grains, like the Salt server & version; this will prove the connection worked & provide some context - (Get-SscMaster).ret.salt.grains | Select-Object Host, NodeName, SaltVersion, @{N='Authenticated';E={$global:DefaultSscConnection.ConnectionDetail.authenticated}}, + Get-SscMaster | Select-Object Host, NodeName, SaltVersion, @{N='Authenticated';E={$global:DefaultSscConnection.ConnectionDetail.authenticated}}, @{N='AuthType';E={$global:DefaultSscConnection.ConnectionDetail.attributes.config_driver}}, @{N='AuthSource';E={$global:DefaultSscConnection.ConnectionDetail.attributes.config_name}}, @{N='UserName';E={$global:DefaultSscConnection.ConnectionDetail.attributes.username}}, @{N='Permissions';E={[string]::Join(', ', $global:DefaultSscConnection.ConnectionDetail.attributes.permissions)}} } catch { - write-warning "Failure connecting to $server" + Write-Error ("Failure connecting to $server. " + $_) } # end try/catch block } @@ -57,16 +57,16 @@ Function Disconnect-SscServer { Twitter: @bwuch =========================================================================== .SYNOPSIS - This function will clear the global variable used to connect to the vRealize Automation SaltStack Config API - .DESCRIPTION This function clears a previously created cookie/header used to connect to SaltStack Config + .DESCRIPTION + This function will clear the global variable used to connect to the vRealize Automation SaltStack Config RaaS API .EXAMPLE PS C:\> Disconnect-SscServer #> if ($global:DefaultSscConnection) { $global:DefaultSscConnection = $null } else { - write-warning "Not connected to any SaltStack Config servers." + Write-Error 'Could not find an existing connection.' } # end if } @@ -80,11 +80,11 @@ Function Get-SscData { Twitter: @bwuch =========================================================================== .SYNOPSIS - This function will pass resource/method/arguments to the vRealize Automation SaltStack Config API. - It depends on a global variable created by Connect-SscServer. - .DESCRIPTION Use this function to call the SaltStack Config API. Additional helper functions will call this function, this is where the majority of the logic will happen. + .DESCRIPTION + This function will pass resource/method/arguments to the vRealize Automation SaltStack Config RaaS API. + It depends on a global variable created by Connect-SscServer. .EXAMPLE PS C:\> Get-SscData -Resource 'minions' -Method 'get_minion_cache' #> @@ -95,21 +95,21 @@ Function Get-SscData { ) if (!$global:DefaultSscConnection) { - write-warning "Not connected to any SaltStack Config servers." + Write-Error 'You are not currently connected to any servers. Please connect first using Connect-SscServer.' return; } # end if if (!$kwarg) { - $body = "{`"resource`": `"$resource`", `"method`": `"$method`"}" + $body = @{'resource'=$resource; 'method'=$method } } else { - $body = "{`"resource`": `"$resource`", `"method`": `"$method`", `"kwarg`": $(ConvertTo-Json $kwarg) }" + $body = @{'resource'=$resource; 'method'=$method; 'kwarg'=$kwarg } } try{ - $output = Invoke-WebRequest -WebSession $global:DefaultSscConnection.SscWebSession -Method POST -Uri "https://$($global:DefaultSscConnection.SscServer)/rpc" -body $body -ContentType 'application/json' + $output = Invoke-WebRequest -WebSession $global:DefaultSscConnection.SscWebSession -Method POST -Uri "https://$($global:DefaultSscConnection.SscServer)/rpc" -body $(ConvertTo-Json $body) -ContentType 'application/json' return (ConvertFrom-Json $output.Content) } catch { - write-warning $_.Exception.Message + Write-Error $_.Exception.Message } } @@ -125,27 +125,27 @@ Function Get-SscMaster { Twitter: @bwuch =========================================================================== .SYNOPSIS - This wrapper function will call Get-SscData master.get_master_grains. - .DESCRIPTION This wrapper function will return grain details about the SaltStack Config master node. + .DESCRIPTION + This wrapper function will call Get-SscData master.get_master_grains. .EXAMPLE PS C:\> Get-SscMaster #> param( - [ValidateSet('RAW','Results')][string]$Return='RAW' + [ValidateSet('Json','Results')][string]$Output='Results' ) - $output = Get-SscData master get_master_grains + $data = Get-SscData master get_master_grains - if ($return -eq 'Results') { - $output.ret.salt.grains + if ($Output -eq 'Results') { + $data.ret.salt.grains } else { - $output + $data } # end if for results parameter } -Function Get-SscMinion { +Function Get-SscMinionCache { <# .NOTES =========================================================================== @@ -155,22 +155,22 @@ Function Get-SscMinion { Twitter: @bwuch =========================================================================== .SYNOPSIS - This wrapper function will call Get-SscData minions.get_minion_cache. - .DESCRIPTION This wrapper function will return the grain property cache of SaltStack Config minions. + .DESCRIPTION + This wrapper function will call Get-SscData minions.get_minion_cache. .EXAMPLE PS C:\> Get-SscMinion #> param( - [ValidateSet('RAW','Results')][string]$Return='RAW' + [ValidateSet('Json','Results')][string]$Output='Results' ) - $output = Get-SscData minions get_minion_cache + $data = Get-SscData minions get_minion_cache - if ($return -eq 'Results') { - $output.ret.results + if ($Output -eq 'Results') { + $data.ret.results } else { - $output + $data } # end if for results parameter } @@ -184,22 +184,22 @@ Function Get-SscJob { Twitter: @bwuch =========================================================================== .SYNOPSIS - This wrapper function will call Get-SscData job.get_jobs. - .DESCRIPTION This wrapper function will return configured SatlStack Config jobs. + .DESCRIPTION + This wrapper function will call Get-SscData job.get_jobs. .EXAMPLE PS C:\> Get-SscJob #> param( - [ValidateSet('RAW','Results')][string]$Return='RAW' + [ValidateSet('Json','Results')][string]$Output='Results' ) - $output = Get-SscData job get_jobs + $data = Get-SscData job get_jobs - if ($return -eq 'Results') { - $output.ret.results + if ($Output -eq 'Results') { + $data.ret.results } else { - $output + $data } # end if for results parameter } @@ -213,22 +213,22 @@ Function Get-SscSchedule { Twitter: @bwuch =========================================================================== .SYNOPSIS - This wrapper function will call Get-SscData schedule.get. - .DESCRIPTION This wrapper function will return schedules for SaltStack Config. + .DESCRIPTION + This wrapper function will call Get-SscData schedule.get. .EXAMPLE PS C:\> Get-SscSchedule #> param( - [ValidateSet('RAW','Results')][string]$Return='RAW' + [ValidateSet('Json','Results')][string]$Output='Results' ) - $output = Get-SscData schedule get + $data = Get-SscData schedule get - if ($return -eq 'Results') { - $output.ret.results + if ($Output -eq 'Results') { + $data.ret.results } else { - $output + $data } # end if for results parameter } @@ -242,20 +242,23 @@ Function Get-SscReturn { Twitter: @bwuch =========================================================================== .SYNOPSIS - This wrapper function will call Get-SscData ret.get_returns with either Jid or MinionID. - .DESCRIPTION This wrapper function will return job results from the job cache based on the provided arguments. + .DESCRIPTION + This wrapper function will call Get-SscData ret.get_returns with either Jid or MinionID. + .EXAMPLE + PS C:\> Get-SscReturn .EXAMPLE PS C:\> Get-SscReturn -Jid '20211122160147314949' + .EXAMPLE PS C:\> Get-SscReturn -MinionID 't147-win22-01.lab.enterpriseadmins.org' #> param( - [ValidateSet('RAW','Results')][string]$Return='RAW', + [ValidateSet('Json','Results')][string]$Output='Results', [string]$jid, [string]$minionid ) # ToDo: This should be a parameterset, was having trouble with making the parameters optional. Use if statement for now - if ($jid -and $minionid) { Write-Warning "Please only specify JID or MinionID, not both"; return; } + if ($jid -and $minionid) { Write-Warning 'Please only specify JID or MinionID, not both.'; return; } if ($jid) { $kwarg = @{'jid'=$jid} @@ -265,12 +268,12 @@ Function Get-SscReturn { $kwarg = $null } - $output = Get-SscData ret get_returns $kwarg + $data = Get-SscData ret get_returns $kwarg - if ($return -eq 'Results') { - $output.ret.results + if ($Output -eq 'Results') { + $data.ret.results } else { - $output + $data } # end if for results parameter } @@ -284,21 +287,21 @@ Function Get-SscCommand { Twitter: @bwuch =========================================================================== .SYNOPSIS - This wrapper function will call Get-SscData cmd.get_cmds. - .DESCRIPTION This wrapper function will return SaltStack Config commands that have been issued. + .DESCRIPTION + This wrapper function will call Get-SscData cmd.get_cmds. .EXAMPLE PS C:\> Get-SscCommand #> param( - [ValidateSet('RAW','Results')][string]$Return='RAW' + [ValidateSet('Json','Results')][string]$Output='Results' ) - $output = Get-SscData cmd get_cmds + $data = Get-SscData cmd get_cmds - if ($return -eq 'Results') { - $output.ret.results + if ($Output -eq 'Results') { + $data.ret.results } else { - $output + $data } # end if for results parameter } From 96205f85b2f686e801370cf7d25e30b7787f696f Mon Sep 17 00:00:00 2001 From: Brian Wuchner Date: Thu, 2 Dec 2021 14:39:23 -0500 Subject: [PATCH 5/7] Updating SaltStackConfig module Updated functions based on comments in PR502. Updated manifest to include Get-SscActivity (previously Get-SscCommand) and reference to new Format.ps1xml, which contains custom formatting for the Connect-SscServer output. Signed-off-by: Brian Wuchner --- .../SaltStackConfig.Format.ps1xml | 41 +++++++ Modules/SaltStackConfig/SaltStackConfig.psd1 | 7 +- Modules/SaltStackConfig/SaltStackConfig.psm1 | 103 +++++------------- 3 files changed, 69 insertions(+), 82 deletions(-) create mode 100644 Modules/SaltStackConfig/SaltStackConfig.Format.ps1xml diff --git a/Modules/SaltStackConfig/SaltStackConfig.Format.ps1xml b/Modules/SaltStackConfig/SaltStackConfig.Format.ps1xml new file mode 100644 index 0000000..b9d453c --- /dev/null +++ b/Modules/SaltStackConfig/SaltStackConfig.Format.ps1xml @@ -0,0 +1,41 @@ + + + + + SscConnection + + SscConnection + + + + + 25 + + + + 25 + + + + + + + + + + + SscServer + + + $_.ConnectionDetail.attributes.config_name +'\'+ $_.ConnectionDetail.attributes.username + + + $_.ConnectionDetail.authenticated + + + + + + + + \ No newline at end of file diff --git a/Modules/SaltStackConfig/SaltStackConfig.psd1 b/Modules/SaltStackConfig/SaltStackConfig.psd1 index 96cc64a..7b2cbdd 100644 --- a/Modules/SaltStackConfig/SaltStackConfig.psd1 +++ b/Modules/SaltStackConfig/SaltStackConfig.psd1 @@ -17,7 +17,7 @@ SPDX-License-Identifier: BSD-2-Clause RootModule = 'SaltStackConfig.psm1' # Version number of this module. -ModuleVersion = '0.0.3' +ModuleVersion = '0.0.4' # Supported PSEditions # CompatiblePSEditions = @() @@ -68,13 +68,13 @@ PowerShellVersion = '4.0' # TypesToProcess = @() # Format files (.ps1xml) to be loaded when importing this module -# FormatsToProcess = @() +FormatsToProcess = @('SaltStackConfig.Format.ps1xml') # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess # NestedModules = @() # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. -FunctionsToExport = @('Connect-SscServer', 'Disconnect-SscServer', 'Get-SscCommand', 'Get-SscData', 'Get-SscJob', 'Get-SscMaster', 'Get-SscMinionCache', 'Get-SscReturn', 'Get-SscSchedule') +FunctionsToExport = @('Connect-SscServer', 'Disconnect-SscServer', 'Get-SscActivity', 'Get-SscData', 'Get-SscJob', 'Get-SscMaster', 'Get-SscMinionCache', 'Get-SscReturn', 'Get-SscSchedule') # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. CmdletsToExport = @() @@ -125,4 +125,3 @@ PrivateData = @{ # DefaultCommandPrefix = '' } - diff --git a/Modules/SaltStackConfig/SaltStackConfig.psm1 b/Modules/SaltStackConfig/SaltStackConfig.psm1 index 8fb8565..cd2d7f3 100644 --- a/Modules/SaltStackConfig/SaltStackConfig.psm1 +++ b/Modules/SaltStackConfig/SaltStackConfig.psm1 @@ -36,12 +36,10 @@ Function Connect-SscServer { $ws.headers.Add('X-Xsrftoken', $webRequest.headers.'x-xsrftoken') $webRequest = Invoke-WebRequest -Uri "https://$server/account/login" -WebSession $ws -method POST -body (ConvertTo-Json $loginBody) $webRequestJson = ConvertFrom-JSON $webRequest.Content - $global:DefaultSscConnection = New-Object psobject -property @{ "SscWebSession"=$ws; "SscServer"=$server; "ConnectionDetail"=$webRequestJson } + $global:DefaultSscConnection = New-Object psobject -property @{ "SscWebSession"=$ws; "SscServer"=$server; "ConnectionDetail"=$webRequestJson; PSTypeName='SscConnection' } - # Return a few grains, like the Salt server & version; this will prove the connection worked & provide some context - Get-SscMaster | Select-Object Host, NodeName, SaltVersion, @{N='Authenticated';E={$global:DefaultSscConnection.ConnectionDetail.authenticated}}, - @{N='AuthType';E={$global:DefaultSscConnection.ConnectionDetail.attributes.config_driver}}, @{N='AuthSource';E={$global:DefaultSscConnection.ConnectionDetail.attributes.config_name}}, - @{N='UserName';E={$global:DefaultSscConnection.ConnectionDetail.attributes.username}}, @{N='Permissions';E={[string]::Join(', ', $global:DefaultSscConnection.ConnectionDetail.attributes.permissions)}} + # Return the connection object + $global:DefaultSscConnection } catch { Write-Error ("Failure connecting to $server. " + $_) } # end try/catch block @@ -107,7 +105,12 @@ Function Get-SscData { try{ $output = Invoke-WebRequest -WebSession $global:DefaultSscConnection.SscWebSession -Method POST -Uri "https://$($global:DefaultSscConnection.SscServer)/rpc" -body $(ConvertTo-Json $body) -ContentType 'application/json' - return (ConvertFrom-Json $output.Content) + $outputJson = (ConvertFrom-Json $output.Content) + + if ($outputJson.error) { Write-Error $outputJson.error } + if ($outputJson.warnings) { Write-Warning $outputJson.warnings } + return $outputJson.ret + } catch { Write-Error $_.Exception.Message } @@ -132,17 +135,7 @@ Function Get-SscMaster { PS C:\> Get-SscMaster #> - param( - [ValidateSet('Json','Results')][string]$Output='Results' - ) - - $data = Get-SscData master get_master_grains - - if ($Output -eq 'Results') { - $data.ret.salt.grains - } else { - $data - } # end if for results parameter + (Get-SscData master get_master_grains).salt.grains } Function Get-SscMinionCache { @@ -161,17 +154,8 @@ Function Get-SscMinionCache { .EXAMPLE PS C:\> Get-SscMinion #> - param( - [ValidateSet('Json','Results')][string]$Output='Results' - ) - $data = Get-SscData minions get_minion_cache - - if ($Output -eq 'Results') { - $data.ret.results - } else { - $data - } # end if for results parameter + (Get-SscData minions get_minion_cache).results } Function Get-SscJob { @@ -190,17 +174,8 @@ Function Get-SscJob { .EXAMPLE PS C:\> Get-SscJob #> - param( - [ValidateSet('Json','Results')][string]$Output='Results' - ) - $data = Get-SscData job get_jobs - - if ($Output -eq 'Results') { - $data.ret.results - } else { - $data - } # end if for results parameter + (Get-SscData job get_jobs).results } Function Get-SscSchedule { @@ -219,17 +194,8 @@ Function Get-SscSchedule { .EXAMPLE PS C:\> Get-SscSchedule #> - param( - [ValidateSet('Json','Results')][string]$Output='Results' - ) - $data = Get-SscData schedule get - - if ($Output -eq 'Results') { - $data.ret.results - } else { - $data - } # end if for results parameter + (Get-SscData schedule get).results } Function Get-SscReturn { @@ -251,33 +217,22 @@ Function Get-SscReturn { PS C:\> Get-SscReturn -Jid '20211122160147314949' .EXAMPLE PS C:\> Get-SscReturn -MinionID 't147-win22-01.lab.enterpriseadmins.org' + .EXAMPLE + PS C:\> Get-SscReturn -MinionID 't147-win22-01.lab.enterpriseadmins.org' -Jid '20211122160147314949' #> param( - [ValidateSet('Json','Results')][string]$Output='Results', - [string]$jid, - [string]$minionid + [string]$jid, + [string]$MinionID ) - # ToDo: This should be a parameterset, was having trouble with making the parameters optional. Use if statement for now - if ($jid -and $minionid) { Write-Warning 'Please only specify JID or MinionID, not both.'; return; } - if ($jid) { - $kwarg = @{'jid'=$jid} - } elseif ($minionid) { - $kwarg = @{'minion_id'=$minionid} - } else { - $kwarg = $null - } + $kwarg = @{} + if ($jid) { $kwarg += @{'jid'=$jid} } + if ($MinionID) { $kwarg += @{'minion_id'=$MinionID} } - $data = Get-SscData ret get_returns $kwarg - - if ($Output -eq 'Results') { - $data.ret.results - } else { - $data - } # end if for results parameter + (Get-SscData ret get_returns $kwarg).results } -Function Get-SscCommand { +Function Get-SscActivity { <# .NOTES =========================================================================== @@ -288,20 +243,12 @@ Function Get-SscCommand { =========================================================================== .SYNOPSIS This wrapper function will return SaltStack Config commands that have been issued. + In the web interface this is similar to the Activity button. .DESCRIPTION This wrapper function will call Get-SscData cmd.get_cmds. .EXAMPLE - PS C:\> Get-SscCommand + PS C:\> Get-SscActivity #> - param( - [ValidateSet('Json','Results')][string]$Output='Results' - ) - $data = Get-SscData cmd get_cmds - - if ($Output -eq 'Results') { - $data.ret.results - } else { - $data - } # end if for results parameter + (Get-SscData cmd get_cmds).results } From 3afa7eed5d00bd4c107058250a5faaa0fcd05425 Mon Sep 17 00:00:00 2001 From: Brian Wuchner Date: Fri, 3 Dec 2021 12:53:37 -0500 Subject: [PATCH 6/7] Resolving comments from PR in SaltStackConfig module Promoting properties on the connection object as requested in PR comment. Signed-off-by: Brian Wuchner --- Modules/SaltStackConfig/SaltStackConfig.Format.ps1xml | 6 +++--- Modules/SaltStackConfig/SaltStackConfig.psd1 | 2 +- Modules/SaltStackConfig/SaltStackConfig.psm1 | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Modules/SaltStackConfig/SaltStackConfig.Format.ps1xml b/Modules/SaltStackConfig/SaltStackConfig.Format.ps1xml index b9d453c..eedff9b 100644 --- a/Modules/SaltStackConfig/SaltStackConfig.Format.ps1xml +++ b/Modules/SaltStackConfig/SaltStackConfig.Format.ps1xml @@ -24,13 +24,13 @@ - SscServer + Server Name - $_.ConnectionDetail.attributes.config_name +'\'+ $_.ConnectionDetail.attributes.username + Connected As - $_.ConnectionDetail.authenticated + Authenticated diff --git a/Modules/SaltStackConfig/SaltStackConfig.psd1 b/Modules/SaltStackConfig/SaltStackConfig.psd1 index 7b2cbdd..6c4f3f3 100644 --- a/Modules/SaltStackConfig/SaltStackConfig.psd1 +++ b/Modules/SaltStackConfig/SaltStackConfig.psd1 @@ -17,7 +17,7 @@ SPDX-License-Identifier: BSD-2-Clause RootModule = 'SaltStackConfig.psm1' # Version number of this module. -ModuleVersion = '0.0.4' +ModuleVersion = '0.0.5' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/Modules/SaltStackConfig/SaltStackConfig.psm1 b/Modules/SaltStackConfig/SaltStackConfig.psm1 index cd2d7f3..7d872b5 100644 --- a/Modules/SaltStackConfig/SaltStackConfig.psm1 +++ b/Modules/SaltStackConfig/SaltStackConfig.psm1 @@ -36,7 +36,8 @@ Function Connect-SscServer { $ws.headers.Add('X-Xsrftoken', $webRequest.headers.'x-xsrftoken') $webRequest = Invoke-WebRequest -Uri "https://$server/account/login" -WebSession $ws -method POST -body (ConvertTo-Json $loginBody) $webRequestJson = ConvertFrom-JSON $webRequest.Content - $global:DefaultSscConnection = New-Object psobject -property @{ "SscWebSession"=$ws; "SscServer"=$server; "ConnectionDetail"=$webRequestJson; PSTypeName='SscConnection' } + $global:DefaultSscConnection = New-Object psobject -property @{ 'SscWebSession'=$ws; 'Server Name'=$server; 'ConnectionDetail'=$webRequestJson; + 'Connected As'=$webRequestJson.attributes.config_driver +'\'+ $username; 'Authenticated'=$webRequestJson.authenticated; PSTypeName='SscConnection' } # Return the connection object $global:DefaultSscConnection @@ -104,7 +105,7 @@ Function Get-SscData { } try{ - $output = Invoke-WebRequest -WebSession $global:DefaultSscConnection.SscWebSession -Method POST -Uri "https://$($global:DefaultSscConnection.SscServer)/rpc" -body $(ConvertTo-Json $body) -ContentType 'application/json' + $output = Invoke-WebRequest -WebSession $global:DefaultSscConnection.SscWebSession -Method POST -Uri "https://$($global:DefaultSscConnection.'Server Name')/rpc" -body $(ConvertTo-Json $body) -ContentType 'application/json' $outputJson = (ConvertFrom-Json $output.Content) if ($outputJson.error) { Write-Error $outputJson.error } From 3b7653da710a0571f86df93cdc408cab3dda6c74 Mon Sep 17 00:00:00 2001 From: Brian Wuchner Date: Mon, 6 Dec 2021 15:49:33 -0500 Subject: [PATCH 7/7] Minor changes to Connect-SscServer output properties. Changing returned columns from Connect-SscServer to be more in line with other PowerCLI cmdlets. Signed-off-by: Brian Wuchner --- .../SaltStackConfig/SaltStackConfig.Format.ps1xml | 12 ++++++------ Modules/SaltStackConfig/SaltStackConfig.psm1 | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Modules/SaltStackConfig/SaltStackConfig.Format.ps1xml b/Modules/SaltStackConfig/SaltStackConfig.Format.ps1xml index eedff9b..da69972 100644 --- a/Modules/SaltStackConfig/SaltStackConfig.Format.ps1xml +++ b/Modules/SaltStackConfig/SaltStackConfig.Format.ps1xml @@ -9,12 +9,12 @@ - 25 - + 30 + - 25 - + 30 + @@ -24,10 +24,10 @@ - Server Name + Name - Connected As + User Authenticated diff --git a/Modules/SaltStackConfig/SaltStackConfig.psm1 b/Modules/SaltStackConfig/SaltStackConfig.psm1 index 7d872b5..007f74d 100644 --- a/Modules/SaltStackConfig/SaltStackConfig.psm1 +++ b/Modules/SaltStackConfig/SaltStackConfig.psm1 @@ -36,8 +36,8 @@ Function Connect-SscServer { $ws.headers.Add('X-Xsrftoken', $webRequest.headers.'x-xsrftoken') $webRequest = Invoke-WebRequest -Uri "https://$server/account/login" -WebSession $ws -method POST -body (ConvertTo-Json $loginBody) $webRequestJson = ConvertFrom-JSON $webRequest.Content - $global:DefaultSscConnection = New-Object psobject -property @{ 'SscWebSession'=$ws; 'Server Name'=$server; 'ConnectionDetail'=$webRequestJson; - 'Connected As'=$webRequestJson.attributes.config_driver +'\'+ $username; 'Authenticated'=$webRequestJson.authenticated; PSTypeName='SscConnection' } + $global:DefaultSscConnection = New-Object psobject -property @{ 'SscWebSession'=$ws; 'Name'=$server; 'ConnectionDetail'=$webRequestJson; + 'User'=$webRequestJson.attributes.config_driver +'\'+ $username; 'Authenticated'=$webRequestJson.authenticated; PSTypeName='SscConnection' } # Return the connection object $global:DefaultSscConnection @@ -105,7 +105,7 @@ Function Get-SscData { } try{ - $output = Invoke-WebRequest -WebSession $global:DefaultSscConnection.SscWebSession -Method POST -Uri "https://$($global:DefaultSscConnection.'Server Name')/rpc" -body $(ConvertTo-Json $body) -ContentType 'application/json' + $output = Invoke-WebRequest -WebSession $global:DefaultSscConnection.SscWebSession -Method POST -Uri "https://$($global:DefaultSscConnection.Name)/rpc" -body $(ConvertTo-Json $body) -ContentType 'application/json' $outputJson = (ConvertFrom-Json $output.Content) if ($outputJson.error) { Write-Error $outputJson.error }