[英]Ansible. Parse yaml. Getting a value from a string
如何從以下變量中包含的字符串中獲取 mac 地址 00 50 79 66 68 04?
"oid.stdout_lines": [
"iso.3.6.1.2.1.17.4.3.1.1.0.80.121.102.104.4 \"00 50 79 66 68 04 \""
]
使用regex_replace 。 例如
_regex: '.*"(.*)"'
_replace: '\1'
mac: "{{ oid.stdout_lines|first|regex_replace(_regex, _replace)|trim }}"
給
mac: 00 50 79 66 68 04
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.