amazon web services - Ansible register rds and how to use it? -


i have rds play looks

- name: create postgresql instance in rds   hosts: localhost   gather_facts: false    tasks:     - name: provision rds instances       rds:         command: create         instance_name: ansibledataloading         size: 100         instance_type: db.m3.xlarge         region: us-east-1         db_engine: postgres         username: app         password: app         db_name: db         tags:           environment: testing           application: dataloading       register: rds      - name: wait rds       wait_for: host={{rds.instance.endpoint}} port=5432 delay=60 timeout=320 state=started      - name: add rds endpoint db group       add_host: hostname={{rds.instance.endpoint}} groupname=amazon_rds 

when try access rds endpoint in play error.

i did db_host: "{{hostvars.localhost.rds.instance.endpoint}}"

the error got was,

 failed! => {"changed": false, "failed": true, "module_stderr": "", "module_stdout": "\r\ntraceback (most recent call last):\r\n  file \"/tmp/ansible_v9jt8w/ansible_module_command.py\", line 250, in <module>\r\n    main()\r\n  file \"/tmp/ansible_v9jt8w/ansible_module_command.py\", line 181, in main\r\n    if args.strip() == '':\r\nattributeerror: 'nonetype' object has no attribute 'strip'\r\n", "msg": "module failure"} 

i need understand variables in ansible, how can set variable in rds play , later use in other play.

in play trying set env variables in host. sure wrong how did

- name: setup env variables   hosts: amazon_ec2   become: true   gather_facts: true    tasks:     - shell:       environment:         db_adapter: 'postgis'         db_encoding: 'utf8'         db_schema: 'dataloading'         db_pool_size: '5'         db_user_name: 'app'         db_password: 'app'         db_host: "{{hostvars.localhost.rds.instance.endpoint}}"         db_port: '5432' 

thank in advance


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -