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
f6961e93
Commit
f6961e93
authored
May 26, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweaks on previous refactoring of playbook, version bump a 0.4 reference, remove some debug, etc
parent
fb261f94
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
27 deletions
+27
-27
lib/ansible/__init__.py
+1
-1
lib/ansible/playbook/play.py
+14
-9
lib/ansible/playbook/task.py
+8
-13
lib/ansible/runner/__init__.py
+3
-0
lib/ansible/runner/connection.py
+1
-3
library/virt
+0
-1
No files found.
lib/ansible/__init__.py
View file @
f6961e93
...
...
@@ -14,5 +14,5 @@
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
__version__
=
'0.
4
'
__version__
=
'0.
5
'
__author__
=
'Michael DeHaan'
lib/ansible/playbook/play.py
View file @
f6961e93
...
...
@@ -33,6 +33,9 @@ class Play(object):
# *************************************************
def
__init__
(
self
,
playbook
,
ds
):
''' constructor loads from a play datastructure '''
# TODO: more error handling
self
.
_ds
=
ds
self
.
playbook
=
playbook
...
...
@@ -90,16 +93,20 @@ class Play(object):
# *************************************************
def
handlers
(
self
):
return
self
.
_handlers
def
tasks
(
self
):
''' return task objects for this play '''
return
self
.
_tasks
def
handlers
(
self
):
''' return handler objects for this play '''
return
self
.
_handlers
# *************************************************
def
_get_vars
(
self
,
dirname
):
''' load the vars section from a play '''
''' load the vars section from a play, accounting for all sorts of variable features
including loading from yaml files, prompting, and conditional includes of the first
file found in a list. '''
if
self
.
vars
is
None
:
self
.
vars
=
{}
...
...
@@ -120,8 +127,7 @@ class Play(object):
if
type
(
self
.
vars_prompt
)
!=
dict
:
raise
errors
.
AnsibleError
(
"'vars_prompt' section must contain only key/value pairs"
)
for
vname
in
self
.
vars_prompt
:
# TODO: make this prompt one line and consider double entry
vars
[
vname
]
=
self
.
callbacks
.
on_vars_prompt
(
vname
)
vars
[
vname
]
=
self
.
playbook
.
callbacks
.
on_vars_prompt
(
vname
)
results
=
self
.
playbook
.
extra_vars
.
copy
()
results
.
update
(
vars
)
...
...
@@ -132,18 +138,17 @@ class Play(object):
def
update_vars_files
(
self
,
hosts
):
''' calculate vars_files, which requires that setup runs first so ansible facts can be mixed in '''
for
h
in
hosts
:
self
.
update_vars_files_for_host
(
h
)
self
.
_
update_vars_files_for_host
(
h
)
# *************************************************
def
update_vars_files_for_host
(
self
,
host
):
def
_
update_vars_files_for_host
(
self
,
host
):
if
not
host
in
self
.
playbook
.
SETUP_CACHE
:
# no need to process failed hosts or hosts not in this play
return
for
filename
in
self
.
vars_files
:
# TODO: maybe have to template the path here...
if
type
(
filename
)
==
list
:
...
...
lib/ansible/playbook/task.py
View file @
f6961e93
...
...
@@ -17,11 +17,7 @@
#############################################
#import ansible.inventory
#import ansible.runner
#import ansible.constants as C
#from ansible import utils
#from ansible import errors
from
ansible
import
errors
class
Task
(
object
):
...
...
@@ -31,14 +27,13 @@ class Task(object):
]
def
__init__
(
self
,
play
,
ds
):
''' constructor loads from a task or handler datastructure '''
self
.
play
=
play
# TODO: more error handling
# FIXME: error handling on invalid fields
# action...
self
.
name
=
ds
.
get
(
'name'
,
None
)
self
.
action
=
ds
.
get
(
'action'
,
''
)
self
.
play
=
play
self
.
name
=
ds
.
get
(
'name'
,
None
)
self
.
action
=
ds
.
get
(
'action'
,
''
)
self
.
notified_by
=
[]
if
self
.
name
is
None
:
...
...
@@ -53,8 +48,7 @@ class Task(object):
tokens
=
self
.
action
.
split
(
None
,
1
)
if
len
(
tokens
)
<
1
:
# FIXME: better error handling
raise
Exception
(
"invalid action in task:
%
s"
%
ds
)
raise
errors
.
AnsibleError
(
"invalid/missing action in task"
)
self
.
module_name
=
tokens
[
0
]
self
.
module_args
=
''
...
...
@@ -63,6 +57,7 @@ class Task(object):
# include task specific vars
self
.
module_vars
=
ds
.
get
(
'vars'
,
{})
if
'first_available_file'
in
ds
:
self
.
module_vars
[
'first_available_file'
]
=
ds
.
get
(
'first_available_file'
)
...
...
lib/ansible/runner/__init__.py
View file @
f6961e93
...
...
@@ -549,6 +549,9 @@ class Runner(object):
return
ReturnData
(
host
=
conn
.
host
,
comm_ok
=
False
,
result
=
result
)
if
self
.
module_vars
is
not
None
:
inject
.
update
(
self
.
module_vars
)
source
=
utils
.
template
(
source
,
inject
,
self
.
setup_cache
)
#(host, ok, data, err) = (None, None, None, None)
...
...
lib/ansible/runner/connection.py
View file @
f6961e93
...
...
@@ -42,15 +42,13 @@ with warnings.catch_warnings():
class
Connection
(
object
):
''' Handles abstract connections to remote hosts '''
_LOCALHOSTRE
=
re
.
compile
(
r"^(127.0.0.1|localhost|
%
s)$"
%
os
.
uname
()[
1
])
def
__init__
(
self
,
runner
,
transport
,
sudo_user
):
self
.
runner
=
runner
self
.
transport
=
transport
self
.
sudo_user
=
sudo_user
def
connect
(
self
,
host
,
port
=
None
):
conn
=
None
if
self
.
transport
==
'local'
and
self
.
_LOCALHOSTRE
.
search
(
host
)
:
if
self
.
transport
==
'local'
:
conn
=
LocalConnection
(
self
.
runner
,
host
)
elif
self
.
transport
==
'paramiko'
:
conn
=
ParamikoConnection
(
self
.
runner
,
host
,
port
)
...
...
library/virt
View file @
f6961e93
...
...
@@ -124,7 +124,6 @@ class LibvirtConnection(object):
def
get_status2
(
self
,
vm
):
state
=
vm
.
info
()[
0
]
# print "DEBUG: state: %s" % state
return
VIRT_STATE_NAME_MAP
.
get
(
state
,
"unknown"
)
def
get_status
(
self
,
vmid
):
...
...
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