ngine_io.cloudstack.instance 资源清单 – Apache CloudStack 实例资源清单来源
注意
此资源清单插件是 ngine_io.cloudstack 集合 (版本 2.5.0) 的一部分。
如果您使用的是 ansible 包,则可能已安装此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install ngine_io.cloudstack。您需要其他要求才能使用此资源清单插件,有关详细信息,请参阅 要求。
要在 playbook 中使用它,请指定:ngine_io.cloudstack.instance。
ngine_io.cloudstack 2.1.0 中的新增功能
概要
- 从 Apache CloudStack 获取资源清单主机 
- 允许过滤和分组资源清单主机。 
- 使用以 cloudstack-instances.yml 或 cloudstack-instances.yaml 结尾的 YAML 配置文件设置参数值(另请参见示例)。 
要求
以下要求是在执行此资源清单的本地控制器节点上需要的。
- python >= 2.6 
- cs >= 0.9.0 
参数
| 参数 | 注释 | 
|---|---|
| 用于查询 API 端点的 HTTP 方法。 如果未给出,则考虑  选项 
 配置 
 | |
| CloudStack API 的 URL,例如 https://cloud.example.com/client/api。 如果未给出,则考虑  配置 
 | |
| 从 jinja2 表达式创建变量。 默认值:  | |
| 仅返回提供的域中的实例。 | |
| 仅返回提供的项目中的实例。 | |
| 仅返回提供的 VPC 中的实例。 | |
| 仅返回提供的区域中的实例。 | |
| 根据 Jinja2 条件将主机添加到组。 默认值:  | |
| 匹配主机名的字段。注意 v4_main_ip 对应于实例的第一个网卡的 primary ipv4address。 选项 
 | |
| 根据变量的值将主机添加到组。 默认值:  | |
| 主机变量的值为空字符串时的默认值。 此选项与  | |
| 用于生成组的输入字典中的键。 | |
| 键控组的父组。 | |
| 键控组名将以此前缀开头。 默认值:  | |
| 用于构建键控组名的分隔符。 默认值:  | |
| 将此选项设置为  此选项与  选项 
 | |
| 与  默认情况下,未提供前缀或分隔符的键控组的名称将以下划线开头。 这是因为默认前缀为  将此选项设置为  如果组名来自映射,则仍然使用分隔符连接项目。 要完全不使用组名中的分隔符,请将键控组的分隔符设置为空字符串。 选项 
 | |
| 确保这是“instance”插件的源文件的令牌。 选项 
 | |
| 如果为  由于可以在表达式中使用事实,因此它们可能并不总是可用,并且我们默认忽略这些错误。 选项 
 | |
| 将额外的变量合并到可用于组合的变量中(最高优先级)。 选项 
 配置 
 | |
| 如果为  如果没有给出,则考虑  这仅应在使用自签名证书的个人控制站点上使用。 选项 
 | 
注释
注意
- 有关 CloudStack 模块的详细指南,请参阅 CloudStack 云指南。 
- 此模块支持检查模式。 
示例
# inventory_cloudstack.yml file in YAML format
# Example command line: ansible-inventory --list -i cloudstack-instances.yml
plugin: ngine_io.cloudstack.instance
# Use the default ip as ansible_host
hostname: v4_default_ip
# Return only instances related to the VPC vpc1 and in the zone EU
filter_by_vpc: vpc1
filter_by_zone: EU
# Group instances with a disk_offering as storage
# Create a group dmz for instances connected to the dmz network
groups:
  storage: disk_offering is defined
  dmz: "'dmz' in networks"
# Group the instances by network, with net_network1 as name of the groups
# Group the instanes by custom tag sla, groups like sla_value for tag sla
keyed_groups:
  - prefix: net
    key: networks
  - prefix: sla
    key: tags.sla
