Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
97f4f562
Commit
97f4f562
authored
Jun 18, 2014
by
Matt Martz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Exit-Json and Fail-Json powershell helper functions
parent
74c43c94
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
4 deletions
+21
-4
lib/ansible/module_utils/powershell.ps1
+17
-0
library/windows/setup.ps1
+1
-1
library/windows/slurp.ps1
+1
-1
library/windows/win_ping.ps1
+1
-1
library/windows/win_stat.ps1
+1
-1
No files found.
lib/ansible/module_utils/powershell.ps1
View file @
97f4f562
...
@@ -47,3 +47,20 @@ Function Set-Attr($obj, $name, $value)
...
@@ -47,3 +47,20 @@ Function Set-Attr($obj, $name, $value)
$obj
|
Add-Member
-Force -MemberType NoteProperty -Name
$name
-Value
$value
$obj
|
Add-Member
-Force -MemberType NoteProperty -Name
$name
-Value
$value
}
}
# Helper function to convert a powershell object to JSON to echo it, exiting
# the script
Function Exit
-Json
(
$obj
)
{
echo
$obj
|
ConvertTo-Json
Exit
}
# Helper function to add the "msg" property and "failed" property, convert the
# powershell object to JSON and echo it, exiting the script
Function
Fail-Json
(
$obj
,
$message
)
{
Set
-Attr
$obj
"msg"
$message
Set
-Attr
$obj
"failed"
$true
echo
$obj
|
ConvertTo-Json
Exit
}
library/windows/setup.ps1
View file @
97f4f562
...
@@ -34,4 +34,4 @@ Set-Attr $result.ansible_facts "ansible_os_family" "Windows"
...
@@ -34,4 +34,4 @@ Set-Attr $result.ansible_facts "ansible_os_family" "Windows"
Set
-Attr
$result
.ansible_facts
"ansible_distribution"
$osversion
.VersionString
Set
-Attr
$result
.ansible_facts
"ansible_distribution"
$osversion
.VersionString
Set
-Attr
$result
.ansible_facts
"ansible_distribution_version"
$osversion
.Version.ToString
()
Set
-Attr
$result
.ansible_facts
"ansible_distribution_version"
$osversion
.Version.ToString
()
echo
$result
|
ConvertTo-Json
;
Exit
-Json
$result
;
library/windows/slurp.ps1
View file @
97f4f562
...
@@ -44,4 +44,4 @@ $result = New-Object psobject @{
...
@@ -44,4 +44,4 @@ $result = New-Object psobject @{
encoding
=
"base64"
encoding
=
"base64"
}
;
}
;
Set
-Attr
$result
"content"
$content
;
Set
-Attr
$result
"content"
$content
;
echo
$result
|
ConvertTo-Json
;
Exit
-Json
$result
;
library/windows/win_ping.ps1
View file @
97f4f562
...
@@ -29,4 +29,4 @@ $result = New-Object psobject @{
...
@@ -29,4 +29,4 @@ $result = New-Object psobject @{
changed
=
$false
changed
=
$false
ping
=
$data
ping
=
$data
}
;
}
;
echo
$result
|
ConvertTo-Json
;
Exit
-Json
$result
;
library/windows/win_stat.ps1
View file @
97f4f562
...
@@ -61,4 +61,4 @@ If ($get_md5 -and $result.stat.exists -and -not $result.stat.isdir)
...
@@ -61,4 +61,4 @@ If ($get_md5 -and $result.stat.exists -and -not $result.stat.isdir)
Set
-Attr
$result
.stat
"md5"
$path_md5
;
Set
-Attr
$result
.stat
"md5"
$path_md5
;
}
}
echo
$result
|
ConvertTo-Json
;
Exit
-Json
$result
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment