I just changed the host as devops
---

- hosts: devops
  gather_facts: no
  tasks:
    - name: Get the running process across the systems
      command: ps -ef
      register: output

    - name: Getting some details of systems
      local_action: copy content={{ output }} dest=/opt/{{ 
inventory_hostname }}file

Output::-
-------------

[root@ansible-master opt]# ls
192.168.56.111file  192.168.56.116file 

You can try with this and see if your problem get resolved.

On Wednesday, April 11, 2018 at 1:42:45 PM UTC+5:30, smitconsu...@gmail.com 
wrote:
>
> Hi 
> I am trying to achieve all running processes on our linux machines via 
> ansible and get output in a file along with each host name and processes. I 
> have made below playbook but not getting to the point how to get list of 
> processes for each host one by one and store in a file. Can anyone please 
> help with the code how can I achieve this? I am using with_items with list 
> of hosts which is coming from inventory group hostlist. many thanks
>
> ---
> - hosts: all
>   gather_facts: false
>   tasks:
>
>   - name: Get Running Processes
>     command: ps -ef
>     delegate_to: "{{ item }}"
>     run_once: false
>     with_items:
>      - "{{ groups['hostlist'] }}"
>     register: process_list
>
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/11e0d7f6-4c90-489b-9df0-d2dd9febdc36%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to