ansible - ansible中的regex_findall中的变量
问题描述
- name: Get names for all running Oracle databases from oratab file
slurp:
src: /etc/oratab
register: oracle_patch_oratab
- name: Extract a list of DBs which mataches the Oracle Home
set_fact:
oracle_patch_dblist: "{{ oracle_patch_oratab['content'] | b64decode | regex_findall ('(.+v12201.+)', multiline=True, ignorecase=True) }}"
在 regex_findall 中,我将一个值硬编码为 v12201,我想用变量替换它。如果是这样,在 regex_findall 中使用的语法是什么?提前致谢。
解决方案
我尝试了以下方法,效果很好。
- name: Get names for all running Oracle databases from oratab file
slurp:
src: /etc/oratab
register: oracle_patch_oratab
- name: "assign pattern"
set_fact:
ora_ver: "12201"
- name: Extract a list of DBs which mataches the Oracle Home
set_fact:
oracle_patch_dblist: "{{ oracle_patch_oratab['content'] | b64decode | regex_findall ('(.+' + ora_ver | string + '.+)', multiline=True, ignorecase=True) }}"
推荐阅读
- powershell - 脚本路径中的 Powershell 空格
- postgresql - 如何提高 Spring Data JPA 性能
- ruby-on-rails - (Rails)将带有初始数据的新模型添加到现有应用程序
- json - Python3 - Json 通过 Rest API 写入值
- c++ - OpenGL 应用程序在不同计算机上的工作方式不同
- javascript - 从 html 中向左滑动和向右滑动调用 id 并链接到 href,在数字图书中翻页
- python-3.x - MacOS Python 3.7 virtualenv 失败?
- sql-server - 通过 SQL Server 汇总每个 orderID 的文章
- c# - 使用 Circle CI 配置值插值?
- login - 如何通过 Selenium2Library 在浏览器中切换到新的“登录对话框”?