Hello all,

I've got a playbook that does:

- name: Get db cluster endpoint
shell: "aws --region=us-east-1 rds describe-db-clusters 
--db-cluster-identifier {{ cluster }}-kam-db"
register: aws_cluster_res

- set_fact:
myvar: "{{ aws_cluster_res.stdout | from_json }}"

- set_fact:
endpoint: "{{ myvar.DBClusters[0].Endpoint }}"


and much later on:

- replace:
dest: /home/admin/myconfig.cfg
regexp: '^(.*)!\{\{ DB_HOST \}\}(.*)$'
replace: '\1!{{ endpoint }}\2'

But ansible complaints that it is undefined, eve though it _has_ beed 
defined:

output:

TASK [set_fact] 
*************************************************************************************************************************************************************************
task path: /home/admin/create_instances.yaml:107
ok: [127.0.0.1] => {
    "ansible_facts": {
        "endpoint": "something.amazonaws.com"
    },
    "changed": false
}
Read vars_file 'vars/sts.yml'
Read vars_file 'vars/default.yml'


TASK [Print endpoint] 
*******************************************************************************************************************************************************************
task path: /home/admin/create_instances.yaml:110
ok: [127.0.0.1] => {
    "msg": "sonmething.amazonaws.com"
}



....


TASK [replace] 
**************************************************************************************************************************************************************************
task path: /home/admin/voice-conf/playbooks/create_instances.yaml:335
fatal: [18.206.82.39]: FAILED! => {
    "msg": "The task includes an option with an undefined variable. The 
error was: 'endpoint' is undefined\n\nThe error appears to have been in 
'/home/admin/create_instances.yaml': line 335, column 5, but may\nbe 
elsewhere in the file depending on the exact syntax problem.\n\nThe 
offending line appears to be:\n\n\n  - replace:\n    ^ here\n"
}
fatal: [18.206.108.97]: FAILED! => {
    "msg": "The task includes an option with an undefined variable. The 
error was: 'endpoint' is undefined\n\nThe error appears to have been in 
'/home/admin/create_instances.yaml': line 335, column 5, but may\nbe 
elsewhere in the file depending on the exact syntax problem.\n\nThe 
offending line appears to be:\n\n\n  - replace:\n    ^ here\n"
}


I can't figure out why this is happening, can someone help?

Thanks!

David


-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1777673f-a80f-4a2b-84be-d5a65578aad3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to