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.
El viernes, 18 de diciembre de 2020 a la(s) 09:07:06 UTC-6, [email protected] escribió: > Hi, > > I've tried that and - service_status.stdout_lines[0] == 'enabled' > but still same error. > > > > > On Friday, December 18, 2020 at 9:54:04 AM UTC-5 [email protected] wrote: > >> The error says "results" don't exist. >> >> I think that line should be: >> when: 'enabled' in service_status.stdout_lines[0] >> >> El viernes, 18 de diciembre de 2020 a la(s) 08:37:18 UTC-6, >> [email protected] escribió: >> >>> 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 >>> >>> >>> >>> ================================================== >>> >>> >>> - name: Check if log package is installed. >>> block: >>> - name: Gather package facts. >>> become: true >>> package_facts: >>> manager: "auto" >>> - name: validating if the package is installed >>> debug: >>> msg: "{{ item }} is installed " >>> when: '"{{ item }}" in ansible_facts.packages' >>> with_items: >>> - rsyslog >>> register: rsyslog_check >>> >>> - name: check that log service is enabled if it's installed >>> shell: systemctl is-enabled rsyslog >>> register: service_status >>> >>> - debug: >>> var: service_status >>> >>> - name: check that log service is running. >>> shell: systemctl status rsyslog >>> register: active_status >>> - set_fact: >>> stig_text: "{{ stig_id }} FAILED. Log service isn't installed and /or >>> enabled or running." >>> when: "'rsyslog' in ansible_facts.packages" >>> >>> - set_fact: >>> stig_text: "PASSED" >>> when: >>> - service_status.results[0].stdout == 'enabled' >>> - active_status.stdout[0] == 'running' >>> >> -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ffe7eb6a-7c06-40b2-8ac4-e5ff37b8e59cn%40googlegroups.com.
