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
3ea9174e
Commit
3ea9174e
authored
Mar 14, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split argsfile handling into subfunction, attempt to apply argsfile logic to setup
parent
1f53c89b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
13 deletions
+27
-13
lib/ansible/runner.py
+20
-12
library/setup
+7
-1
No files found.
lib/ansible/runner.py
View file @
3ea9174e
...
...
@@ -35,6 +35,7 @@ import jinja2
import
time
import
traceback
import
tempfile
import
StringIO
# FIXME: stop importing *, use as utils/errors
from
ansible.utils
import
*
...
...
@@ -227,7 +228,6 @@ class Runner(object):
def
_transfer_file
(
self
,
conn
,
source
,
dest
):
''' transfers a remote file '''
self
.
remote_log
(
conn
,
'COPY remote:
%
s local:
%
s'
%
(
source
,
dest
))
conn
.
put_file
(
source
,
dest
)
# *****************************************************
...
...
@@ -244,6 +244,23 @@ class Runner(object):
# *****************************************************
def
_transfer_argsfile
(
self
,
conn
,
tmp
,
args_str
):
'''
transfer arguments as a single file to be fed to the module.
this is to avoid various shell things being eaten by SSH
'''
args_fd
,
args_file
=
tempfile
.
mkstemp
()
args_fo
=
os
.
fdopen
(
args_fd
,
'w'
)
args_fo
.
write
(
args_str
)
args_fo
.
flush
()
args_fo
.
close
()
args_remote
=
os
.
path
.
join
(
tmp
,
'arguments'
)
self
.
_transfer_file
(
conn
,
args_file
,
'arguments'
)
os
.
unlink
(
args_file
)
return
args_remote
# *****************************************************
def
_execute_module
(
self
,
conn
,
tmp
,
remote_module_path
,
module_args
):
'''
runs a module that has already been transferred, but first
...
...
@@ -268,17 +285,8 @@ class Runner(object):
template
=
jinja2
.
Template
(
args
)
args
=
template
.
render
(
inject_vars
)
# make a tempfile for the args and stuff the args into the file
argsfd
,
argsfile
=
tempfile
.
mkstemp
()
argsfo
=
os
.
fdopen
(
argsfd
,
'w'
)
argsfo
.
write
(
args
)
argsfo
.
flush
()
argsfo
.
close
()
args_rem
=
tmp
+
'argsfile'
self
.
remote_log
(
conn
,
"args:
%
s"
%
args
)
self
.
_transfer_file
(
conn
,
argsfile
,
args_rem
)
os
.
unlink
(
argsfile
)
cmd
=
"
%
s
%
s"
%
(
remote_module_path
,
args_rem
)
argsfile
=
self
.
_transfer_argsfile
(
conn
,
tmp
,
args
)
cmd
=
"
%
s
%
s"
%
(
remote_module_path
,
'arguments'
)
result
=
self
.
_exec_command
(
conn
,
cmd
)
return
result
...
...
library/setup
View file @
3ea9174e
...
...
@@ -31,7 +31,13 @@ except ImportError:
# load config & template variables
input_data
=
sys
.
argv
[
1
:]
if
len
(
sys
.
argv
)
==
1
:
sys
.
exit
(
1
)
argfile
=
sys
.
argv
[
1
]
if
not
os
.
path
.
exists
(
argfile
):
sys
.
exit
(
1
)
input_data
=
open
(
argfile
,
'r'
)
.
read
()
new_options
=
dict
([
x
.
split
(
'='
)
for
x
in
input_data
])
ansible_file
=
new_options
.
get
(
'metadata'
,
DEFAULT_ANSIBLE_SETUP
)
ansible_dir
=
os
.
path
.
dirname
(
ansible_file
)
...
...
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