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
6ab615c7
Commit
6ab615c7
authored
Mar 23, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanup for playbooks, also added 'on_skipped' callback
parent
24964b96
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
15 deletions
+54
-15
lib/ansible/callbacks.py
+3
-0
lib/ansible/playbook.py
+0
-0
test/TestPlayBook.py
+5
-1
test/playbook1.events
+30
-11
test/playbook1.yml
+16
-3
No files found.
lib/ansible/callbacks.py
View file @
6ab615c7
...
...
@@ -60,6 +60,9 @@ class PlaybookCallbacks(object):
else
:
print
"ok: [
%
s] =>
%
s
\n
"
%
(
host
,
invocation
)
def
on_skipped
(
self
,
host
):
print
"skipping: [
%
s]
\n
"
%
host
def
on_import_for_host
(
self
,
host
,
imported_file
):
print
"
%
s: importing
%
s"
%
(
host
,
imported_file
)
...
...
lib/ansible/playbook.py
View file @
6ab615c7
This diff is collapsed.
Click to expand it.
test/TestPlayBook.py
View file @
6ab615c7
...
...
@@ -32,6 +32,9 @@ class TestCallbacks(object):
def
on_setup_secondary
(
self
):
self
.
events
.
append
([
'secondary_setup'
])
def
on_skipped
(
self
,
host
):
self
.
events
.
append
([
'skipped'
,
[
host
]])
def
on_import_for_host
(
self
,
host
,
filename
):
self
.
events
.
append
([
'import'
,
[
host
,
filename
]])
...
...
@@ -47,8 +50,9 @@ class TestCallbacks(object):
def
on_failed
(
self
,
host
,
results
):
self
.
events
.
append
([
'failed'
,
[
host
,
results
]])
def
on_ok
(
self
,
host
,
host_
result
):
def
on_ok
(
self
,
host
,
result
):
# delete certain info from host_result to make test comparisons easier
host_result
=
result
.
copy
()
for
k
in
[
'ansible_job_id'
,
'invocation'
,
'md5sum'
,
'delta'
,
'start'
,
'end'
]:
if
k
in
host_result
:
del
host_result
[
k
]
...
...
test/playbook1.events
View file @
6ab615c7
...
...
@@ -31,7 +31,7 @@
"import",
[
"127.0.0.1",
"/home/mdehaan/ansible/test/
default_os
.yml"
"/home/mdehaan/ansible/test/
CentOS
.yml"
]
],
[
...
...
@@ -213,6 +213,28 @@
[
"task start",
[
"this should be skipped",
false
]
],
[
"skipped",
[
"127.0.0.1"
]
],
[
"ok",
[
"127.0.0.1",
{
"skipped": true
}
]
],
[
"task start",
[
"on change 1",
true
]
...
...
@@ -222,12 +244,10 @@
[
"127.0.0.1",
{
"cmd": [
"/bin/true"
],
"cmd": "echo this should fire once ",
"rc": 0,
"stderr": "",
"stdout": ""
"stdout": "
this should fire once
"
}
]
],
...
...
@@ -243,12 +263,10 @@
[
"127.0.0.1",
{
"cmd": [
"/bin/true"
],
"cmd": "echo this should fire once also ",
"rc": 0,
"stderr": "",
"stdout": ""
"stdout": "
this should fire once also
"
}
]
]
...
...
@@ -258,8 +276,9 @@
"changed": 2,
"dark": 0,
"failed": 0,
"resources":
9
,
"skipped":
0
"resources":
12
,
"skipped":
1
}
}
}
test/playbook1.yml
View file @
6ab615c7
# extremely simple test of the most basic of playbook engine/functions
---
-
hosts
:
all
# the 'weasels' string should show up in the output
vars
:
answer
:
"
Wuh,
I
think
so,
Brain,
but
if
we
didn't
have
ears,
we'd
look
like
weasels."
port
:
5150
# we should have import events for common_vars and CentOS.yml (if run on CentOS)
# sorry, tests are a bit platform specific just for now
vars_files
:
-
common_vars.yml
-
[
'
$facter_operatingsystem.yml'
,
'
default_os.yml'
]
...
...
@@ -46,20 +53,26 @@
async
:
10
poll
:
3
# the following command should be skipped
-
name
:
this should be skipped
action
:
shell echo 'if you see this, this is wrong ($facter_operatingsystem)'
only_if
:
"
'$facter_operatingsystem'
==
'Imaginary'"
handlers
:
# in the above test example, this should fire ONCE (at the end)
-
name
:
on change 1
action
:
command /bin/true
action
:
shell echo 'this should fire once'
# in the above test example, this should fire ONCE (at the end)
-
name
:
on change 2
action
:
command /bin/true
action
:
shell echo 'this should fire once also'
# in the above test example, this should NOT FIRE
-
name
:
on change 3
action
:
command /bin/true
action
:
shell echo 'if you see this, this is wrong'
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