Hi,

I'm trying to use the rds_subnet_group module to create a subnet group with 
all the subnets defined in my VPC, but I'm having trouble finding a way of 
using the subnet ids from a registered vpc variable.

So, first I create a VPC & register the response:

  - name: Create VPC
    local_action: 
      module: ec2_vpc
      state: present
      subnets: ...
      route_tables: ...
    register: vpc

This works well and the result looks like:

TASK: [debug var=vpc] 
********************************************************* 
ok: [localhost] => {
    "vpc": {
        "changed": true, 
        "invocation": {
            "module_args": "", 
            "module_name": "ec2_vpc"
        }, 
        "subnets": [
            {
                "az": "eu-west-11", 
                "cidr": "10.55.81.0/24", 
                "id": "subnet-d1d21ea6", 
                "resource_tags": {
                    "Environment": "test", 
                    "Name": "test_euw1a_app", 
                }
            },
            { ... } ] }

Now I'd like to use the subnet ids (subnets.id) in this response when 
creating a RDS subnet with all of them attached:

  - name: Create DB subnet group 
    local_action:
      module: rds_subnet_group
      state: present
      name: "rds-sg"
      description: "rds-sg"
      subnets: 
        - "{{ item.id }}"
    with_items: vpc.subnets

The problem is that if I have the with_item on the same level of 
local_action it seems to make N calls to rds_subnet_group (each with one of 
the ids) with fail with:
msg: DB Subnet Group doesn't meet availability zone coverage requirement. 
Please add subnets to cover at least 2 availability zones. Current 
coverage: 1

So I'd like to add all the subnets in one go (single call with all subnet 
ids defined for the "subnets" parameter). With_items doesn't seem to work 
when it's nested on the same level with the other params (subnets/state) - 
instead I get the error: 
fatal: [localhost -> 127.0.0.1] => One or more undefined variables: 'item' 
is undefined

What would be the best way to use all the vpc.subnets.id values in a list 
and supply those to rds_subnet_group.subnets in one go?

Best regards,
Timo


-- 
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/5a4543b8-d054-4c14-99a6-965ffb41d582%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to