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
7669a0b2
Commit
7669a0b2
authored
Apr 21, 2015
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing some v2 bugs
parent
d996a2c2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
8 deletions
+16
-8
v2/ansible/parsing/__init__.py
+1
-1
v2/ansible/plugins/action/set_fact.py
+1
-1
v2/ansible/vars/__init__.py
+14
-6
No files found.
v2/ansible/parsing/__init__.py
View file @
7669a0b2
...
...
@@ -120,7 +120,7 @@ class DataLoader():
return
os
.
path
.
isdir
(
path
)
def
list_directory
(
self
,
path
):
return
os
.
path
.
listdir
(
path
)
return
os
.
listdir
(
path
)
def
_safe_load
(
self
,
stream
,
file_name
=
None
):
''' Implements yaml.safe_load(), except using our custom loader class. '''
...
...
v2/ansible/plugins/action/set_fact.py
View file @
7669a0b2
...
...
@@ -35,4 +35,4 @@ class ActionModule(ActionBase):
if
isinstance
(
v
,
basestring
)
and
v
.
lower
()
in
(
'true'
,
'false'
,
'yes'
,
'no'
):
v
=
boolean
(
v
)
facts
[
k
]
=
v
return
dict
(
changed
=
Tru
e
,
ansible_facts
=
facts
)
return
dict
(
changed
=
Fals
e
,
ansible_facts
=
facts
)
v2/ansible/vars/__init__.py
View file @
7669a0b2
...
...
@@ -29,6 +29,7 @@ except ImportError:
from
sha
import
sha
as
sha1
from
ansible
import
constants
as
C
from
ansible.errors
import
*
from
ansible.parsing
import
DataLoader
from
ansible.plugins.cache
import
FactCache
from
ansible.template
import
Templar
...
...
@@ -78,14 +79,19 @@ class VariableManager:
def
set_inventory
(
self
,
inventory
):
self
.
_inventory
=
inventory
def
_validate_both_dicts
(
self
,
a
,
b
):
'''
Validates that both arguments are dictionaries, or an error is raised.
'''
if
not
(
isinstance
(
a
,
dict
)
and
isinstance
(
b
,
dict
)):
raise
AnsibleError
(
"failed to combine variables, expected dicts but got a '
%
s' and a '
%
s'"
%
(
type
(
a
)
.
__name__
,
type
(
b
)
.
__name__
))
def
_combine_vars
(
self
,
a
,
b
):
'''
Combines dictionaries of variables, based on the hash behavior
'''
# FIXME: do we need this from utils, or should it just
# be merged into this definition?
#_validate_both_dicts(a, b)
self
.
_validate_both_dicts
(
a
,
b
)
if
C
.
DEFAULT_HASH_BEHAVIOUR
==
"merge"
:
return
self
.
_merge_dicts
(
a
,
b
)
...
...
@@ -100,9 +106,7 @@ class VariableManager:
result
=
dict
()
# FIXME: do we need this from utils, or should it just
# be merged into this definition?
#_validate_both_dicts(a, b)
self
.
_validate_both_dicts
(
a
,
b
)
for
dicts
in
a
,
b
:
# next, iterate over b keys and values
...
...
@@ -183,6 +187,8 @@ class VariableManager:
try
:
vars_file
=
templar
.
template
(
vars_file
)
data
=
loader
.
load_from_file
(
vars_file
)
if
data
is
None
:
data
=
dict
()
all_vars
=
self
.
_combine_vars
(
all_vars
,
data
)
except
:
# FIXME: get_vars should probably be taking a flag to determine
...
...
@@ -258,6 +264,8 @@ class VariableManager:
else
:
data
=
loader
.
load_from_file
(
path
)
if
data
is
None
:
data
=
dict
()
name
=
self
.
_get_inventory_basename
(
path
)
return
(
name
,
data
)
...
...
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