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
bced4c9d
Commit
bced4c9d
authored
Apr 23, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'jhoekx-custom-facts' into devel
parents
d60efc23
49cca98f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
13 deletions
+31
-13
lib/ansible/playbook.py
+8
-1
lib/ansible/runner.py
+8
-6
library/facter
+2
-0
library/ohai
+3
-0
library/setup
+6
-4
test/TestRunner.py
+4
-2
No files found.
lib/ansible/playbook.py
View file @
bced4c9d
...
...
@@ -397,6 +397,12 @@ class PlayBook(object):
module_args
,
module_vars
,
remote_user
,
async_seconds
,
async_poll_interval
,
only_if
,
sudo
,
transport
,
port
)
# add facts to the global setup cache
for
host
,
result
in
results
[
'contacted'
]
.
iteritems
():
if
"ansible_facts"
in
result
:
for
k
,
v
in
result
[
'ansible_facts'
]
.
iteritems
():
SETUP_CACHE
[
host
][
k
]
=
v
self
.
stats
.
compute
(
results
)
# if no hosts are matched, carry on, unlike /bin/ansible
...
...
@@ -528,7 +534,8 @@ class PlayBook(object):
if
vars_files
is
None
:
# first pass only or we'll erase good work
for
(
host
,
result
)
in
setup_ok
.
iteritems
():
SETUP_CACHE
[
host
]
=
result
if
'ansible_facts'
in
result
:
SETUP_CACHE
[
host
]
=
result
[
'ansible_facts'
]
# *****************************************************
...
...
lib/ansible/runner.py
View file @
bced4c9d
...
...
@@ -320,9 +320,9 @@ class Runner(object):
''' allows discovered variables to be used in templates and action statements '''
host
=
conn
.
host
try
:
var_result
=
utils
.
parse_json
(
result
)
e
xcept
:
if
'ansible_facts'
in
result
:
var_result
=
result
[
'ansible_facts'
]
e
lse
:
var_result
=
{}
# note: do not allow variables from playbook to be stomped on
...
...
@@ -349,10 +349,12 @@ class Runner(object):
if
module_name
==
'setup'
:
self
.
_add_result_to_setup_cache
(
conn
,
result
)
if
self
.
is_playbook
:
self
.
_save_setup_result_to_disk
(
conn
,
result
)
(
host
,
ok
,
data
,
err
)
=
self
.
_return_from_module
(
conn
,
host
,
result
,
err
,
executed
)
return
self
.
_return_from_module
(
conn
,
host
,
result
,
err
,
executed
)
if
ok
:
self
.
_add_result_to_setup_cache
(
conn
,
data
)
return
(
host
,
ok
,
data
,
err
)
# *****************************************************
...
...
library/facter
View file @
bced4c9d
...
...
@@ -22,4 +22,6 @@
# facter
# ruby-json
echo
'{ "ansible_facts":'
/usr/bin/facter
--json
echo
'}'
library/ohai
View file @
bced4c9d
...
...
@@ -18,4 +18,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
echo
'{ "ansible_facts":'
/usr/bin/ohai
echo
'}'
\ No newline at end of file
library/setup
View file @
bced4c9d
...
...
@@ -362,9 +362,11 @@ md5sum2 = os.popen("md5sum %s" % ansible_file).read().split()[0]
if
md5sum
!=
md5sum2
:
changed
=
True
setup_options
[
'written'
]
=
ansible_file
setup_options
[
'changed'
]
=
changed
setup_options
[
'md5sum'
]
=
md5sum2
setup_result
=
{}
setup_result
[
'written'
]
=
ansible_file
setup_result
[
'changed'
]
=
changed
setup_result
[
'md5sum'
]
=
md5sum2
setup_result
[
'ansible_facts'
]
=
setup_options
print
json
.
dumps
(
setup_
options
)
print
json
.
dumps
(
setup_
result
)
test/TestRunner.py
View file @
bced4c9d
...
...
@@ -85,15 +85,17 @@ class TestRunner(unittest.TestCase):
if
not
get_binary
(
"facter"
):
raise
SkipTest
result
=
self
.
_run
(
'facter'
,[])
assert
"hostname"
in
result
assert
"hostname"
in
result
[
'ansible_facts'
]
# temporarily disbabled since it occasionally hangs
# ohai's fault, setup module doesn't actually run this
# to get ohai's "facts" anyway
#
#def test_ohai(self):
# if not get_binary("facter"):
# raise SkipTest
# result = self._run('ohai',[])
# assert "hostname" in result
# assert "hostname" in result
['ansible_facts']
def
test_copy
(
self
):
# test copy module, change trigger, etc
...
...
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