[ansible-project] How to extract information from string

2020-07-01 Thread Jenisha T
Hello All I have a string like this in the register. Agent Communication Diagnostic Report --- Agent User Name: username Agent Directory: /path/to/dir Agent Platform Architecture: Linux Agent Version

Re: [ansible-project] How to extract information from string

2020-07-01 Thread Vladimir Botka
On Wed, 1 Jul 2020 02:43:24 -0700 (PDT) Jenisha T wrote: > Agent Communication Diagnostic Report > --- > > Agent User Name: username > Agent Directory: /path/to/dir > Agent Platform Architecture: Linux > Agent Ve

Re: [ansible-project] How to extract information from string

2020-07-01 Thread T. JENISHA
Hi Vladimir I get the below error. my_data is input data stored in the register. whats my_key? fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'my_key' is undefined\n\nThe error appears to be in '/home/jenisha/PycharmProjects/ansible_

Re: [ansible-project] How to extract information from string

2020-07-01 Thread Vladimir Botka
Hi! On Thu, 2 Jul 2020 10:24:29 +0530 "T. JENISHA" wrote: > my_data is input data stored in the register If you have problem test the code with simple data first. For example vars: my_data: | a: 1 b: 2 > whats my_key? It's variable. See https://docs.python.org/3/library/re

Re: [ansible-project] How to extract information from string

2020-07-02 Thread Vladimir Botka
On Thu, 2 Jul 2020 13:59:13 +0530 "T. JENISHA" wrote: > - name: Ex grep > gather_facts: yes > hosts: localhost > connection: local > tasks: > > - name: Run ag_diag_comm > command: cat "ag_diag.txt" > register: ag_diag > > - set_fact: > . my_agent: "{{ my_agent|

Re: [ansible-project] How to extract information from string

2020-07-02 Thread T. JENISHA
Thankyou Vladimir. Its working now Best Regards Jenisha T Whatsapp: +91 07598087866 On Thu, 2 Jul 2020 at 14:54, Vladimir Botka wrote: > On Thu, 2 Jul 2020 13:59:13 +0530 > "T. JENISHA" wrote: > > > - name: Ex grep > > gather_facts: yes > > hosts: localhost > > connection: local > >