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
3baf2dc0
Commit
3baf2dc0
authored
Feb 20, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding new test for conditional behavior
parent
87f2e362
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
202 additions
and
0 deletions
+202
-0
tests_new/integration/group_vars/all
+6
-0
tests_new/integration/non_destructive.yml
+1
-0
tests_new/integration/roles/test_conditionals/tasks/main.yml
+195
-0
No files found.
tests_new/integration/group_vars/all
View file @
3baf2dc0
...
@@ -7,5 +7,11 @@ dos: 2
...
@@ -7,5 +7,11 @@ dos: 2
tres: 3
tres: 3
etest: 'from group_vars'
etest: 'from group_vars'
inventory_beats_default: 'narf'
inventory_beats_default: 'narf'
# variables used for hash merging behavior testing
test_hash:
test_hash:
group_vars_all: "this is in group_vars/all"
group_vars_all: "this is in group_vars/all"
# variables used for conditional testing
test_bare: true
test_bare_var: 123
test_bare_nested_good: "{{test_bare_var}} == 123"
test_bare_nested_bad: "{{test_bare_var}} == 321"
tests_new/integration/non_destructive.yml
View file @
3baf2dc0
...
@@ -26,4 +26,5 @@
...
@@ -26,4 +26,5 @@
-
{
role
:
test_unarchive
,
tags
:
test_unarchive
}
-
{
role
:
test_unarchive
,
tags
:
test_unarchive
}
-
{
role
:
test_filters
,
tags
:
test_filters
}
-
{
role
:
test_filters
,
tags
:
test_filters
}
-
{
role
:
test_facts_d
,
tags
:
test_facts_d
}
-
{
role
:
test_facts_d
,
tags
:
test_facts_d
}
-
{
role
:
test_conditionals
,
tags
:
test_conditionals
}
tests_new/integration/roles/test_conditionals/tasks/main.yml
0 → 100644
View file @
3baf2dc0
# test code for conditional statements
# (c) 2014, James Cammarata <jcammarata@ansible.com>
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
name
:
test conditional '=='
shell
:
echo 'testing'
when
:
1 == 1
register
:
result
-
name
:
assert conditional '==' ran
assert
:
that
:
-
"
result.changed
==
true"
-
"
result.stdout
==
'testing'"
-
"
result.rc
==
0"
-
name
:
test bad conditional '=='
shell
:
echo 'testing'
when
:
0 == 1
register
:
result
-
name
:
assert bad conditional '==' did NOT run
assert
:
that
:
-
"
result.skipped
==
true"
-
name
:
test conditional '!='
shell
:
echo 'testing'
when
:
0 != 1
register
:
result
-
name
:
assert conditional '!=' ran
assert
:
that
:
-
"
result.changed
==
true"
-
"
result.stdout
==
'testing'"
-
"
result.rc
==
0"
-
name
:
test bad conditional '!='
shell
:
echo 'testing'
when
:
1 != 1
register
:
result
-
name
:
assert bad conditional '!=' did NOT run
assert
:
that
:
-
"
result.skipped
==
true"
-
name
:
test conditional 'in'
shell
:
echo 'testing'
when
:
1 in [1,2,3]
register
:
result
-
name
:
assert conditional 'in' ran
assert
:
that
:
-
"
result.changed
==
true"
-
"
result.stdout
==
'testing'"
-
"
result.rc
==
0"
-
name
:
test bad conditional 'in'
shell
:
echo 'testing'
when
:
1 in [7,8,9]
register
:
result
-
name
:
assert bad conditional 'in' did NOT run
assert
:
that
:
-
"
result.skipped
==
true"
-
name
:
test conditional 'not in'
shell
:
echo 'testing'
when
:
0 not in [1,2,3]
register
:
result
-
name
:
assert conditional 'not in' ran
assert
:
that
:
-
"
result.changed
==
true"
-
"
result.stdout
==
'testing'"
-
"
result.rc
==
0"
-
name
:
test bad conditional 'not in'
shell
:
echo 'testing'
when
:
1 not in [1,2,3]
register
:
result
-
name
:
assert bad conditional 'not in' did NOT run
assert
:
that
:
-
"
result.skipped
==
true"
-
name
:
test conditional 'is defined'
shell
:
echo 'testing'
when
:
test_bare is defined
register
:
result
-
name
:
assert conditional 'is defined' ran
assert
:
that
:
-
"
result.changed
==
true"
-
"
result.stdout
==
'testing'"
-
"
result.rc
==
0"
-
name
:
test bad conditional 'is defined'
shell
:
echo 'testing'
when
:
foo_asdf_xyz is defined
register
:
result
-
name
:
assert bad conditional 'is defined' did NOT run
assert
:
that
:
-
"
result.skipped
==
true"
-
name
:
test conditional 'is not defined'
shell
:
echo 'testing'
when
:
foo_asdf_xyz is not defined
register
:
result
-
name
:
assert conditional 'is not defined' ran
assert
:
that
:
-
"
result.changed
==
true"
-
"
result.stdout
==
'testing'"
-
"
result.rc
==
0"
-
name
:
test bad conditional 'is not defined'
shell
:
echo 'testing'
when
:
test_bare is not defined
register
:
result
-
name
:
assert bad conditional 'is not defined' did NOT run
assert
:
that
:
-
"
result.skipped
==
true"
-
name
:
test bare conditional
shell
:
echo 'testing'
when
:
test_bare
register
:
result
-
name
:
assert bare conditional ran
assert
:
that
:
-
"
result.changed
==
true"
-
"
result.stdout
==
'testing'"
-
"
result.rc
==
0"
-
name
:
test conditional using a variable
shell
:
echo 'testing'
when
:
test_bare_var == 123
register
:
result
-
name
:
assert conditional using a variable ran
assert
:
that
:
-
"
result.changed
==
true"
-
"
result.stdout
==
'testing'"
-
"
result.rc
==
0"
-
name
:
test good conditional based on nested variables
shell
:
echo 'testing'
when
:
test_bare_nested_good
register
:
result
-
name
:
assert good conditional based on nested var ran
assert
:
that
:
-
"
result.changed
==
true"
-
"
result.stdout
==
'testing'"
-
"
result.rc
==
0"
-
name
:
test bad conditional based on nested variables
shell
:
echo 'testing'
when
:
test_bare_nested_bad
register
:
result
-
name
:
assert that the bad nested conditional did NOT run
assert
:
that
:
-
"
result.skipped
==
true"
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