# Stdout error

**URL:** <https://forum.ansible.com/t/stdout-error/34354>\
**Category:** Ansible Project\
**Created:** [December 18, 2020, 2:37pm UTC](https://forum.ansible.com/t/stdout-error/34354 "2020-12-18T14:37:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thuan1](https://avatars.discourse-cdn.com/v4/letter/t/0ea827/32.png) [@Thuan1](https://forum.ansible.com/u/Thuan1)\
**Post date:** [December 18, 2020, 2:37pm UTC](https://forum.ansible.com/t/stdout-error/34354/1 "2020-12-18T14:37:18Z")

</div>

Hi,

I’m getting the below error. I’ve tried: service\_status.stdout == ‘enabled’,  
and service.status.stdout.find(‘enabled’) != -1 but no luck.

TASK [set\_fact] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [localhost]: FAILED! =\> {“msg”: "The conditional check ‘service\_status.results[0].stdout == ‘enabled’’ failed. The error was: error while evaluating conditional (service\_status.results[0].stdout == ‘enabled’): ‘dict object’ has no attribute ‘results’\n\nThe error appears

---

<div class="post-metadata">

**Author:** ![Roberto\_J\_R\_Paz](https://avatars.discourse-cdn.com/v4/letter/r/d2c977/32.png) [@Roberto\_J\_R\_Paz](https://forum.ansible.com/u/Roberto_J_R_Paz)\
**Post date:** [December 18, 2020, 2:54pm UTC](https://forum.ansible.com/t/stdout-error/34354/2 "2020-12-18T14:54:03Z")

</div>

The error says “results” don’t exist.

I think that line should be:  
when: ‘enabled’ in service\_status.stdout\_lines[0]

---

<div class="post-metadata">

**Author:** ![Thuan1](https://avatars.discourse-cdn.com/v4/letter/t/0ea827/32.png) [@Thuan1](https://forum.ansible.com/u/Thuan1)\
**Post date:** [December 18, 2020, 3:07pm UTC](https://forum.ansible.com/t/stdout-error/34354/3 "2020-12-18T15:07:06Z")

</div>

Hi,

I’ve tried that and - service\_status.stdout\_lines[0] == ‘enabled’  
but still same error.

---

<div class="post-metadata">

**Author:** ![Roberto\_J\_R\_Paz](https://avatars.discourse-cdn.com/v4/letter/r/d2c977/32.png) [@Roberto\_J\_R\_Paz](https://forum.ansible.com/u/Roberto_J_R_Paz)\
**Post date:** [December 18, 2020, 3:10pm UTC](https://forum.ansible.com/t/stdout-error/34354/4 "2020-12-18T15:10:17Z")

</div>

Can you copy the error message ? I don’t see how the error can include something related to “results” is that is no longer part of the “when” entry.

---

<div class="post-metadata">

**Author:** ![Thuan1](https://avatars.discourse-cdn.com/v4/letter/t/0ea827/32.png) [@Thuan1](https://forum.ansible.com/u/Thuan1)\
**Post date:** [December 18, 2020, 3:33pm UTC](https://forum.ansible.com/t/stdout-error/34354/5 "2020-12-18T15:33:43Z")

</div>

TASK [set\_fact] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [localhost]: FAILED! =\> {“msg”: “The conditional check ‘service\_status.stdout\_lines[0] == ‘enabled’’ failed. The error was: error while evaluating conditional (service\_status.stdout\_lines[0] == ‘enabled’): ‘dict object’ has no attribute ‘stdout\_lines’\n\nThe error appears to be in ‘/home/thuan/Desktop/STIG/57898.yml’: line 44, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - set\_fact:\n ^ here\n”}

TASK [Install log service package.] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost]

TASK [Ensure log service is enabled and running.] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [localhost]

TASK [set\_fact] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost]

TASK [debug] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost] =\> {  
“msg”: “V-57898 PASSED”  
}

TASK [lineinfile] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost]

---

<div class="post-metadata">

**Author:** ![Roberto\_J\_R\_Paz](https://avatars.discourse-cdn.com/v4/letter/r/d2c977/32.png) [@Roberto\_J\_R\_Paz](https://forum.ansible.com/u/Roberto_J_R_Paz)\
**Post date:** [December 18, 2020, 4:34pm UTC](https://forum.ansible.com/t/stdout-error/34354/6 "2020-12-18T16:34:01Z")

</div>

Try to write the full value of “service\_status” right after being used to register the command with this:

- debug  
msg: “{{ service\_status }}”

to detect what is missing. That dictionary should include stdout, stderr and stdout\_lines keys if command “systemctl is-enabled rsyslog” was executed with no errors.

---

<div class="post-metadata">

**Author:** ![Thuan1](https://avatars.discourse-cdn.com/v4/letter/t/0ea827/32.png) [@Thuan1](https://forum.ansible.com/u/Thuan1)\
**Post date:** [December 18, 2020, 4:39pm UTC](https://forum.ansible.com/t/stdout-error/34354/7 "2020-12-18T16:39:24Z")

</div>

fatal: [localhost]: FAILED! =\> {“changed”: true, “cmd”: “systemctl is-enabled rsyslog”, “delta”: “0:00:00.005366”, “end”: “2020-12-18 11:37:39.206468”, “msg”: “non-zero return code”, “rc”: 1, “start”: “2020-12-18 11:37:39.201102”, “stderr”: “”, “stderr\_lines”: , “stdout”: “disabled”, “stdout\_lines”: [“disabled”]}

---

<div class="post-metadata">

**Author:** ![Roberto\_J\_R\_Paz](https://avatars.discourse-cdn.com/v4/letter/r/d2c977/32.png) [@Roberto\_J\_R\_Paz](https://forum.ansible.com/u/Roberto_J_R_Paz)\
**Post date:** [December 18, 2020, 5:57pm UTC](https://forum.ansible.com/t/stdout-error/34354/8 "2020-12-18T17:57:53Z")

</div>

Ok, it seems the command “systemctl is-enabled ” returns rc=0 if server is enabled and rc=1 if service is not enabled.

Any rc != 0 is usually considered as an error.

You can add the following:

- name: check that log service is enabled if it’s installed  
shell: systemctl is-enabled rsyslog  
register: service\_status

**failed\_when: service\_status.rc != 0 and service\_status.rc != 1**

(more conservative approach)

or

- name: check that log service is enabled if it’s installed  
shell: systemctl is-enabled rsyslog  
register: service\_status

**ignore\_errors: yes**

(this will ignore any error. Use with caution.)

---

<div class="post-metadata">

**Author:** ![Thuan1](https://avatars.discourse-cdn.com/v4/letter/t/0ea827/32.png) [@Thuan1](https://forum.ansible.com/u/Thuan1)\
**Post date:** [December 18, 2020, 6:31pm UTC](https://forum.ansible.com/t/stdout-error/34354/9 "2020-12-18T18:31:08Z")

</div>

I added your recommended codes, and received no error.  
However, the rescue block didn’t execute.
