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
5122455d
Commit
5122455d
authored
Jul 03, 2015
by
Brian Coca
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ported missing sequence updates from 1.9
parent
8c29bba2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
7 deletions
+23
-7
lib/ansible/plugins/lookup/sequence.py
+17
-6
test/integration/roles/test_iterators/tasks/main.yml
+6
-1
No files found.
lib/ansible/plugins/lookup/sequence.py
View file @
5122455d
...
...
@@ -152,15 +152,26 @@ class LookupModule(LookupBase):
)
elif
self
.
count
is
not
None
:
# convert count to end
if
self
.
count
!=
0
:
self
.
end
=
self
.
start
+
self
.
count
*
self
.
stride
-
1
else
:
self
.
start
=
0
self
.
end
=
0
self
.
stride
=
0
del
self
.
count
if
self
.
end
<
self
.
start
:
raise
AnsibleError
(
"can't count backwards"
)
if
self
.
stride
>
0
and
self
.
end
<
self
.
start
:
raise
AnsibleError
(
"to count backwards make stride negative"
)
if
self
.
stride
<
0
and
self
.
end
>
self
.
start
:
raise
AnsibleError
(
"to count forward don't make stride negative"
)
if
self
.
format
.
count
(
'
%
'
)
!=
1
:
raise
AnsibleError
(
"bad formatting string:
%
s"
%
self
.
format
)
def
generate_sequence
(
self
):
numbers
=
xrange
(
self
.
start
,
self
.
end
+
1
,
self
.
stride
)
if
self
.
stride
>
0
:
adjust
=
1
else
:
adjust
=
-
1
numbers
=
xrange
(
self
.
start
,
self
.
end
+
adjust
,
self
.
stride
)
for
i
in
numbers
:
try
:
...
...
@@ -191,13 +202,13 @@ class LookupModule(LookupBase):
raise
AnsibleError
(
"unknown error parsing with_sequence arguments:
%
r. Error was:
%
s"
%
(
term
,
e
))
self
.
sanity_check
()
if
self
.
stride
!=
0
:
results
.
extend
(
self
.
generate_sequence
())
except
AnsibleError
:
raise
except
Exception
:
except
Exception
as
e
:
raise
AnsibleError
(
"unknown error generating sequence
"
"unknown error generating sequence
:
%
s"
%
e
)
return
results
test/integration/roles/test_iterators/tasks/main.yml
View file @
5122455d
...
...
@@ -81,10 +81,15 @@
with_sequence
:
count=0
register
:
count_of_zero
-
name
:
test with_sequence count 1
set_fact
:
"
{{
'x'
+
item
}}={{
item
}}"
with_sequence
:
count=1
register
:
count_of_one
-
assert
:
that
:
-
count_of_zero | skipped
-
not count_of_
zero | fail
ed
-
not count_of_
one | skipp
ed
# WITH_RANDOM_CHOICE
...
...
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