I am not quite sure what {{something}} was supposed to be here ?
Le mercredi 7 octobre 2020 à 14:50:31 UTC-7, Nick-H a écrit :
> thanks Matt,
> here is the real example , trying to remove multiple IAM policies from a
> bunch of users
>
> - name: assign policies to a given user
> iam_policy:
> iam_type: user
> iam_name: "{{ item }}"
> state: absent
> policy_name: "{{ starts_with('database_access-(ro|rw)') }}" ## here
> I need to wildcard to any policy starting with that string .
> # policy_name: "database_access-(ro | rw)" # the other
> possibility is to find a switch like here so it can either do
> database_access-ro OR database_access_rw , regex maybe ?
>
> loop: "{{ my_users }}"
>
> As I already have one loop for users , I was trying to find a filter that
> I could directly pass in the 'policy_name' parameter .
>
>
>
> Le mercredi 7 octobre 2020 à 14:20:49 UTC-7, Matt Martz a écrit :
>
>> I have no idea what your goal is, and without giving a concrete example
>> with an actual module I cannot say.
>>
>> You want to loop some list variable, but limit to only values that start
>> with prefixed- from that list?
>>
>> loop: "{{ something|select('match', 'prefixed-.*')|list }}"
>>
>> Or you could do:
>>
>> loop: "{{ something }}'
>> when: item.startswith('prefixed-')
>>
>> On Wed, Oct 7, 2020 at 4:15 PM Nick-H <[email protected]> wrote:
>>
>>> hi, again a very simple use case in appearance but that is driving me
>>> nuts to realize with ansible, anyone ever done :
>>> tasks:
>>> - name: run a module
>>> any_module:
>>> users: {{item}} # I want to loop first here
>>> state: absent
>>> name: "prefixed-*" # basically anything that starts with 'prefixed'
>>>
>>> I tried :
>>> - as above just using the wildcard symbol , doesn't work
>>> Things that comes to mind :
>>> - use startswith , but can't find the syntax that would fit here
>>> - use another loop, but that tales me to the slope of nested_loops ,
>>> something I was NEVER able to make it working.
>>>
>>> any simple possibility to just use wildcard in a string ?
>>>
>>> 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 [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/2b7ce081-b637-43f0-875b-3fb1202501c2n%40googlegroups.com
>>>
>>> <https://groups.google.com/d/msgid/ansible-project/2b7ce081-b637-43f0-875b-3fb1202501c2n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>
>>
>> --
>> Matt Martz
>> @sivel
>> sivel.net
>>
>
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/5f6d763b-cdaa-475a-8ead-6e5ab1f0d3ddn%40googlegroups.com.