Thank you,
This is how I wrote-
- name: SET FACT - Interface SPEED -1
set_fact:
speed_list1: "{{ item.split('=')[1] | default(omit) }}"
with_items:
- '{{ speed_list }}'
- name: Debug Speed
debug: msg="{{ speed_list1 }}"
Still the output is same-
TASK [Debug Speed]
**************************************************************************************************************************************************
ok: [localhost] =>
msg: ' 0'
On Friday, 26 February 2021 at 22:13:31 UTC+5:30 [email protected] wrote:
> Maybe you can use split.
>
> item.split("=")[1]
>
> should refer to what is at the right of "=".
>
> El viernes, 26 de febrero de 2021 a la(s) 10:12:46 UTC-6,
> [email protected] escribió:
>
>> Hello Everyone,
>> When I use the regex_search in tasks, it is adding single quotes in the
>> starting and end.
>> Like for this -
>> - sw01 GigabitEthernet0/0 IF-MIB.ifSpeed = 1000000000
>> when I use regex_search-
>> - name: SET FACT - Interface SPEED -1
>> set_fact:
>> speeds: "{{ item.0 | regex_search('[^=]*$') | regex_replace(' ',
>> '') }}"
>>
>> Converting above value to -
>> ok: [localhost] => (item=['sw01 GigabitEthernet0/0 IF-MIB.ifSpeed =
>> 1000000000'])
>>
>> My goal is fetch the value after '='
>> sw01 GigabitEthernet0/0 IF-MIB.ifSpeed = 1000000000
>> to
>> 1000000000
>>
>> please advise.
>>
>>
--
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/6b786e68-f3a9-4948-9f81-45741c355ebdn%40googlegroups.com.