Here's the new test:

- set_fact:
    mongodb_candidate_master: "{{mongodb_replica_set_hosts[0]}}"
  run_once: true


- name: var groups.mongod_rs_member[0]
  debug: var=groups.mongod_rs_member[0]
  run_once: true


- shell: echo "HELLO groups.mongod_rs_member +++++++++++++++++"
  delegate_to: "{{groups.mongod_rs_member[0]}}"
  run_once: true


- name: var mongodb_candidate_master
  debug: var=mongodb_candidate_master
  run_once: true


- shell: echo "HELLO mongodb_candidate_master +++++++++++++++++"
  delegate_to: "{{mongodb_candidate_master}}"
  run_once: true


- name: var mongodb_replica_set_hosts[0]
  debug: var=mongodb_replica_set_hosts[0]
  run_once: true


- name: msg mongodb_replica_set_hosts[0]
  debug: msg="{{mongodb_replica_set_hosts[0]}}"
  run_once: true


- debug: msg="{{mongodb_replica_set_hosts[0]}}"
  run_once: true


- shell: echo "HELLO mongodb_replica_set_hosts +++++++++++++++++"
  delegate_to: "{{mongodb_replica_set_hosts[0]}}"
  run_once: true


And the output:

ansibleāÆ ansible-playbook -i inventory/aws/staging playbooks/configure/
mongod.yml --skip-tags base                                                 
                ops/git/master !+


PLAY [Base ansible configuration (packages)] 
********************************** 


GATHERING FACTS 
*************************************************************** 
ok: [10.0.137.189]
ok: [10.0.139.51]
ok: [10.0.136.46]


PLAY [Base ansible configuration (configure)] 
********************************* 


GATHERING FACTS 
*************************************************************** 
ok: [10.0.137.189]
ok: [10.0.139.51]
ok: [10.0.136.46]


PLAY [Base ansible configuration (users)] 
************************************* 


GATHERING FACTS 
*************************************************************** 
ok: [10.0.137.189]
ok: [10.0.139.51]
ok: [10.0.136.46]


PLAY [Configure mongodb replicaset cluster] 
*********************************** 


GATHERING FACTS 
*************************************************************** 
ok: [10.0.136.46]
ok: [10.0.137.189]
ok: [10.0.139.51]


TASK: [debug var=groups.mongod_rs_member] 
************************************* 
ok: [10.0.136.46] => {
    "var": {
        "groups.mongod_rs_member": [
            "10.0.136.46", 
            "10.0.139.51", 
            "10.0.137.189"
        ]
    }
}
ok: [10.0.139.51] => {
    "var": {
        "groups.mongod_rs_member": [
            "10.0.136.46", 
            "10.0.139.51", 
            "10.0.137.189"
        ]
    }
}
ok: [10.0.137.189] => {
    "var": {
        "groups.mongod_rs_member": [
            "10.0.136.46", 
            "10.0.139.51", 
            "10.0.137.189"
        ]
    }
}


TASK: [mongodb | set_fact ] 
*************************************************** 
ok: [10.0.136.46]


TASK: [mongodb | var groups.mongod_rs_member[0]] 
****************************** 
ok: [10.0.136.46] => {
    "var": {
        "groups.mongod_rs_member[0]": "10.0.136.46"
    }
}


TASK: [mongodb | shell echo "HELLO groups.mongod_rs_member 
+++++++++++++++++"] *** 
changed: [10.0.136.46 -> 10.0.136.46]


TASK: [mongodb | var mongodb_candidate_master] 
******************************** 
ok: [10.0.136.46] => {
    "var": {
        "mongodb_candidate_master": "10.0.136.46"
    }
}


TASK: [mongodb | shell echo "HELLO mongodb_candidate_master 
+++++++++++++++++"] *** 
changed: [10.0.136.46 -> 10.0.136.46]


TASK: [mongodb | var mongodb_replica_set_hosts[0]] 
**************************** 
ok: [10.0.136.46] => {
    "var": {
        "mongodb_replica_set_hosts[0]": "10.0.136.46"
    }
}


TASK: [mongodb | msg mongodb_replica_set_hosts[0]] 
**************************** 
ok: [10.0.136.46] => {
    "msg": "10.0.136.46"
}


TASK: [mongodb | debug msg="{"] 
*********************************************** 
ok: [10.0.136.46] => {
    "msg": "10.0.136.46"
}


TASK: [mongodb | shell echo "HELLO mongodb_replica_set_hosts 
+++++++++++++++++"] *** 
fatal: [10.0.136.46 -> {] => SSH Error: data could not be sent to the 
remote host. Make sure this host can be reached over ssh


FATAL: all hosts have already failed -- aborting


The last debug is interesting. I does not have a -name and it seems to 
render the value as '{' just like the delegate_to.



-- 
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/bebb3253-db43-452d-83b5-f9e5fc8f72f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to