Hi,
I have a small Ansible playbook.
-----------------%<-----------------
- hosts: localhost
tasks:
- name: Populate service facts
ansible.builtin.service_facts:
- name: Print service facts
loop:
- postfix
- rsyslog
- sshd
ansible.builtin.debug:
var: ansible_facts.services['{{ item }}.service']['state']
-----------------%<-----------------
The output is
-----------------%<-----------------
PLAY [localhost]
***************************************************************
TASK [Gathering Facts]
*********************************************************
ok: [localhost]
TASK [Populate service facts]
**************************************************
ok: [localhost]
TASK [Print service facts]
*****************************************************
ok: [localhost] => (item=postfix) => {
"ansible_facts.services['postfix.service']['state']": "running",
"ansible_loop_var": "item",
"item": "postfix"
}
ok: [localhost] => (item=rsyslog) => {
"ansible_facts.services['rsyslog.service']['state']": "running",
"ansible_loop_var": "item",
"item": "rsyslog"
}
ok: [localhost] => (item=sshd) => {
"ansible_facts.services['sshd.service']['state']": "running",
"ansible_loop_var": "item",
"item": "sshd"
}
PLAY RECAP
*********************************************************************
localhost : ok=3 changed=0 unreachable=0
failed=0 skipped=0 rescued=0 ignored=0
-----------------%<-----------------
What I want is
TASK [Print service facts]
should print only
"ansible_facts.services['rsyslog.service']['state']": "running"
The other three should be hidden.
Any easy trick for this ?
Thanks
---
Lee
--
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/CAG7s96UXZz6XnQ641AK2L%3DkBKPRdWBaKgha3JWf7zLkPnWLuvA%40mail.gmail.com.