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

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

我正在致力于创建基于 Ansible 的 AWS 基础设施。 我有一个创建 RDS 实例的剧本。当我 运行 剧本独立时,它会完美执行并创建 RDS 实例。但是,当另一个剧本使用

调用该剧本时

include: rds.yml

出现如下错误

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

我使用的RDS ansible playbook如下

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

我在互联网上搜索了很多,但没有找到正确的答案。谁能指出我的错误。谢谢

问题已通过替换

解决

vpc_security_groups:“{{ sg_mysql }}”

vpc_security_groups:“{{ sg_mysql.group_id }}”

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