Hi Dick, Below is the complete output of the playbook,

[root@tower1 temp_play]#  ansible-playbook testplay2.yml -i
/etc/ansible/temp_play/hosts

PLAY [Get the secondary router tunnel ip address]
*****************************************************************

TASK [Obtain secondary tunnel interface ip address]
***************************************************************
ok: [172.16.12.1]

TASK [debug]
******************************************************************************************************
ok: [172.16.12.1] => {
    "msg": [
        "Internet address is 172.16.121.6/32"
    ]
}

TASK [set_fact]
***************************************************************************************************
ok: [172.16.12.1]

TASK [debug]
******************************************************************************************************
ok: [172.16.12.1] => {
    "msg": {
        "ansible_facts": {
            "intf": "- [u'172.16.121.6']\n"
        },
        "changed": false,
        "failed": false
    }
}

PLAY RECAP
********************************************************************************************************
172.16.12.1                : ok=4    changed=0    unreachable=0    failed=0
   skipped=0    rescued=0    ignored=0

[root@tower1 temp_play]#

Thanks,
Charles Daniel


On Thu, 8 Jul 2021 at 15:34, Dick Visser <[email protected]> wrote:

> You're sending only the output of the debug task with the regex_search
> applied to the output.stdout variable.
> We need to see the output.stdout variable before you mangled it.
>
> On Thu, 8 Jul 2021 at 09:56, Charles Daniel <[email protected]>
> wrote:
> >
> > One more help needed, When I try to do regex to get the ip output, it
> comes along with the unicode characters such as - [u'
> > how to eliminate it while grepping it through regex_search itself.
> >
> > Actual output: "- [u'172.16.121.6']\n"
> >
> > I want it to be(expected): 172.16.121.6
> >
> >
> >   - name: Obtain secondary tunnel interface ip address
> >     ios_command:
> >       commands:
> >         - "show interface tunnel1 | sec Internet address"
> >     register: output
> >   - debug:
> >       msg: "{{ output.stdout}}"
> >   - set_fact:
> >       intf: |
> >           - {{output.stdout |
> map('regex_search','(([0-9]+(.)[0-9]+(.)[0-9]+(.)[0-9]+))') | list }}
> >     register: sec_tunnel_ip
> >   - debug:
> >        msg={{ sec_tunnel_ip }}
> >
> >
> > Output:
> > ********
> >
> > TASK [debug]
> ******************************************************************************************************
> > ok: [172.16.12.1] => {
> >     "msg": {
> >         "ansible_facts": {
> >             "intf": "- [u'172.16.121.6']\n"
> >         },
> >         "changed": false,
> >         "failed": false
> >     }
> > }
> >
> > Thanks,
> > Charles Daniel
> >
> > --
> > 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/CAPnV%3Dh%2B7LxPqEnbrezq3Maofib9Ak8UmLUsK10twE0DeqXKBPw%40mail.gmail.com
> .
>
>
>
> --
> Dick Visser
> Trust & Identity Service Operations Manager
> GÉANT
>
> --
> 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/CAL8fbwPitsJ0-RyoEdfUWJkV%3DBusc8y7gx8r_YnB1YuvDwuCeQ%40mail.gmail.com
> .
>

-- 
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/CAPnV%3DhLBRtLbu0RWnNodwDs7v7xfrtprATkeKhfKC6%2By98OVsQ%40mail.gmail.com.

Reply via email to