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
61d064d0
Commit
61d064d0
authored
Feb 26, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed up KV munging in runner, misc fixes to copy, setup, and template modules
parent
226da501
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
36 deletions
+21
-36
examples/playbook.yml
+4
-1
lib/ansible/playbook.py
+8
-29
lib/ansible/runner.py
+5
-5
library/copy
+1
-0
library/setup
+2
-1
library/template
+1
-0
No files found.
examples/playbook.yml
View file @
61d064d0
-
pattern
:
'
*'
hosts
:
'
/etc/ansible/hosts'
hosts
:
/etc/ansible/hosts
tasks
:
-
do
:
-
restart apache for kicks
-
command /sbin/service apache restart
-
do
:
-
configure template & module variables for future template calls
-
setup a=2 b=3 c=4
-
do
:
...
...
lib/ansible/playbook.py
View file @
61d064d0
...
...
@@ -88,32 +88,6 @@ class PlayBook(object):
}
return
results
def
_get_task_runner
(
self
,
pattern
=
None
,
host_list
=
None
,
module_name
=
None
,
module_args
=
None
):
'''
return a runner suitable for running this task, using
preferences from the constructor
'''
if
host_list
is
None
:
host_list
=
self
.
host_list
return
ansible
.
runner
.
Runner
(
pattern
=
pattern
,
module_name
=
module_name
,
module_args
=
module_args
,
host_list
=
host_list
,
forks
=
self
.
forks
,
remote_user
=
self
.
remote_user
,
remote_pass
=
self
.
remote_pass
,
module_path
=
self
.
module_path
,
timeout
=
self
.
timeout
)
def
_run_task
(
self
,
pattern
=
None
,
task
=
None
,
host_list
=
None
,
handlers
=
None
,
conditional
=
False
):
'''
run a single task in the playbook and
...
...
@@ -135,11 +109,16 @@ class PlayBook(object):
else
:
print
"
\n
NOTIFIED [
%
s]"
%
(
comment
)
runner
=
self
.
_get_task_r
unner
(
runner
=
ansible
.
runner
.
R
unner
(
pattern
=
pattern
,
host_list
=
host_list
,
module_name
=
module_name
,
module_args
=
module_args
module_args
=
module_args
,
host_list
=
host_list
,
forks
=
self
.
forks
,
remote_user
=
self
.
remote_user
,
# FIXME: read from playbook
remote_pass
=
self
.
remote_pass
,
module_path
=
self
.
module_path
,
timeout
=
self
.
timeout
)
results
=
runner
.
run
()
...
...
lib/ansible/runner.py
View file @
61d064d0
...
...
@@ -154,17 +154,17 @@ class Runner(object):
options
=
self
.
_parse_kv
(
self
.
module_args
)
source
=
options
[
'src'
]
dest
=
options
[
'dest'
]
tmp_
dest
=
self
.
_get_tmp_path
(
conn
,
dest
.
split
(
"/"
)[
-
1
])
self
.
_transfer_file
(
conn
,
source
,
tmp_
dest
)
tmp_
src
=
self
.
_get_tmp_path
(
conn
,
dest
.
split
(
"/"
)[
-
1
])
self
.
_transfer_file
(
conn
,
source
,
tmp_
src
)
# install the copy module
self
.
module_name
=
'copy'
module
=
self
.
_transfer_module
(
conn
)
# run the copy module
self
.
module_args
=
[
tmp_dest
,
dest
]
self
.
module_args
=
[
"src=
%
s"
%
tmp_src
,
"dest=
%
s"
%
dest
]
result
=
self
.
_execute_module
(
conn
,
module
)
self
.
_delete_remote_files
(
conn
,
tmp_
dest
)
self
.
_delete_remote_files
(
conn
,
tmp_
src
)
return
self
.
_return_from_module
(
conn
,
host
,
result
)
def
_execute_template
(
self
,
conn
,
host
):
...
...
@@ -185,7 +185,7 @@ class Runner(object):
module
=
self
.
_transfer_module
(
conn
)
# run the template module
self
.
module_args
=
[
temppath
,
dest
,
metadata
]
self
.
module_args
=
[
"src=
%
s"
%
temppath
,
"dest=
%
s"
%
dest
,
"metadata=
%
s"
%
metadata
]
result
=
self
.
_execute_module
(
conn
,
module
)
self
.
_delete_remote_files
(
conn
,
[
temppath
])
return
self
.
_return_from_module
(
conn
,
host
,
result
)
...
...
library/copy
View file @
61d064d0
...
...
@@ -2,6 +2,7 @@
import
sys
import
os
import
shlex
try
:
import
json
...
...
library/setup
View file @
61d064d0
...
...
@@ -16,7 +16,7 @@ except ImportError:
input_data
=
sys
.
argv
[
1
:]
new_options
=
dict
([
x
.
split
(
'='
)
for
x
in
input_data
])
ansible_file
=
new_options
.
get
(
'metadata'
,
DEFAULT_ANSIBLE_SETUP
)
ansible_dir
=
os
.
path
.
dirname
(
metadata
)
ansible_dir
=
os
.
path
.
dirname
(
ansible_file
)
# create the config dir if it doesn't exist
...
...
@@ -24,6 +24,7 @@ if not os.path.exists(ansible_dir):
os
.
makedirs
(
ansible_dir
)
changed
=
False
md5sum
=
None
if
not
os
.
path
.
exists
(
ansible_file
):
changed
=
True
else
:
...
...
library/template
View file @
61d064d0
...
...
@@ -3,6 +3,7 @@
import
sys
import
os
import
jinja2
import
shlex
try
:
import
json
except
ImportError
:
...
...
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