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
df8866b8
Commit
df8866b8
authored
Jun 19, 2014
by
Matt Martz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add examples for how to use powershell common functions
parent
e4e61056
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
0 deletions
+5
-0
lib/ansible/module_utils/powershell.ps1
+5
-0
No files found.
lib/ansible/module_utils/powershell.ps1
View file @
df8866b8
...
...
@@ -29,6 +29,7 @@
# Helper function to parse Ansible JSON arguments from a file passed as
# the single argument to the module
# Example: $params = Parse-Args $args
Function
Parse-Args
(
$arguments
)
{
$parameters
=
New-Object
psobject;
...
...
@@ -42,6 +43,7 @@ Function Parse-Args($arguments)
# Helper function to set an "attribute" on a psobject instance in powershell.
# This is a convenience to make adding Members to the object easier and
# slightly more pythonic
# Example: Set-Attr $result "changed" $true
Function
Set
-Attr
(
$obj
,
$name
,
$value
)
{
$obj
|
Add-Member
-Force -MemberType NoteProperty -Name
$name
-Value
$value
...
...
@@ -66,6 +68,7 @@ Function Get-Attr($obj, $name, $default = $null)
# Helper function to convert a powershell object to JSON to echo it, exiting
# the script
# Example: Exit-Json $result
Function Exit
-Json
(
$obj
)
{
echo
$obj
|
ConvertTo-Json
...
...
@@ -74,6 +77,7 @@ Function Exit-Json($obj)
# Helper function to add the "msg" property and "failed" property, convert the
# powershell object to JSON and echo it, exiting the script
# Example: Fail-Json $result "This is the failure message"
Function
Fail-Json
(
$obj
,
$message
)
{
Set
-Attr
$obj
"msg"
$message
...
...
@@ -84,6 +88,7 @@ Function Fail-Json($obj, $message)
# Helper filter/pipeline function to convert a value to boolean following current
# Ansible practices
# Example: $is_true = "true" | ConvertTo-Bool
Function
ConvertTo-Bool
{
param
(
...
...
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