Dave Thomas
2015-07-18 02:03:05 UTC
Iâd trying to get the database endpoint into a Rails database.ml file. I
know the RDS id, so I can get the endpoint using reds/command: facts.
Unfortunately, the RDS play has to use localhost, while the template write
uses the actual target host.
So far Iâve done it using
- hosts: localhost
connection: local
gather_facts: False
vars_files:
- ../ec2/ec2_params.yml
tasks:
- rds:
command: facts
region: "{{ region }}"
instance_name: "{{ database_instance }}"
register: db_facts
- name: save remote host
copy:
content: "{{ db_facts.instance }}"
dest: /tmp/db_facts
- hosts: tag_class_apps
become: yes
become_user: "{{ app_user }}"
gather_facts: False
vars:
db_facts: "{{ lookup('file', '/tmp/db_facts')|from_json }}"
tasks:
- name: Update database.yml with current rds endpoint
template:
src: ../roles/app_directories/templates/config/database.yml # this template uses db_facts.endpoint
dest: "{{ shared_path }}/config/database.yml"I canât help feeling Iâm making this too complex. What should I be doing?
I can't help feeling I'm making this too complicated. What magic am I
missing?
Cheers
Dave
â
know the RDS id, so I can get the endpoint using reds/command: facts.
Unfortunately, the RDS play has to use localhost, while the template write
uses the actual target host.
So far Iâve done it using
- hosts: localhost
connection: local
gather_facts: False
vars_files:
- ../ec2/ec2_params.yml
tasks:
- rds:
command: facts
region: "{{ region }}"
instance_name: "{{ database_instance }}"
register: db_facts
- name: save remote host
copy:
content: "{{ db_facts.instance }}"
dest: /tmp/db_facts
- hosts: tag_class_apps
become: yes
become_user: "{{ app_user }}"
gather_facts: False
vars:
db_facts: "{{ lookup('file', '/tmp/db_facts')|from_json }}"
tasks:
- name: Update database.yml with current rds endpoint
template:
src: ../roles/app_directories/templates/config/database.yml # this template uses db_facts.endpoint
dest: "{{ shared_path }}/config/database.yml"I canât help feeling Iâm making this too complex. What should I be doing?
I can't help feeling I'm making this too complicated. What magic am I
missing?
Cheers
Dave
â
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+***@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/f27915cb-0909-4b82-a124-1baa19e5a250%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+***@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/f27915cb-0909-4b82-a124-1baa19e5a250%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.