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_ex/tasks/grep_ex.yml': line 31,
column 7, but may\nbe elsewhere in the file depending on the exact syntax
problem.\n\nThe offending line appears to be:\n\n\n    - set_fact:\n      ^
here\n"}



Best Regards
Jenisha T
Whatsapp: +91 07598087866





On Thu, 2 Jul 2020 at 08:35, Vladimir Botka <[email protected]> wrote:

> On Wed, 1 Jul 2020 02:43:24 -0700 (PDT)
> Jenisha T <[email protected]> wrote:
>
> > Agent Communication Diagnostic Report
> > -----------------------------------------------
> >
> >  Agent User Name                : username
> >  Agent Directory                : /path/to/dir
> >  Agent Platform Architecture    : Linux
> >  Agent Version                  : x.0.00.x
> >  Agent Host Name                : abcdef1234
> >  Logical Agent Name             : abcdef1234
> >  Listen to Network Interface    : *ANY
> >
> >  Agent processes status
> >  ======================
> >  Agent Listener                 : Running as root
>
> Try this (given the string is in variable "my_data")
>
>     - set_fact:
>         my_agent: "{{ my_agent|default({})|
>                       combine({my_key: my_val}) }}"
>       loop: "{{ my_data.splitlines()|
>                 select('match', my_regex)|
>                 list }}"
>       vars:
>         my_regex: '^(.*?):(.*)$'
>         my_key: "{{ item|
>                     regex_replace(my_regex, '\\1')|
>                     trim|
>                     regex_replace(' ', '_') }}"
>         my_val: "{{ item|
>                     regex_replace(my_regex, '\\2')|
>                     trim }}"
>     - debug:
>         var: my_agent
>     - debug:
>         var: my_agent.Logical_Agent_Name
>
>
> --
> Vladimir Botka
>

-- 
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/CAAGhZYjkMvFNfLrX1jz9OYphsKt4xw_c9PX3XqJEQDEfEKct6A%40mail.gmail.com.

Reply via email to