创建RDS实例时可以接受:AttributeError:' dict'对象没有属性' split'

时间:2015-02-23 17:47:28

标签: python amazon-web-services ansible ansible-playbook rds

我正致力于创建基于Ansible的AWS基础架构。 我有一个创建RDS实例的剧本。当我独立运行Playbook时,它可以完美地执行。创建RDS实例。然而,当该剧本被另一本剧本使用

调用时
  

包括:rds.yml

它出现以下错误

  

任务:[创建mysql RDS实例] *************************************** ******   失败:[localhost - > 127.0.0.1] => {"失败":是,"解析":false}   回溯(最近一次调用最后一次):

     

文件" /home/rahul/.ansible/tmp/ansible-tmp-1424469014.33-157847268952956/rds" ;,第2419行,       main()的

     

文件" /home/rahul/.ansible/tmp/ansible-tmp-1424469014.33-157847268952956/rds" ;,第468行,主要内容       params [" vpc_security_groups"] = vpc_security_groups.split(',')   AttributeError:' dict'对象没有属性' split'

     

致命:所有主机都已经失败 - 正在中止

我使用的RDS的ansible剧本如下

---
- 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 }}"  

我在互联网上搜索了很多,但无法找到正确的答案。任何人都可以指出我的错误。谢谢

1 个答案:

答案 0 :(得分:0)

问题通过替换

解决了

vpc_security_groups:" {{sg_mysql}}"

vpc_security_groups:" {{sg_mysql.group_id}}"

问题是由于错误的数据传递给模块。