You could perhaps template your desired variables and values into a file, 
then use the ansible.builtin.include_vars module to read them in.
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/include_vars_module.html

On Thursday, August 3, 2023 at 6:02:14 PM UTC-4 solarflow 99 wrote:

> I wonder if something like this can be done, the problem i'm seeing is 
> that the fact name has to be static, and could not use {{ item }}:
>
>    - name: Set each tag to facts
>      set_fact:
>        list_of_vars: "{{ my_instance.instances | 
> map(attribute='tags.list_of_vars') | list | join('\n') }}"
>
>    - name: Split "list_of_vars" variable into a comma separated list
>      set_fact:
>        item_list: "{{ list_of_vars.split(',') }}"
>
>    - name: lookup SSM Parameter Store secrets
>      set_fact:
>       * {{ item }}:* "{{ lookup('amazon.aws.ssm_parameter', 
> puppet_env+'_'+env+'_{{ item }}', region=ansible_ec2_placement_region) }}"
>      with_items: "{{ item_list }}"
>
>
> This would give me a fact for each comma separated var I put in the tag, 
> if only it worked.  Is there a better way to do something like this?
>

-- 
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/5d4f4026-2a54-495d-8089-5cfaa57d14f2n%40googlegroups.com.

Reply via email to