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
8f9e136c
Commit
8f9e136c
authored
Jul 30, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #721 from Ernest0x/command_change_cwd
added a 'chdir' argument to the command module
parents
b7da73b7
4ad0ff61
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
library/command
+13
-0
No files found.
library/command
View file @
8f9e136c
...
...
@@ -31,8 +31,12 @@ def main():
module
=
CommandModule
(
argument_spec
=
dict
())
shell
=
module
.
params
[
'shell'
]
chdir
=
module
.
params
[
'chdir'
]
args
=
module
.
params
[
'args'
]
if
chdir
:
os
.
chdir
(
chdir
)
if
not
shell
:
args
=
shlex
.
split
(
args
)
startd
=
datetime
.
datetime
.
now
()
...
...
@@ -77,6 +81,7 @@ class CommandModule(AnsibleModule):
args
=
base64
.
b64decode
(
MODULE_ARGS
)
items
=
shlex
.
split
(
args
)
params
=
{}
params
[
'chdir'
]
=
None
params
[
'shell'
]
=
False
if
args
.
find
(
"#USE_SHELL"
)
!=
-
1
:
args
=
args
.
replace
(
"#USE_SHELL"
,
""
)
...
...
@@ -99,6 +104,14 @@ class CommandModule(AnsibleModule):
rc
=
0
)
args
=
args
.
replace
(
x
,
''
)
elif
x
.
startswith
(
"chdir="
):
(
k
,
v
)
=
x
.
split
(
"="
,
1
)
if
not
(
os
.
path
.
exists
(
v
)
and
os
.
path
.
isdir
(
v
)):
self
.
fail_json
(
msg
=
"cannot change to directory '
%
s': path does not exist"
%
v
)
elif
v
[
0
]
!=
'/'
:
self
.
fail_json
(
msg
=
"the path for 'chdir' argument must be fully qualified"
)
params
[
'chdir'
]
=
v
args
=
args
.
replace
(
x
,
''
)
params
[
'args'
]
=
args
return
(
params
,
args
)
...
...
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