Hi i'm able to create dynamic facts but i have a problem using them in 
other task

i set the facts like this:

- name: set security_groups facts
  set_fact:
    "{{ item.item.name | replace('-', '_') }}_group":
      name: "{{ item.item.name }}"
      group_id: "{{ item.group_id }}"
      rules: "{{ item.item.rules }}"
      state: "{{ item.item.state }}"
  with_items: ec2_groups.results

and are accessible calling like this

- debug: var=monitor_server_group
- debug: var=monitor_test_1_group
- debug: var=monitor_test_2_group

but when i try to do this

- name: Create EC2 instances per subnets
  ec2:
    profile: "{{ boto_profile }}"
    key_name: "{{ item[1].name }}"
    region: "{{ vpc.region }}"
    *group_id: "{{ item[1].name | replace('-', '_') ~ '_group' }}.group_id"*
    instance_type: "{{ item[1].instance_type }}"
    image: "{{ item[1].ami }}"
    vpc_subnet_id: "{{ item[0] }}"
    monitoring: yes
    wait: yes
    instance_tags:
      env: "{{ linio_environment }}"
      Name: "{{ item[1].name }}"
      role: "{{ item[1].role }}"
      group: "{{ item[1].host_group }}"
      cap_stage: "{{ item[1].role }}"
    count_tag: "{{ item[1].name }}"
    exact_count: "{{ item[1].instances }}"
  with_nested:
    - vpc.subnets.security.private_subnet_ids
    - ec2_instances_configuration
  register: api_instances_facts


i got:

<Response><Errors><Error><Code>InvalidGroupId.Malformed</Code><Message>Invalid 
id: "monitor_test_2_group.group_id"

how can i use the name as variable object instead of a string

-- 
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/588b67fc-bb66-4536-9f13-a108cf6b3f84%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to