Last active
August 10, 2023 08:39
-
-
Save restump/c22b361a3127c61f9d4970254b367c1f to your computer and use it in GitHub Desktop.
Example demonstrating string extraction from HTML content in Ansible with regex_search filter plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: localhost | |
connection: local | |
tasks: | |
- uri: | |
url: https://rstumph2.service-now.com/stats.do | |
return_content: yes | |
register: response | |
- debug: msg="{{ response.content }}" | |
- set_fact: "mid_build_stamp={{ response.content | regex_search('MID buildstamp: ([^<]{1,})') }}" | |
- debug: "msg={{ mid_build_stamp.split(': ')[1]}}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just in case someones stumbles across this from google, like I did. There is no need to use intermediate set_fact.