Hi Experts,
I am looking to capture certain service status using ansible the problem is
debug prints only last item.Below is the expected output.
Hostname : test
httpd --> Running
ntpd --> Running
Below are the playbook.
---
- hosts: test
become: true
gather_facts: false
tasks:
- name: Service facts
service_facts:
- set_fact:
elk_app1: "{{ ansible_facts.services[item + '.service'].name}}
Running"
when: ansible_facts.services[item + '.service'].state == 'running'
with_items:
- httpd
- ntpd
register: foo_result
- debug: msg="{{ foo_result }}"
Regards
Kumar
--
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/cbd4fd36-e141-48a1-b306-0a9629ec8e31n%40googlegroups.com.