On 8/13/20 8:00 PM, Nick-H wrote:
> so, I have been trying with lookup('dict')  but still not quite close to the 
> expected result 
> I get: " An unhandled exception occurred while running the lookup plugin 
> 'dict'. Error was a <class
> 'ansible.errors.AnsibleError'>, original message: with_dict expects a dict"
> her is the last code :
> 
>   iam_managed_policy:
>     policy_name: "{{ item.name }}"
>     policy: "{{ item.policy }}"
>     state: present
>   loop:
>     - { name: "rds-{{ lookup('dict', mysql_privilege[0].value ) }} ", policy: 
> "{{ lookup('template', 'template.json.j2') }}" }
>     # - { name: "rds-{{ lookup('nested', mysql_privilege[role] ) }} ", 
> policy: "{{ lookup('template', 'template.json.j2') }}" }
>   vars:
>     mysql_privilege:
>         role:
>           - rw
>           - ro
>         regions:    
>           - us-west-1
>           - us-west-2
> 

What are the possible values for policy_name? The value for the "policy" seems 
to the same lookup so you don't need in
the loop.

I'm pretty sure that you are running into brick walls for a possibly simple 
problem.

So please explain / give examples how the policy_name is constructed.

Regards
         Racke

> 
> 
> 
> Le mercredi 12 août 2020 à 17:27:22 UTC-7, Nick-H a écrit :
> 
>     Hi, I have been looking into /nested /, /subelements /and other /lookups 
> /with no luck to make this working , using
>     ansible 2.8. 
>     Basically , I'd like to construct a loop than can itself iterate over 
> other variables (list or dict). 
>     *  iam_managed_policy:*
>     *    policy_name: "{{ item.name <http://item.name> }}"*
>     *    policy: "{{ item.policy }}"*
>     *    state: present*
>     *  loop:*
>     *    - { name: "rds-{{mysql_privilege}}-{{regions}}", policy: "{{ 
> lookup('template', template.json.j2') }}" }*
>     *  vars:*
>     *    mysql_privilege:**  *
>     *        - rw*
>     *        - ro*
>     *    regions:    *
>     *        - us-west-1*
>     *        - us-west-2*
> 
>     but it end up with such result:
>     "Couldn't create policy rds-prod-[u'rw', u'ro'] - [u'ca-central-1', 
> u'us-west-1']"
> 
>     What i d like is each loop would build a 2 dimensions array with the vars 
> elements ( rw-us-west-1 , rw-us-west-2, 
>     ro-us-west-1, ro-us-west-2)
> 
>     Is that even possible to achieve with ansible ? 
>     thanks
> 
> -- 
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/bacb4345-c3a7-4663-9931-91b3f0225175n%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/bacb4345-c3a7-4663-9931-91b3f0225175n%40googlegroups.com?utm_medium=email&utm_source=footer>.


-- 
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/4e5341ef-8f83-34e3-41d5-21ae179b24c6%40linuxia.de.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to