HI Bishwajit Samanta Thanks. It is creating file for each hostname but data is not in readable format. Are you able to do favor little more, how to get the data in each file as orignal form like as processes list show on linux machine? I was initially thinking to get output from all hosts in one file and somehow get processes list along with hostname one by one. But this can work as well. Many Thanks.
On Thursday, April 12, 2018 at 5:09:41 PM UTC+10, Bishwajit Samanta wrote: > > 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 >> >> On Thursday, April 12, 2018 at 5:09:41 PM UTC+10, Bishwajit Samanta wrote: > > 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 >> >> On Thursday, April 12, 2018 at 5:09:41 PM UTC+10, Bishwajit Samanta wrote: > > 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 >> >> On Thursday, April 12, 2018 at 5:09:41 PM UTC+10, Bishwajit Samanta wrote: > > 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/b54cfb73-0bac-43b6-b2a6-571ea16faccd%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.