Score:1

what ansible filter can I use on hostvars to extract string

cn flag
"{{ hostvars['DUMMY_HOST']['iosengineID'] }}"

value returns is this

{'msg': [['80000009045B575A5032333331303055565D']], 'failed': False, 'changed': False} 

Which filter can I use extract or print or register the value

80000009045B575A5032333331303055565D
Score:0
cn flag

I had to use this crazy crazy filter on hostvars!!!!

"{{ hostvars['DUMMY_HOST']['foundengineID'] | regex_replace('[^A-Za-z0-9]','') | replace('msg','') | replace('failedFalsechangedFalse','') }}"

and then it writes this value so I can use it as a variable to write it in a file:

80000009045B575A5032333331303055565D
Score:0
br flag

The value of iosengineID is a list with a single item that is a list

iosengineID: [['80000009045B575A5032333331303055565D']]

What you want is the first item on the first list

    - debug:
        var: iosengineID.0.0

gives

  iosengineID.0.0: 80000009045B575A5032333331303055565D
Andreas avatar
cn flag
Ah man that is way easier! Thanks.
Zeitounator avatar
fr flag
@Andreas The way to say "thank you" on serverfault or on any other stackechange sites is to up-vote and/or accept (green tick) answers you find useful. See [What should I do when someone answers my question?](/help/someone-answers)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.