Ansible when creating an RDS instance: AttributeError: 'dict' object has no attribute 'split'

496 views
Skip to first unread message

Rahul Mehrotra

unread,
Feb 26, 2015, 11:06:55 AM2/26/15
to ansible...@googlegroups.com
I am working on creating an AWS infrastructure based on Ansible. 
I have a playbook which creates an RDS instance. When I run the playbook standalone it executes perfectly & creates RDS instance. However when that playbook is called by another playbook using the 

include: rds.yml 

It gives the following error

 TASK: [create mysql RDS instance] ********************************************* 
failed: [localhost -> 127.0.0.1] => {"failed": true, "parsed": false}
Traceback (most recent call last):

  File "/home/rahul/.ansible/tmp/ansible-tmp-1424469014.33-157847268952956/rds", line 2419, in <module>
    main()
  
 File "/home/rahul/.ansible/tmp/ansible-tmp-1424469014.33-157847268952956/rds", line 468, in main
    params["vpc_security_groups"] = vpc_security_groups.split(',')
AttributeError: 'dict' object has no attribute 'split'
FATAL: all hosts have already failed -- aborting



The ansible playbook for RDS which I am using is as follows

    ---
    - hosts: localhost
      gather_facts: no
      vars_files:
       - ../group_vars/dev_vpc
       - ../group_vars/dev_sg
       - ../hosts_vars/ec2_info
       - ../hosts_vars/rds_info
      vars:
        instance_type: db.m1.medium
        db_engine: MySQL
        engine_version: 5.6.19a
        subnet: dev-subnet-group
        iops: 1000
        db_name: dev_rds
      tasks:
       - name: Creating RDS subnet group
         local_action:
         module: rds_subnet_group
         state: present
         name: "{{ subnet }}"
         region: "{{ region }}"
         description: Subnet Group for RDS instance
         subnets:
           - "{{ PrivateSubnetA }}"
           - "{{ PrivateSubnetB }}"
     - name: create mysql RDS instance
       local_action:
         module: rds
         command: create
         instance_name: dev-rds
         region: "{{ region }}"
         size: 100
         instance_type: "{{ instance_type }}"
         db_engine: "{{ db_engine }}"
         engine_version: "{{ engine_version }}"
         subnet: "{{ subnet }}"
         multi_zone: yes
         db_name: "{{ db_name }}"
         username: "{{ username }}"
         password: "{{ pass }}"
         vpc_security_groups: "{{ sg_mysql  }}"
         iops: "{{ iops }}"  


I have searched a lot on the internet and wasn't able to find a correct answer. Can anyone point out my mistake. Thank you


adding task debug: var=sg_mysql gives the following result

ok: [localhost] => { "var": { "sg_mysql": { "changed": false, "group_id": "sg-d73012b2", "invocation": { "module_args": "", "module_name": "ec2_group" } } } }

Brian Coca

unread,
Feb 26, 2015, 11:13:31 AM2/26/15
to ansible...@googlegroups.com
it should be:

- include: rds.yml




--
Brian Coca

Rahul Mehrotra

unread,
Feb 26, 2015, 11:21:29 AM2/26/15
to ansible...@googlegroups.com

The main playbook has it as
- include: rds.yml

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/55lmxGpX07w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAJ5XC8m9VqBdmvQ5fN%2BtVtq9pRikGZqMF0ECT6ef4xH7Ao1%2BaQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Brian Coca

unread,
Feb 26, 2015, 11:23:04 AM2/26/15
to ansible...@googlegroups.com
the error seems to indicate bad data is being passed to the rds module



--
Brian Coca

Rahul Mehrotra

unread,
Feb 26, 2015, 11:40:41 AM2/26/15
to ansible...@googlegroups.com

I am not able to figure out which specific vars is bad...
Is there a problem of file locking ???
Because there is a sg_mysql.yml file being called before rds.yml in main.yml

Something like

- include: sg_mysql.yml
- include: rds.yml

sg_mysql.yml is writing the security group id to be used by rds.yml

However the debug task on sg_mysql shows that the id is getting read correctly by rds.yml.

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/55lmxGpX07w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

Ravi Bhure

unread,
Feb 26, 2015, 12:01:50 PM2/26/15
to ansible...@googlegroups.com
I am also facing the same issue while creating security group on aws, using Ansible 1.8.3 version and 1.6, not really sure but this is something wrong at aws api library ?

Dan Vaida

unread,
Feb 26, 2015, 12:08:41 PM2/26/15
to ansible...@googlegroups.com
Try this instead: 
vpc_security_groups: "{{ sg_mysql.group_id  }}"

Rahul Mehrotra

unread,
Feb 26, 2015, 4:01:36 PM2/26/15
to ansible...@googlegroups.com
That fixed it... Thank you :)
Reply all
Reply to author
Forward
0 new messages