Hi Micheal,

I will try your approach but I found it no so pretty as suggested :)

Thanks
Peter

From: Michael DeHaan <[email protected]<mailto:[email protected]>>
Reply-To: 
"[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Date: Friday 25 July 2014 01:46
To: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Subject: Re: [ansible-project] using 2 loops with_first_found and with_items

Can't combine these two things.

Also, when using with_foo: var, don't use jinja2.

Not like:

with_items: "{{ foo }}"

Do it like so:

with_items: alist_variable

I'd just have a bunch of templates like so:

- template: src={{ item}} dest=/etc/apt/sources.list.d/{{ item.basename }}
  with_fileglob: '*.sources.j2'

You may need to reference a hash that keys off of something like "{{ item | 
basename }}" inside your template, such as

{# set basename = item|basename #}
{{ repo_url[basename] }}

etc

Sort of make sense?





On Wed, Jul 23, 2014 at 12:24 AM, Hudec Peter 
<[email protected]<mailto:[email protected]>> wrote:
Hi,

I’m trying to write role for configuration of the package management. In
this role I following setup.

— defaults/main.yml
debain_source_list:
  - name: debian
  state: enabled
- name: debian-backports
  state: enabled
- name: debian-lts
  state: enabled





— task/setup-Debian.yml
- name: "[repository] apt source list files"
  action: template src=???? dest=/etc/apt/sources.d/????.list
  with_items: " {{ debain_source_list }}"
  when: "item.state != 'enabled'"
  with_first_found:
  - {{ item.name<http://item.name> }}.list.{{ 
ansible_lsb.id<http://ansible_lsb.id> }}.{{ ansible_lsb.codename }}
  - default.list


The idea is to have separate source list files for each Debian release
/wheeze, squeeze, …/, if the file is not found put there some default
file. The problem is how to run more loops and address variables in one
action.

Consider this to be an example and will be used as template for another
actions. I do not want to sync the directories.

        Best regards
                Peter Hudec

--
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 
[email protected]<mailto:ansible-project%[email protected]>.
To post to this group, send email to 
[email protected]<mailto:[email protected]>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CFF505AC.3A5BF%25peter.hudec%40cnc.sk.
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 
[email protected]<mailto:[email protected]>.
To post to this group, send email to 
[email protected]<mailto:[email protected]>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgzXkAfD1SS74bnwmSpPz0zfJ0ivwyEwwBoxmbR0NSB7UA%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgzXkAfD1SS74bnwmSpPz0zfJ0ivwyEwwBoxmbR0NSB7UA%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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CFFC1B93.3AE1E%25peter.hudec%40cnc.sk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to