That only prints each droplet once, not count times. The original would
have given consul.1, consul.2, consul.3, etc.
On 05/29/2014 09:13 AM, James Cammarata wrote:
You can simplify that by just using with_items:
vars:
droplets:
- name: consul
count: 5
region: nyc2
region_id: 4
- name: influxdb
count: 3
region: nyc2
region_id: 4
- name: elasticsearch
count: 4
region: nyc2
region_id: 4
tasks:
- name: Print phone records
debug: msg="{{ item.name <http://item.name> }} in {{ item.region
}}({{ item.region_id }})"
with_items: droplets
Results in output like this:
ok: [127.0.0.1] => (item={'count': 5, 'region': 'nyc2', 'name':
'consul', 'region_id': 4}) => {
"item": {
"count": 5,
"name": "consul",
"region": "nyc2",
"region_id": 4
},
"msg": "consul in nyc2(4)"
}
On Thu, May 29, 2014 at 12:34 AM, <sma...@gmail.com
<mailto:sma...@gmail.com>> wrote:
Hey just wondering if there is a more elegant way of doing this:
---
droplets:
- name: consul
count: [1,2,3,4,5]
region: nyc2
region_id: 4
- name: influxdb
count: [1,2,3]
region: nyc2
region_id: 4
- name: elasticsearch
count: [1,2,3,4]
region: nyc2
region_id: 4
vars_files:
- vars/testing.yml
tasks:
- name: Print phone records
debug: msg="{{ item.0.name <http://item.0.name> }}.{{
item.1 }} in {{ item.0.region }}({{ item.0.region_id }})"
with_subelements:
- droplets
- count
this could get out of control if the counts got into the 100's
would be nice if I could do this:
- name: consul
count: 5
region: nyc2
region_id: 4
and it looped on the count 5 times.
hoping you have a more elegant solution for me :)
--
You received this message because you are subscribed to the Google
Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to ansible-project+unsubscr...@googlegroups.com
<mailto:ansible-project+unsubscr...@googlegroups.com>.
To post to this group, send email to
ansible-project@googlegroups.com
<mailto:ansible-project@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/0a5ac977-f227-47de-b8c1-f10951e3779b%40googlegroups.com
<https://groups.google.com/d/msgid/ansible-project/0a5ac977-f227-47de-b8c1-f10951e3779b%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google
Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to ansible-project+unsubscr...@googlegroups.com
<mailto:ansible-project+unsubscr...@googlegroups.com>.
To post to this group, send email to ansible-project@googlegroups.com
<mailto:ansible-project@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAMFyvFh9uAadSkSb7LaFGEpDEjGC9F6wSg%3Dye5ZH09niPF7gAw%40mail.gmail.com
<https://groups.google.com/d/msgid/ansible-project/CAMFyvFh9uAadSkSb7LaFGEpDEjGC9F6wSg%3Dye5ZH09niPF7gAw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Ansible
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/53875322.6090609%40brainfood.com.
For more options, visit https://groups.google.com/d/optout.