在ansible中创建RDS [英] Creating RDS in ansible

查看:27
本文介绍了在ansible中创建RDS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力学习 ansible 的工作.我需要创建 RDS 实例,然后创建一个数据库并获取 env 变量.

I am trying to learn ansible for work. I need to create RDS instance followed by a database and get env variables.

我不断收到错误

致命:[本地主机]:失败!=> {"changed": false, "failed": true, "msg": "不支持的模块参数:注册"}

fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "unsupported parameter for module: register"}

这是我的代码

- name: Configure RDS
  hosts: localhost
  connection: local
  gather_facts: false

  tasks:
    - name: Provision RDS
      rds:
        command: create
        instance_name: ANSIBLEDataloading
        db_engine: Postgresql
        size: 10
        instance_type: sb.m1.small
        username: xxxxx
        password: xxxxx
        tags:
          Environment: Dataloading
          Application: sims
        command: facts
        instance_name: ANSIBLEDataloading
        register: ANSIBLEDataloading
    - name: Add new instance to host group
      add_host: hostname={{ item.endpoint }} groupname=launched_db
      with_items: '{{ANSIBLEDataloading.instance}}'

我正在努力学习,对 ansible 非常陌生.

I am trying to learn, very very new to ansible.

新代码

- name: Configure RDS
  hosts: localhost
  connection: local
  gather_facts: false

  tasks:
    - name: Provision RDS
      rds:
        command: create
        instance_name: ANSIBLEDataloading
        db_engine: postgres
        region: 'us-east-1'
        size: 10
        instance_type: db.m3.xlarge
        username: xxxxx
        password: xxxx
        tags:
          Environment: Dataloading
          Application: sims
      register: ANSIBLEDataloading
    - name: Add new instance to host group
      add_host: hostname={{ item.endpoint }} groupname=launched_db
      with_items: '{{ANSIBLEDataloading.instance}}'

新错误

fatal: [localhost]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'unicode object' has no attribute 'endpoint'\n\nThe error appears to have been in '/Users/suyesh/Desktop/ansible_conversion/conversion.yml': line 48, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n      register: ANSIBLEDataloading\n    - name: Add new instance to host group\n      ^ here\n"}

推荐答案

您得到的错误只是格式错误.register 应与任务缩进相同.

The error you're getting is simply a formatting error. register should be on the same indentation as the task.

  tasks:
    - name: Provision RDS
      rds:
        command: create
        instance_name: ANSIBLEDataloading
        db_engine: Postgresql
        size: 10
        instance_type: sb.m1.small
        username: xxxxx
        password: xxxxx
        tags:
          Environment: Dataloading
          Application: sims
        command: facts
        instance_name: ANSIBLEDataloading
      register: ANSIBLEDataloading

这篇关于在ansible中创建RDS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆