azure - Azure 资源管理器清单插件可以根据资源组名称的子字符串动态查找 VM(在 include_vm_resource_groups 中)
问题描述
Azure 资源管理器清单插件如何根据资源组名称的子字符串动态查找 VM(在 include_vm_resource_groups 中)
我可以使用 include_vm_resource_groups 中的完整资源组名称获取 VM 列表,但在使用资源组名称的部分\子字符串时不能。
请举个例子谢谢
解决方案
不,不能使用子字符串。
作为一种解决方法,我在剧本文件中的主机变量上放置了一个过滤器
# This is an explanation of the following command:
# 1. Find the hostname of Ansible host using lookup("pipe","hostname").
# 2. Pipe the result and replace "-management-ansible" with "_cluster". E.g of output: ddd-dev001-01_cluster
# 3. Pipe the result and replace "-" with "_". E.g of output: ddd_dev001_01_cluster
# 4. Append the result to hosts group "tag_workspace_". E.g of output: tag_workspace_ddd_dev001_01_cluster
# Note hyphens are not accepted in host group names.
hosts: tag_workspace_{{ lookup("pipe","hostname") | regex_replace('-management-ansible', '_cluster') | regex_replace('-', '_') }}
推荐阅读
- openmp - 在openmp中操作二维数组
- outlook-addin - Outlook 2019:主页功能区中未显示按钮
- mysql - 如何进行查询以过滤掉同一列上的两个 AND 条件
- sql-server - 如何在 SAP B1 中自动计算 Header 和 Row UDF 值
- flask - 使用 Flask 和请求的 OpenCensus 分布式跟踪传播
- python - 如何在 Python 中保存一个新的 excel 文件
- javascript - iframe内的html表单输入在焦点时不显示虚拟键盘
- python - 在Python中将两个列表组合成另一个列表对象中的笛卡尔积
- asp.net-core - MS Graph SDK 在检索不存在的照片时抛出错误错误
- telegraf - 在 Docker 中运行 Telegraf 时获取容器主机指标