I an trying to get set_fact: resource_{{ item.item.key }}={{item.stdout}} 
to be the output of   "stdout": "0" meaning resource_{{ item.item.key }}= 
0, later in other task I am checking if value is 0 or 1

On Wednesday, September 27, 2017 at 9:36:42 PM UTC-5, Frank Dias wrote:
>
> Can I get your help in diagnosing why this is not working, I am getting 
> the error on task #3 Here are the three tasks; I am wantng to key off 
> of            "stdout": "0",
>
> - name: Check if Redis Resources already exists
>
>   shell: "pcs resource | grep '{{ item.key }}' | grep Master | wc -l"
>
>   register: resource_exist
>
>   with_dict: "{{redis}}"
>
>   tags: [config_cluster, redis]
>
>  
>
> - name: Print results
>
>    debug: msg="{{ resource_exist.results }}"
>
>    tags: [config_cluster, redis]
>
>  
>
>  
>
> - name: Set facts about if resources already exists
>
>   set_fact: resource_{{ item.item.key }}={{item.stdout}}
>
>   with_items: resource_exist.results
>
>   tags: [config_cluster, redis]
>
>  
>
> here is the output;
>
>  
>
> TASK [postgres-ha : Check if Redis Resources already exists] 
> ***********************************************************************
>
> skipping: [sds02.prodea-int.net] => (item={'key': u'redis_array_1', 
> 'value': {u'bin': u'/opt/redis/bin/redis-server', u'clone_max': 3, 
> u'master_max': 1, u'wait_last_known_master': 0, u'loglevel': u'notice', 
> u'client_bin': u'/opt/redis/bin/redis-cli', u'vip_cidr_netmask': 24, 
> u'master_node_max': 1, u'save': [u'900 1', u'300 10', u'60 10000'], 
> u'vip_nic': u'eth0', u'daemonize': u'yes', u'notify': True, u'user': 
> u'root', u'vip_ip': u'172.24.2.242', u'rundir': u'/var/run/redis', 
> u'logfile': None, u'port': 6379, u'clone_node_max': 1}})
>
> changed: [sds01.prodea-int.net] => (item={'key': u'redis_array_1', 
> 'value': {u'bin': u'/opt/redis/bin/redis-server', u'clone_max': 3, 
> u'master_max': 1, u'wait_last_known_master': 0, u'loglevel': u'notice', 
> u'client_bin': u'/opt/redis/bin/redis-cli', u'vip_cidr_netmask': 24, 
> u'master_node_max': 1, u'save': [u'900 1', u'300 10', u'60 10000'], 
> u'vip_nic': u'eth0', u'daemonize': u'yes', u'notify': True, u'user': 
> u'root', u'vip_ip': u'172.24.2.242', u'rundir': u'/var/run/redis', 
> u'logfile': None, u'port': 6379, u'clone_node_max': 1}})
>
>  
>
> TASK [postgres-ha : Print results] 
> *************************************************************************************************
>
> ok: [sds01.prodea-int.net] => {
>
>     "msg": [
>
>         {
>
>             "_ansible_item_result": true, 
>
>             "_ansible_no_log": false, 
>
>             "_ansible_parsed": true, 
>
>             "changed": true, 
>
>             "cmd": "pcs resource | grep 'redis_array_1' | grep Master | wc 
> -l", 
>
>             "delta": "0:00:00.328159", 
>
>             "end": "2017-09-26 17:25:25.591212", 
>
>             "invocation": {
>
>                 "module_args": {
>
>                     "_raw_params": "pcs resource | grep 'redis_array_1' | 
> grep Master | wc -l", 
>
>                     "_uses_shell": true, 
>
>                     "chdir": null, 
>
>                     "creates": null, 
>
>                     "executable": null, 
>
>                     "removes": null, 
>
>                     "warn": true
>
>                 }
>
>             }, 
>
>             "item": {
>
>                 "key": "redis_array_1", 
>
>                 "value": {
>
>                     "bin": "/opt/redis/bin/redis-server", 
>
>                     "client_bin": "/opt/redis/bin/redis-cli", 
>
>                     "clone_max": 3, 
>
>                     "clone_node_max": 1, 
>
>                     "daemonize": "yes", 
>
>                     "logfile": null, 
>
>                     "loglevel": "notice", 
>
>                     "master_max": 1, 
>
>                     "master_node_max": 1, 
>
>                     "notify": true, 
>
>                     "port": 6379, 
>
>                     "rundir": "/var/run/redis", 
>
>                     "save": [
>
>                         "900 1", 
>
>                         "300 10", 
>
>                         "60 10000"
>
>                     ], 
>
>                     "user": "root", 
>
>                     "vip_cidr_netmask": 24, 
>
>                     "vip_ip": "172.24.2.242", 
>
>                     "vip_nic": "eth0", 
>
>                     "wait_last_known_master": 0
>
>                 }
>
>             }, 
>
>             "rc": 0, 
>
>             "start": "2017-09-26 17:25:25.263053", 
>
>             "stderr": "", 
>
>             "stderr_lines": [], 
>
>             "stdout": "0", 
>
>             "stdout_lines": [
>
>                 "0"
>
>             ]
>
>         }
>
>     ]
>
> }
>
> skipping: [sds02.prodea-int.net]
>
>  
>
> TASK [postgres-ha : Set facts about if resources already exists] 
> *******************************************************************
>
> fatal: [sds01.prodea-int.net]: FAILED! => {"failed": true, "msg": "the 
> field 'args' has an invalid value, which appears to include a variable that 
> is undefined. The error was: 'ansible.vars.unsafe_proxy.AnsibleUnsafeText 
> object' has no attribute 'stdout'\n\nThe error appears to have been in 
> '/etc/ansible/roles/postgres-ha/tasks/redis_resources.yml': line 18, column 
> 3, but may\nbe elsewhere in the file depending on the exact syntax 
> problem.\n\nThe offending line appears to be:\n\n\n- name: Set fatcs about 
> if resources already exists\n  ^ here\n"}
>
> fatal: [sds02.prodea-int.net]: FAILED! => {"failed": true, "msg": "the 
> field 'args' has an invalid value, which appears to include a variable that 
> is undefined. The error was: 'ansible.vars.unsafe_proxy.AnsibleUnsafeText 
> object' has no attribute 'stdout'\n\nThe error appears to have been in 
> '/etc/ansible/roles/postgres-ha/tasks/redis_resources.yml': line 18, column 
> 3, but may\nbe elsewhere in the file depending on the exact syntax 
> problem.\n\nThe offending line appears to be:\n\n\n- name: Set fatcs about 
> if resources already exists\n  ^ here\n"}
>
>  
>
> NO MORE HOSTS LEFT 
> *****************************************************************************************************************
>
>         to retry, use: --limit @/root/sds-postgres-ha.retry
>

-- 
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/28d300ee-3110-4261-bd4a-c7740c4b5030%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to