Extract nmon

18 views
Skip to first unread message

Kannappan M

unread,
Dec 29, 2021, 1:26:51 AM12/29/21
to ansible...@googlegroups.com
Hi all,
From my ansible user I was trying to fetch the nmon files (root owned) but throwed me error even though I have mentioned as become: yes. Now if I run the same playbook using root user ,my task is getting completed but I need to perform this task using ansible user not as root user.

On Tue, Dec 28, 2021, 22:11 <ansible...@googlegroups.com> wrote:
Marian Saldhana <marian....@gmail.com>: Dec 27 08:58PM -0800

Hi All,
 
This is my code:
 
---
# tasks file for uname
 
- name: Kernel version number
register: uname_a
command: "uname -a"
 
- debug:
var: ...more
Mauricio Tavares <raub...@gmail.com>: Dec 28 07:35AM -0500

var
 
On Mon, Dec 27, 2021 at 11:58 PM Marian Saldhana
> }
 
> ++++
 
> Now I need to compare these values with the values given by the customer ( Linux ansible-client1 4.18.0-348.el8.x86_64 ) ...more
Todd Lewis <uto...@gmail.com>: Dec 27 08:53AM -0800

You probably want something like this:
 
- hosts: localhost
tasks:
- name: Get Service Status
ansible.builtin.systemd:
name: '{{ item }}.service'
register: hello
loop: ...more
Todd Lewis <uto...@gmail.com>: Dec 27 08:55AM -0800

which produces:
TASK [Dump ActiveState] **********
ok: [localhost] => {
"msg": [
{
"name": "postfix.service",
"state": "active"
},
{ ...more
Dick Visser <dick....@geant.org>: Dec 27 09:07PM +0100


> - debug:
> msg: "{{ hello.results | to_nice_json |
> json_query('status.ActiveState') }}"
 
the result var is a list, so if you want a list of a specific key:
 
 
- debug: ...more
Thomas Stephen Lee <lee....@gmail.com>: Dec 28 08:00AM +0530

Hi @Todd Lewis,
 
That works.
 
Thanks a lot.
 
---
Lee
 
...more
Thomas Stephen Lee <lee....@gmail.com>: Dec 28 08:00AM +0530

Hi @Dick Visser,
 
That gives the below output.
 
-----------------%<-----------------
 
TASK [debug] *******************************************************************
ok: [localhost] => { ...more
Dick Visser <dick....@geant.org>: Dec 28 12:26PM +0100

I meant:
 
- debug: var=hello|json_query('results[].status.ActiveState')
 
 
 
--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT
...more
Thomas Stephen Lee <lee....@gmail.com>: Dec 28 05:27PM +0530

Hi @Dick Visser,
 
That gives the below output.
 
-----------------%<-----------------
 
TASK [debug] *******************************************************************
ok: [localhost] => { ...more
Dick Visser <dick....@geant.org>: Dec 28 01:29PM +0100

I believe this is what you wanted - right?
 
 
--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT
...more
Dick Visser <dick....@geant.org>: Dec 27 09:31PM +0100

Why would you want to use ansible for this?
What is the use case?
 
 
--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT
...more
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to ansible-proje...@googlegroups.com.

Dick Visser

unread,
Dec 29, 2021, 1:39:03 AM12/29/21
to ansible...@googlegroups.com
Then your privilege escalation is not set up correctly. You should fix that. 
But since you just mention the opaque "throwed me error" it's mostly a guess.



--
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-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CABxrqnEmzCMLZO2cDq54UuVUQvSg9Y3yASMiQd6fNMhPJnyWtg%40mail.gmail.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.
Reply all
Reply to author
Forward
0 new messages