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
5d6b0280
Commit
5d6b0280
authored
Feb 24, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added stub for template execution, WIP.
parent
102385e4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
2 deletions
+27
-2
examples/playbook.yml
+4
-0
lib/ansible/runner.py
+20
-2
library/template
+3
-0
No files found.
examples/playbook.yml
View file @
5d6b0280
...
...
@@ -5,6 +5,10 @@
-
setup
-
[
"
a=2"
,
"
b=3"
,
"
c=4"
]
-
do
:
-
template from local file template.j2 to remote location /srv/file.out
-
template
-
[
'
/srv/template.j2'
,
'
/srv/file.out'
]
-
do
:
-
update apache
-
command
-
[
/usr/bin/yum
,
update
,
apache
]
...
...
lib/ansible/runner.py
View file @
5d6b0280
...
...
@@ -111,7 +111,7 @@ class Runner(object):
if
not
ok
:
return
[
host
,
False
,
conn
]
if
self
.
module_name
!=
"copy"
:
if
self
.
module_name
not
in
[
'copy'
,
'template'
]
:
# transfer a module, set it executable, and run it
outpath
=
self
.
_copy_module
(
conn
)
self
.
_exec_command
(
conn
,
"chmod +x
%
s"
%
outpath
)
...
...
@@ -120,7 +120,7 @@ class Runner(object):
self
.
_exec_command
(
conn
,
"rm -f
%
s"
%
outpath
)
conn
.
close
()
return
[
host
,
True
,
json
.
loads
(
result
)
]
el
se
:
el
if
self
.
module_name
==
'copy'
:
# SFTP file copy module is not really a module
self
.
remote_log
(
conn
,
'COPY remote:
%
s local:
%
s'
%
(
self
.
module_args
[
0
],
self
.
module_args
[
1
]))
ftp
=
conn
.
open_sftp
()
...
...
@@ -128,6 +128,24 @@ class Runner(object):
ftp
.
close
()
conn
.
close
()
return
[
host
,
True
,
1
]
elif
self
.
module_name
==
'template'
:
# template runs COPY then the template module
# TODO: DRY/refactor these
# TODO: things like _copy_module should take the name as a param
tempname
=
os
.
path
.
split
(
self
.
module_args
[
0
])[
-
1
]
temppath
=
self
.
_get_tmp_path
(
conn
,
tempname
)
self
.
remote_log
(
conn
,
'COPY remote:
%
s local:
%
s'
%
(
self
.
module_args
[
0
],
temppath
))
ftp
=
conn
.
open_sftp
()
ftp
.
put
(
self
.
module_args
[
0
],
temppath
)
ftp
.
close
()
self
.
module_name
=
'template'
self
.
module_args
=
[
self
.
module_args
[
0
],
temppath
]
outpath
=
self
.
_copy_module
(
conn
)
self
.
_exec_command
(
conn
,
"chmod +x
%
s"
%
outpath
)
result
=
self
.
_exec_command
(
conn
,
self
.
_command
(
outpath
))
self
.
_exec_command
(
conn
,
"rm -f
%
s"
%
outpath
)
conn
.
close
()
return
[
host
,
True
,
json
.
loads
(
result
)
]
def
_command
(
self
,
outpath
):
...
...
library/template
0 → 100644
View file @
5d6b0280
#!/usr/bin/python
print
{}
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