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
aa23ea84
Commit
aa23ea84
authored
Jul 20, 2015
by
Pierre-Louis Bonicoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: checks that handlers work with loops
parent
a09ce4bd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
2 deletions
+20
-2
test/integration/Makefile
+2
-1
test/integration/roles/test_handlers/handlers/main.yml
+2
-0
test/integration/roles/test_handlers/tasks/main.yml
+14
-0
test/integration/test_handlers.yml
+2
-1
No files found.
test/integration/Makefile
View file @
aa23ea84
...
...
@@ -51,7 +51,8 @@ test_group_by:
ansible-playbook test_group_by.yml
-i
inventory.group_by
-e
@
$(VARS_FILE)
$(CREDENTIALS_ARG)
-v
$(TEST_FLAGS)
test_handlers
:
ansible-playbook test_handlers.yml
-i
inventory.handlers
-e
@
$(VARS_FILE)
$(CREDENTIALS_ARG)
-v
$(TEST_FLAGS)
ansible-playbook test_handlers.yml
--tags
scenario1
-i
inventory.handlers
-e
@
$(VARS_FILE)
$(CREDENTIALS_ARG)
-v
$(TEST_FLAGS)
[
"
$$
(ansible-playbook test_handlers.yml --tags scenario2 -l A -i inventory.handlers -e @
$(VARS_FILE)
$(CREDENTIALS_ARG)
-v
$(TEST_FLAGS)
| grep -Po 'RUNNING HANDLER
\[
test_handlers :
\K
[^
\]
]+')"
=
"test handler"
]
# Not forcing, should only run on successful host
[
"
$$
(ansible-playbook test_force_handlers.yml --tags normal -i inventory.handlers -e @
$(VARS_FILE)
$(CREDENTIALS_ARG)
-v
$(TEST_FLAGS)
| egrep -o CALLED_HANDLER_. | sort | uniq | xargs)"
=
"CALLED_HANDLER_B"
]
# Forcing from command line
...
...
test/integration/roles/test_handlers/handlers/main.yml
View file @
aa23ea84
-
name
:
set handler fact
set_fact
:
handler_called
:
True
-
name
:
test handler
debug
:
msg="handler called"
test/integration/roles/test_handlers/tasks/main.yml
View file @
aa23ea84
...
...
@@ -20,19 +20,33 @@
-
name
:
reset handler_called variable to
false
for all hosts
set_fact
:
handler_called
:
False
tags
:
scenario1
-
name
:
notify the handler for host A only
shell
:
echo
notify
:
-
set handler fact
when
:
inventory_hostname == 'A'
tags
:
scenario1
-
name
:
force handler execution now
meta
:
"
flush_handlers"
tags
:
scenario1
-
debug
:
var=handler_called
tags
:
scenario1
-
name
:
validate the handler only ran on one host
assert
:
that
:
-
"
inventory_hostname
==
'A'
and
handler_called
==
True
or
handler_called
==
False"
tags
:
scenario1
-
name
:
'
test
notify
with
loop'
debug
:
msg='a task'
changed_when
:
item == 1
notify
:
test handler
with_items
:
-
1
-
2
tags
:
scenario2
test/integration/test_handlers.yml
View file @
aa23ea84
...
...
@@ -4,7 +4,7 @@
gather_facts
:
False
connection
:
local
roles
:
-
{
role
:
test_handlers_meta
}
-
{
role
:
test_handlers_meta
,
tags
:
[
'
scenario1'
]
}
-
name
:
verify final handler was run
hosts
:
A
...
...
@@ -16,6 +16,7 @@
that
:
-
"
not
hostvars[inventory_hostname]['handler1_called']"
-
"
'handler2_called'
in
hostvars[inventory_hostname]"
tags
:
[
'
scenario1'
]
-
name
:
test handlers
hosts
:
testgroup
...
...
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