Ansible modifications
--one-line output is the default added stopwatch timing to the default output combined Status and RC into a single 2 element array, so that # of columns would default to table format Instead of -OneLine a -RawOutput switch was introduced to force full output
This commit is contained in:
parent
35fe3a156f
commit
7cb9f09c8c
|
@ -3,7 +3,7 @@
|
||||||
[string[]]$Remotes = 'all',
|
[string[]]$Remotes = 'all',
|
||||||
[string[]]$MoreArgs,
|
[string[]]$MoreArgs,
|
||||||
[switch]$NotPowerShell,
|
[switch]$NotPowerShell,
|
||||||
[switch]$OneLine
|
[switch]$RawOutput
|
||||||
)
|
)
|
||||||
|
|
||||||
$script:ansible_cli=@('ansible')
|
$script:ansible_cli=@('ansible')
|
||||||
|
@ -20,7 +20,7 @@ if( $Command ) {
|
||||||
$ansible_cli += "pwsh -encodedcommand $(ConvertTo-Base64 $($Command -join '; '))"
|
$ansible_cli += "pwsh -encodedcommand $(ConvertTo-Base64 $($Command -join '; '))"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( $OneLine ) {
|
if( -not $RawOutput ) {
|
||||||
$ansible_cli += '--one-line'
|
$ansible_cli += '--one-line'
|
||||||
}
|
}
|
||||||
$ansible_cli += $Remotes
|
$ansible_cli += $Remotes
|
||||||
|
@ -30,13 +30,14 @@ $local:expr = $('& "'+$($ansible_cli -join '" "')+'"')
|
||||||
Write-Verbose $expr
|
Write-Verbose $expr
|
||||||
$local:SaveConsoleColor = [Console]::ForegroundColor
|
$local:SaveConsoleColor = [Console]::ForegroundColor
|
||||||
$env:ANSIBLE_DEPRECATION_WARNINGS='false'
|
$env:ANSIBLE_DEPRECATION_WARNINGS='false'
|
||||||
|
$local:sw = [System.Diagnostics.Stopwatch]::StartNew()
|
||||||
Invoke-Expression $expr | ForEach-Object {
|
Invoke-Expression $expr | ForEach-Object {
|
||||||
if( -not $OneLine ) { return $_ };
|
if( $RawOutput ) { return $_ };
|
||||||
$local:res = $_.Split('|') + @('', '', '', '')
|
$local:res = $_.Split('|') + @('', '', '', '')
|
||||||
$res = [PSCustomObject]([ordered]@{
|
$res = [PSCustomObject]([ordered]@{
|
||||||
Machine = $res[0].Trim();
|
Machine = $res[0].Trim();
|
||||||
Status = $res[1].Trim();
|
Status = @($res[1].Trim(), "$($res[2])".Trim())
|
||||||
RC = "$($res[2])".Trim();
|
RunTime = $sw.Elapsed
|
||||||
Output = "$($res[3])".Trim();
|
Output = "$($res[3])".Trim();
|
||||||
})
|
})
|
||||||
if( $res.Status -match '^\w+!:' ) {
|
if( $res.Status -match '^\w+!:' ) {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
[CmdletBinding()]param(
|
[CmdletBinding()]param(
|
||||||
[Parameter(mandatory)]
|
[Parameter(mandatory)]
|
||||||
[string]$RemotePath,
|
[string]$RemotePath,
|
||||||
[switch]$NotOneLine,
|
[switch]$RawOutput,
|
||||||
[string[]]$Remotes = 'All'
|
[string[]]$Remotes = 'All'
|
||||||
)
|
)
|
||||||
|
|
||||||
Invoke-ViaAnsible -Command "cd $RemotePath",'Write-Output "$PWD `t"','git pull' -Remotes:$($Remotes.ToLower()) -OneLine:$(-not $NotOneLine)
|
Invoke-ViaAnsible -Command "cd $RemotePath",'Write-Output "$PWD `t"','git pull' -Remotes:$($Remotes.ToLower()) -RawOutput:$RawOutput
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
[CmdletBinding()]param(
|
[CmdletBinding()]param(
|
||||||
[string[]]$Remotes = 'All',
|
[string[]]$Remotes = 'All',
|
||||||
[switch]$OneLine
|
[switch]$RawOutput
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
Invoke-ViaAnsible -Command "Update-OSz -Mode Auto" -Remotes:$($Remotes.ToLower()) -OneLine:$OneLine
|
Invoke-ViaAnsible -Command "Update-OSz -Mode Auto" -Remotes:$($Remotes.ToLower()) -RawOutput:$RawOutput
|
||||||
|
|
Loading…
Reference in New Issue