Ansible - What's the proper syntax for loop + zip when combining more than two lists?How does PHP 'foreach' actually work?Joining two lists of dicts based on unique key in Jinja2/Ansible using map() functionLoop through hosts with ansibleExtract filename from file result in ansibleansible: correct way to check a list of variables has been set?Iterating through nested dictionaries in Ansibles group_varsHow to provide Ansible default value that includes another variable?with_subelements when subelement is a dictionaryIssue in passing Loop values to Ansible Debug message
Are medical malpractice lawsuits part of the public record?
Why is Trump moving to Florida?
Why use a recurrent neural network over a feedforward neural network for sequence prediction?
How tall would a rainforest need to be to make it completely dark at ground level
Why are dates (of writing or publication) missing in scientific papers?
Max of the reversed of two numbers
CircuiTikZ: How to change the node options of labels and annotations?
Why does the single dot entry exist in file systems?
(Re-)entering UK academic system after a long time abroad
Are these special (one production) Context-Free Grammars always unambiguous?
Submitting list of forbidden words
Solve an ODE containing a 3rd degree polynomial
Why is Carbon Dioxide a Greenhouse Gas whereas Ammonia is not?
In the top five, I'm odd
Drying clothes: windy but cold outside vs warm(ish) inside?
Options for installing sub-panel
What are the catcode 11 / letter codepoints in Xe(La)Tex?
Famous statistical wins and horror stories for teaching purposes
Function to calculate "Nd6 take highest 2, sort descending" probabilities in AnyDice
Why is it possible to teach real numbers before even rigorously defining them?
Does Amoxicillin (as trihydrate) degrade in stomach acid?
Energy cost of C−N rotation in hydroxamate group
Is this a deadly encounter?
LWC not evaluating the if:true statement
Ansible - What's the proper syntax for loop + zip when combining more than two lists?
How does PHP 'foreach' actually work?Joining two lists of dicts based on unique key in Jinja2/Ansible using map() functionLoop through hosts with ansibleExtract filename from file result in ansibleansible: correct way to check a list of variables has been set?Iterating through nested dictionaries in Ansibles group_varsHow to provide Ansible default value that includes another variable?with_subelements when subelement is a dictionaryIssue in passing Loop values to Ansible Debug message
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
I haven't been able to find the syntax for loop + zip when combining more than 2 lists.
Since Ansible 2.5, as shown here, the following syntax replaces with_together with loop + zip:
- name: with_together
debug:
msg: " item.0 - item.1 "
with_together:
- " list_one "
- " list_two "
- name: with_together -> loop
debug:
msg: " item.0 - item.1 "
loop: "zip(list_two)"
My question is, whereas when using with_together, you could simply append lists, and reference them with iterating numbers, I haven't been able to find the method to use with loop + zip. I have tried:
loop: "zip(list_three)"
Without success.
loops ansible
add a comment
|
I haven't been able to find the syntax for loop + zip when combining more than 2 lists.
Since Ansible 2.5, as shown here, the following syntax replaces with_together with loop + zip:
- name: with_together
debug:
msg: " item.0 - item.1 "
with_together:
- " list_one "
- " list_two "
- name: with_together -> loop
debug:
msg: " item.0 - item.1 "
loop: "zip(list_two)"
My question is, whereas when using with_together, you could simply append lists, and reference them with iterating numbers, I haven't been able to find the method to use with loop + zip. I have tried:
loop: "zip(list_three)"
Without success.
loops ansible
add a comment
|
I haven't been able to find the syntax for loop + zip when combining more than 2 lists.
Since Ansible 2.5, as shown here, the following syntax replaces with_together with loop + zip:
- name: with_together
debug:
msg: " item.0 - item.1 "
with_together:
- " list_one "
- " list_two "
- name: with_together -> loop
debug:
msg: " item.0 - item.1 "
loop: "zip(list_two)"
My question is, whereas when using with_together, you could simply append lists, and reference them with iterating numbers, I haven't been able to find the method to use with loop + zip. I have tried:
loop: "zip(list_three)"
Without success.
loops ansible
I haven't been able to find the syntax for loop + zip when combining more than 2 lists.
Since Ansible 2.5, as shown here, the following syntax replaces with_together with loop + zip:
- name: with_together
debug:
msg: " item.0 - item.1 "
with_together:
- " list_one "
- " list_two "
- name: with_together -> loop
debug:
msg: " item.0 - item.1 "
loop: "zip(list_two)"
My question is, whereas when using with_together, you could simply append lists, and reference them with iterating numbers, I haven't been able to find the method to use with loop + zip. I have tried:
loop: "zip(list_three)"
Without success.
loops ansible
loops ansible
asked Mar 28 at 21:27
TravisTravis
285 bronze badges
285 bronze badges
add a comment
|
add a comment
|
1 Answer
1
active
oldest
votes
You can append additional arrays inside the zip filter itself.
zip(list, list, list, ...)
For example:
- hosts: localhost
become: false
gather_facts: false
tasks:
- vars:
list_one:
- one
- two
list_two:
- three
- four
list_three:
- five
- six
debug:
msg: " item.0 item.1 item.2 "
loop: " list_one "
When run:
PLAY [localhost] *********************************************************************************************************************************************
TASK [debug] *************************************************************************************************************************************************
ok: [localhost] => (item=['one', 'three', 'five']) =>
"msg": "one three five"
ok: [localhost] => (item=['two', 'four', 'six']) =>
"msg": "two four six"
PLAY RECAP ***************************************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0
Thanks so much. I couldn't find that documented anywhere online.
– Travis
Mar 29 at 12:20
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55407094%2fansible-whats-the-proper-syntax-for-loop-zip-when-combining-more-than-two-l%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can append additional arrays inside the zip filter itself.
zip(list, list, list, ...)
For example:
- hosts: localhost
become: false
gather_facts: false
tasks:
- vars:
list_one:
- one
- two
list_two:
- three
- four
list_three:
- five
- six
debug:
msg: " item.0 item.1 item.2 "
loop: " list_one "
When run:
PLAY [localhost] *********************************************************************************************************************************************
TASK [debug] *************************************************************************************************************************************************
ok: [localhost] => (item=['one', 'three', 'five']) =>
"msg": "one three five"
ok: [localhost] => (item=['two', 'four', 'six']) =>
"msg": "two four six"
PLAY RECAP ***************************************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0
Thanks so much. I couldn't find that documented anywhere online.
– Travis
Mar 29 at 12:20
add a comment
|
You can append additional arrays inside the zip filter itself.
zip(list, list, list, ...)
For example:
- hosts: localhost
become: false
gather_facts: false
tasks:
- vars:
list_one:
- one
- two
list_two:
- three
- four
list_three:
- five
- six
debug:
msg: " item.0 item.1 item.2 "
loop: " list_one "
When run:
PLAY [localhost] *********************************************************************************************************************************************
TASK [debug] *************************************************************************************************************************************************
ok: [localhost] => (item=['one', 'three', 'five']) =>
"msg": "one three five"
ok: [localhost] => (item=['two', 'four', 'six']) =>
"msg": "two four six"
PLAY RECAP ***************************************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0
Thanks so much. I couldn't find that documented anywhere online.
– Travis
Mar 29 at 12:20
add a comment
|
You can append additional arrays inside the zip filter itself.
zip(list, list, list, ...)
For example:
- hosts: localhost
become: false
gather_facts: false
tasks:
- vars:
list_one:
- one
- two
list_two:
- three
- four
list_three:
- five
- six
debug:
msg: " item.0 item.1 item.2 "
loop: " list_one "
When run:
PLAY [localhost] *********************************************************************************************************************************************
TASK [debug] *************************************************************************************************************************************************
ok: [localhost] => (item=['one', 'three', 'five']) =>
"msg": "one three five"
ok: [localhost] => (item=['two', 'four', 'six']) =>
"msg": "two four six"
PLAY RECAP ***************************************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0
You can append additional arrays inside the zip filter itself.
zip(list, list, list, ...)
For example:
- hosts: localhost
become: false
gather_facts: false
tasks:
- vars:
list_one:
- one
- two
list_two:
- three
- four
list_three:
- five
- six
debug:
msg: " item.0 item.1 item.2 "
loop: " list_one "
When run:
PLAY [localhost] *********************************************************************************************************************************************
TASK [debug] *************************************************************************************************************************************************
ok: [localhost] => (item=['one', 'three', 'five']) =>
"msg": "one three five"
ok: [localhost] => (item=['two', 'four', 'six']) =>
"msg": "two four six"
PLAY RECAP ***************************************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0
answered Mar 28 at 22:32
NickNick
9229 silver badges19 bronze badges
9229 silver badges19 bronze badges
Thanks so much. I couldn't find that documented anywhere online.
– Travis
Mar 29 at 12:20
add a comment
|
Thanks so much. I couldn't find that documented anywhere online.
– Travis
Mar 29 at 12:20
Thanks so much. I couldn't find that documented anywhere online.
– Travis
Mar 29 at 12:20
Thanks so much. I couldn't find that documented anywhere online.
– Travis
Mar 29 at 12:20
add a comment
|
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55407094%2fansible-whats-the-proper-syntax-for-loop-zip-when-combining-more-than-two-l%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown