community.general.lxd 清单 - 从 lxd 主机返回 Ansible 清单

注意

此清单插件是 community.general 集合(版本 10.1.0)的一部分。

如果您正在使用 ansible 软件包,您可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install community.general。您需要进一步的要求才能使用此清单插件,请参阅 要求 了解详细信息。

要在剧本中使用它,请指定:community.general.lxd

community.general 3.0.0 中的新增功能

概要

  • 从 lxd 获取清单。

  • 使用以“lxd.(yml|yaml)”结尾的 YAML 配置文件。

要求

在执行此清单的本地控制器节点上需要以下要求。

  • ipaddress

  • lxd >= 4.0

参数

参数

注释

client_cert

别名:cert_file

路径

客户端证书文件路径。

默认值: "$HOME/.config/lxc/client.crt"

client_key

别名:key_file

路径

客户端证书密钥文件路径。

默认值: "$HOME/.config/lxc/client.key"

groupby

字典

通过以下关键字创建组 locationnetwork_rangeospatternprofilereleasetypevlanid

请参阅示例了解语法。

plugin

字符串 / 必需

确保这是“lxd”插件的源文件的令牌。

选项

  • "community.general.lxd"

prefered_instance_network_family

字符串

如果一个实例有多个网络接口,哪个是按系列首选的接口。

指定 inet 表示 IPv4,inet6 表示 IPv6。

选项

  • "inet" ← (默认)

  • "inet6"

prefered_instance_network_interface

别名:prefered_container_network_interface

字符串

如果一个实例有多个网络接口,请选择哪个接口是首选的模式。

与可以找到的第一个数字组合,例如“eth”+ 0。

该选项已从 prefered_container_network_interface 重命名为 prefered_instance_network_interface 在 community.general 3.8.0 中。旧名称仍然作为别名工作。

默认值: "eth"

project

字符串

在 community.general 6.2.0 中添加

根据给定的项目筛选实例。

默认值: "default"

server_cert

路径

在 community.general 8.0.0 中添加

服务器证书文件路径。

server_check_hostname

布尔值

在 community.general 8.0.0 中添加

此选项控制是否将服务器的主机名作为 HTTPS 连接验证的一部分进行检查。如果例如提供的服务器证书(请参阅 server_cert 选项)未涵盖与用于与服务器通信的名称匹配的名称,则禁用此选项很有用。这种不匹配很常见,因为 LXD 默认生成自签名服务器证书。

选项

  • false

  • true ← (默认)

state

字符串

根据当前状态筛选实例。

选项

  • "已停止"

  • "正在启动"

  • "正在运行"

  • "none" ← (默认)

信任密码

字符串

客户端信任密码。

在使用此模块之前,您需要在 lxd 服务器上设置此密码,使用以下命令:lxc config set core.trust_password <一些 随机 密码>。请参阅 https://documentation.ubuntu.com/lxd/en/latest/authentication/#adding-client-certificates-using-a-trust-password

如果设置了 trust_password,此模块将在发送任何请求之前发送身份验证请求。

类型过滤器

字符串

在 community.general 4.2.0 中添加

按类型过滤实例,可选值为 virtual-machinecontainerboth

inventory 的第一个版本仅支持容器。

选项

  • "virtual-machine"

  • "container" ← (默认)

  • "both"

url

字符串

lxd 服务器的 unix 域套接字路径或 https URL。

文件系统中的套接字必须以 unix: 开头。

通常是 unix:/var/lib/lxd/unix.socketunix:/var/snap/lxd/common/lxd/unix.socket

默认值: "unix:/var/snap/lxd/common/lxd/unix.socket"

示例

# simple lxd.yml
plugin: community.general.lxd
url: unix:/var/snap/lxd/common/lxd/unix.socket

# simple lxd.yml including filter
plugin: community.general.lxd
url: unix:/var/snap/lxd/common/lxd/unix.socket
state: RUNNING

# simple lxd.yml including virtual machines and containers
plugin: community.general.lxd
url: unix:/var/snap/lxd/common/lxd/unix.socket
type_filter: both

# grouping lxd.yml
groupby:
  locationBerlin:
    type: location
    attribute: Berlin
  netRangeIPv4:
    type: network_range
    attribute: 10.98.143.0/24
  netRangeIPv6:
    type: network_range
    attribute: fd42:bd00:7b11:2167:216:3eff::/24
  osUbuntu:
    type: os
    attribute: ubuntu
  testpattern:
    type: pattern
    attribute: test
  profileDefault:
    type: profile
    attribute: default
  profileX11:
    type: profile
    attribute: x11
  releaseFocal:
    type: release
    attribute: focal
  releaseBionic:
    type: release
    attribute: bionic
  typeVM:
    type: type
    attribute: virtual-machine
  typeContainer:
    type: type
    attribute: container
  vlan666:
    type: vlanid
    attribute: 666
  projectInternals:
    type: project
    attribute: internals

作者

  • Frank Dornheim (@conloos)

提示

每个条目类型的配置条目都具有从低到高的优先级顺序。例如,列表中较低的变量将覆盖较高的变量。