Sentinel - Redis : fatal: [pyxrrsap02.pyx.erp]: FAILED! => {"failed": true, "msg": "ERROR! 'list object' has no attribute 'cmd'"}

14 views
Skip to first unread message

Eric Franckx

unread,
Nov 11, 2015, 10:48:09 AM11/11/15
to Ansible Project

Hi,
I try to connect to a list of Sentinel host to get the master redis host and port.

  • name: "CONNECT SENTINEL" command: "redis-cli -h {{ item.allowed_host }} -p {{ item.port }} SENTINEL get-master-addr-by-name redis-pex-01" with_items: "{{ production.redis_params.sentinels }}" register: status_sentinel ignore_errors: yes

TASK [CONNECT SENTINEL] ********************************************************
changed: [pyxrrsap02.pyx.erp] => (item={u'allowed_host': u'pyxrrsap01', u'port': 17700}) => {"changed": true, "cmd": ["redis-cli", "-h", "pyxrrsap01", "-p", "17700", "SENTINEL", "get-master-addr-by-name", "redis-pex-01"], "delta": "0:00:00.016587", "end": "2015-11-11 00:49:19.387801", "item": {"allowed_host": "pyxrrsap01", "port": 17700}, "rc": 0, "start": "2015-11-11 00:49:19.371214", "stderr": "", "stdout": "10.50.133.20\n6379", "stdout_lines": ["10.50.133.20", "6379"], "warnings": []}
changed: [pyxrrsap02.pyx.erp] => (item={u'allowed_host': u'pyxrrsap01', u'port': 27700}) => {"changed": true, "cmd": ["redis-cli", "-h", "pyxrrsap01", "-p", "27700", "SENTINEL", "get-master-addr-by-name", "redis-pex-01"], "delta": "0:00:00.017153", "end": "2015-11-11 00:49:19.998121", "item": {"allowed_host": "pyxrrsap01", "port": 27700}, "rc": 0, "start": "2015-11-11 00:49:19.980968", "stderr": "", "stdout": "10.50.133.20\n6379", "stdout_lines": ["10.50.133.20", "6379"], "warnings": []}

I try to display result f register value:
- name: "DISPLAY SENTINEL VAR 1"
debug: msg={{ status_sentinel }}
ignore_errors: yes

TASK [DISPLAY SENTINEL VAR 1] **************************************************
ok: [pyxrrsap02.pyx.erp] => {
"changed": false,
"msg": {
"changed": true,
"msg": "All items completed",
"results": [
{
"_ansible_no_log": false,
"changed": true,
"cmd": [
"redis-cli",
"-h",
"pyxrrsap01",
"-p",
"17700",
"SENTINEL",
"get-master-addr-by-name",
"redis-pex-01"
],
"delta": "0:00:00.016587",
"end": "2015-11-11 00:49:19.387801",
"invocation": {
"module_args": {
"_raw_params": "redis-cli -h pyxrrsap01 -p 17700 SENTINEL get-master-addr-by-name redis-pex-01"
},
"module_name": "command"
},
"item": {
"allowed_host": "pyxrrsap01",
"port": 17700
},
"rc": 0,
"start": "2015-11-11 00:49:19.371214",
"stderr": "",
"stdout": "10.50.133.20\n6379",
"stdout_lines": [
"10.50.133.20",
"6379"
],
"warnings": []
},
{
"_ansible_no_log": false,
"changed": true,
"cmd": [
"redis-cli",
"-h",
"pyxrrsap01",
"-p",
"27700",
"SENTINEL",
"get-master-addr-by-name",
"redis-pex-01"
],
"delta": "0:00:00.017153",
"end": "2015-11-11 00:49:19.998121",
"invocation": {
"module_args": {
"_raw_params": "redis-cli -h pyxrrsap01 -p 27700 SENTINEL get-master-addr-by-name redis-pex-01"
},
"module_name": "command"
},
"item": {
"allowed_host": "pyxrrsap01",
"port": 27700
},
"rc": 0,
"start": "2015-11-11 00:49:19.980968",
"stderr": "",
"stdout": "10.50.133.20\n6379",
"stdout_lines": [
"10.50.133.20",
"6379"
],
"warnings": []
}
]
}
}

But when it tries to parse to have detail it doesn't work:
- name: "DISPLAY SENTINEL VAR 1 1"
debug: msg={{ status_sentinel.results.cmd }}
ignore_errors: yes

- name: "DISPLAY SENTINEL VAR 1 2"
  debug: msg={{ item.cmd }}
  with_items: ${status_sentinel.results}
  ignore_errors: yes

TASK [DISPLAY SENTINEL VAR 1 1] ************************************************
fatal: [pyxrrsap02.pyx.erp]: FAILED! => {"failed": true, "msg": "ERROR! 'list object' has no attribute 'cmd'"}
...ignoring

TASK [DISPLAY SENTINEL VAR 1 2] ************************************************
fatal: [pyxrrsap02.pyx.erp]: FAILED! => {"failed": true, "msg": "ERROR! 'unicode object' has no attribute 'cmd'"}
...ignoring

or like this :
- name: "DISPLAY SENTINEL VAR 2 1"
debug: var={{ item }}
with_items: ${status_sentinel.results}
ignore_errors: yes

doesn't work:
TASK [DISPLAY SENTINEL VAR 2 1] ************************************************
ok: [pyxrrsap02.pyx.erp] => (item=${status_sentinel.results}) => {
"${status_sentinel.results}": "VARIABLE IS NOT DEFINED!",
"item": "${status_sentinel.results}"

Any idea ?

Regards,



This email is sent on behalf of Northgate Information Solutions Limited and its associated companies ("Northgate") and is strictly confidential and intended solely for the addressee(s). 

If you are not the intended recipient of this email you must: (i) not disclose, copy or distribute its contents to any other person nor use its contents in any way or you may be acting unlawfully;  (ii) contact Northgate immediately on +44 (0)1442 232424 quoting the name of the sender and the addressee then delete it from your system.

Northgate has taken reasonable precautions to ensure that no viruses are contained in this email, but does not accept any responsibility once this email has been transmitted.  You should scan attachments (if any) for viruses.


Eric Franckx

unread,
Nov 12, 2015, 8:20:04 AM11/12/15
to Ansible Project
SOLVED:

Simple by using : [0][0] and [0][1] to get the correct value/parameters.
Reply all
Reply to author
Forward
0 new messages