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
627ff30a
Commit
627ff30a
authored
Jun 17, 2014
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add module replacer capability for powershell files.
parent
9c7ea82a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
2 deletions
+48
-2
MANIFEST.in
+1
-0
lib/ansible/module_common.py
+17
-2
lib/ansible/module_utils/powershell.ps1
+30
-0
No files found.
MANIFEST.in
View file @
627ff30a
...
...
@@ -3,6 +3,7 @@ include examples/hosts
include examples/ansible.cfg
graft examples/playbooks
include packaging/distutils/setup.py
include lib/ansible/module_common/*.ps1
recursive-include docs *
recursive-include library *
include Makefile
lib/ansible/module_common.py
View file @
627ff30a
...
...
@@ -29,6 +29,7 @@ from ansible import constants as C
REPLACER
=
"#<<INCLUDE_ANSIBLE_MODULE_COMMON>>"
REPLACER_ARGS
=
"
\"
<<INCLUDE_ANSIBLE_MODULE_ARGS>>
\"
"
REPLACER_COMPLEX
=
"
\"
<<INCLUDE_ANSIBLE_MODULE_COMPLEX_ARGS>>
\"
"
REPLACER_WINDOWS
=
"# POWERSHELL_COMMON"
class
ModuleReplacer
(
object
):
...
...
@@ -54,6 +55,10 @@ class ModuleReplacer(object):
All modules are required to import at least basic, though there will also
be other snippets.
# POWERSHELL_COMMON will also map to
{{ include 'powershell.ps1' }}
"""
# ******************************************************************************
...
...
@@ -97,6 +102,10 @@ class ModuleReplacer(object):
if
REPLACER
in
line
:
output
.
write
(
self
.
slurp
(
os
.
path
.
join
(
self
.
snippet_path
,
"basic.py"
)))
snippet_names
.
append
(
'basic'
)
if
REPLACER_WINDOWS
in
line
:
ps_data
=
self
.
slurp
(
os
.
path
.
join
(
self
.
snippet_path
,
"powershell.ps1"
))
output
.
write
(
ps_data
)
snippet_names
.
append
(
'powershell'
)
elif
line
.
startswith
(
'from ansible.module_utils.'
):
tokens
=
line
.
split
(
"."
)
import_error
=
False
...
...
@@ -116,8 +125,14 @@ class ModuleReplacer(object):
output
.
write
(
line
)
output
.
write
(
"
\n
"
)
if
len
(
snippet_names
)
>
0
and
not
'basic'
in
snippet_names
:
raise
errors
.
AnsibleError
(
"missing required import in
%
s: from ansible.module_utils.basic import *"
%
module_path
)
if
not
module_path
.
endswith
(
".ps1"
):
# Unixy modules
if
len
(
snippet_names
)
>
0
and
not
'basic'
in
snippet_names
:
raise
errors
.
AnsibleError
(
"missing required import in
%
s: from ansible.module_utils.basic import *"
%
module_path
)
else
:
# Windows modules
if
len
(
snippet_names
)
>
0
and
not
'powershell'
in
snippet_names
:
raise
errors
.
AnsibleError
(
"missing required import in
%
s: # POWERSHELL_COMMON"
%
module_path
)
return
(
output
.
getvalue
(),
module_style
)
...
...
lib/ansible/module_utils/powershell.ps1
0 → 100644
View file @
627ff30a
# This particular file snippet, and this file snippet only, is BSD licensed.
# Modules you write using this snippet, which is embedded dynamically by Ansible
# still belong to the author of the module, and may assign their own license
# to the complete work.
#
# Copyright (c), Michael DeHaan <michael.dehaan@gmail.com>, 2014, and others
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
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