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 <[email protected]> wrote: > [email protected] > <https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!forum/ansible-project/topics> > Google > Groups > <https://groups.google.com/forum/?utm_source=digest&utm_medium=email/#!overview> > <https://groups.google.com/forum/?utm_source=digest&utm_medium=email/#!overview> > Today's topic summary > View all topics > <https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!forum/ansible-project/topics> > > - Need to understand how I can write a ansible role so that it > compares input / output value. <#m_-1182577969097162148_group_thread_0> > - 2 Updates > - ActiveState of a systemd service > <#m_-1182577969097162148_group_thread_1> - 8 Updates > - Ansible command output <#m_-1182577969097162148_group_thread_2> - 1 > Update > > Need to understand how I can write a ansible role so that it compares > input / output value. > <http://groups.google.com/group/ansible-project/t/d0ede326a3ec67fb?utm_source=digest&utm_medium=email> > Marian Saldhana <[email protected]>: 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 > <http://groups.google.com/group/ansible-project/msg/b5deb8e5132f?utm_source=digest&utm_medium=email> > Mauricio Tavares <[email protected]>: 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 > <http://groups.google.com/group/ansible-project/msg/cecb315e067a?utm_source=digest&utm_medium=email> > Back to top <#m_-1182577969097162148_digest_top> > ActiveState of a systemd service > <http://groups.google.com/group/ansible-project/t/acf60ca717e05085?utm_source=digest&utm_medium=email> > Todd Lewis <[email protected]>: 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 > <http://groups.google.com/group/ansible-project/msg/8e4a734db33a?utm_source=digest&utm_medium=email> > Todd Lewis <[email protected]>: Dec 27 08:55AM -0800 > > which produces: > TASK [Dump ActiveState] ********** > ok: [localhost] => { > "msg": [ > { > "name": "postfix.service", > "state": "active" > }, > { ...more > <http://groups.google.com/group/ansible-project/msg/8e6bb572cb24?utm_source=digest&utm_medium=email> > Dick Visser <[email protected]>: 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 > <http://groups.google.com/group/ansible-project/msg/98e6ae0cb034?utm_source=digest&utm_medium=email> > Thomas Stephen Lee <[email protected]>: Dec 28 08:00AM +0530 > > Hi @Todd Lewis, > > That works. > > Thanks a lot. > > --- > Lee > > ...more > <http://groups.google.com/group/ansible-project/msg/add2a403de54?utm_source=digest&utm_medium=email> > Thomas Stephen Lee <[email protected]>: Dec 28 08:00AM +0530 > > Hi @Dick Visser, > > That gives the below output. > > -----------------%<----------------- > > TASK [debug] > ******************************************************************* > ok: [localhost] => { ...more > <http://groups.google.com/group/ansible-project/msg/add443e7ecc5?utm_source=digest&utm_medium=email> > Dick Visser <[email protected]>: 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 > <http://groups.google.com/group/ansible-project/msg/cb1091290086?utm_source=digest&utm_medium=email> > Thomas Stephen Lee <[email protected]>: Dec 28 05:27PM +0530 > > Hi @Dick Visser, > > That gives the below output. > > -----------------%<----------------- > > TASK [debug] > ******************************************************************* > ok: [localhost] => { ...more > <http://groups.google.com/group/ansible-project/msg/ccc6f64a0d94?utm_source=digest&utm_medium=email> > Dick Visser <[email protected]>: Dec 28 01:29PM +0100 > > I believe this is what you wanted - right? > > > -- > Dick Visser > Trust & Identity Service Operations Manager > GÉANT > ...more > <http://groups.google.com/group/ansible-project/msg/ce836b77e45a?utm_source=digest&utm_medium=email> > Back to top <#m_-1182577969097162148_digest_top> > Ansible command output > <http://groups.google.com/group/ansible-project/t/7df1e6391d6100a9?utm_source=digest&utm_medium=email> > Dick Visser <[email protected]>: 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 > <http://groups.google.com/group/ansible-project/msg/9a39f9e7e163?utm_source=digest&utm_medium=email> > Back to top <#m_-1182577969097162148_digest_top> > You received this digest because you're subscribed to updates for this > group. You can change your settings on the group membership page > <https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!forum/ansible-project/join> > . > To unsubscribe from this group and stop receiving emails from it send an > email to [email protected]. > -- 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/CABxrqnEmzCMLZO2cDq54UuVUQvSg9Y3yASMiQd6fNMhPJnyWtg%40mail.gmail.com.
