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
65e58c21
Commit
65e58c21
authored
Feb 21, 2014
by
James Tanner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for basic lookups
parent
799fe2c2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
0 deletions
+88
-0
test/integration/non_destructive.yml
+1
-0
test/integration/roles/test_lookups/meta/main.yml
+3
-0
test/integration/roles/test_lookups/tasks/main.yml
+84
-0
No files found.
test/integration/non_destructive.yml
View file @
65e58c21
...
@@ -30,4 +30,5 @@
...
@@ -30,4 +30,5 @@
-
{
role
:
test_conditionals
,
tags
:
test_conditionals
}
-
{
role
:
test_conditionals
,
tags
:
test_conditionals
}
-
{
role
:
test_async
,
tags
:
test_async
}
-
{
role
:
test_async
,
tags
:
test_async
}
-
{
role
:
test_handlers
,
tags
:
test_handlers
}
-
{
role
:
test_handlers
,
tags
:
test_handlers
}
-
{
role
:
test_lookups
,
tags
:
test_lookups
}
test/integration/roles/test_lookups/meta/main.yml
0 → 100644
View file @
65e58c21
dependencies
:
-
prepare_tests
test/integration/roles/test_lookups/tasks/main.yml
0 → 100644
View file @
65e58c21
# test code for lookup plugins
# (c) 2014, James Tanner <tanner.jc@gmail.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/>.
# FILE LOOKUP
-
name
:
make a new file to read
copy
:
dest={{output_dir}}/foo.txt mode=0644 content="bar"
-
name
:
load the file as a fact
set_fact
:
foo
:
"
{{
lookup('file',
output_dir
+
'/foo.txt'
)
}}"
-
debug
:
var=foo
-
name
:
verify file lookup
assert
:
that
:
-
"
foo
==
'bar'"
# PASSWORD LOOKUP
-
name
:
remove previous password files
file
:
dest={{output_dir}}/password state=absent
-
name
:
create a password file
set_fact
:
newpass
:
"
{{
lookup('password',
output_dir
+
'/password
length=8')
}}"
-
name
:
get password length
shell
:
wc -c {{output_dir}}/password | awk '{print $1}'
register
:
wc_result
-
debug
:
var=wc_result.stdout
-
name
:
read password
shell
:
cat {{output_dir}}/password
register
:
cat_result
-
debug
:
var=cat_result.stdout
-
name
:
verify password
assert
:
that
:
-
"
wc_result.stdout
==
'9'"
-
"
cat_result.stdout
==
newpass"
# ENV LOOKUP
-
name
:
get first environment var name
shell
:
env | head -n1 | cut -d\= -f1
register
:
known_var_name
-
name
:
get first environment var value
shell
:
echo {{ '$' + known_var_name.stdout }}
register
:
known_var_value
-
name
:
use env lookup to get known var
set_fact
:
test_val
:
"
{{
lookup('env',
known_var_name.stdout)
}}"
-
debug
:
var=known_var_name.stdout
-
debug
:
var=known_var_value.stdout
-
debug
:
var=test_val
-
name
:
compare values
assert
:
that
:
-
"
test_val
==
known_var_value.stdout"
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