community.general.lxd_profile 模块 – 管理 LXD 配置文件
注意
此模块是 community.general 集合(版本 10.1.0)的一部分。
如果您正在使用 ansible 包,您可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用: ansible-galaxy collection install community.general。
要在 playbook 中使用它,请指定: community.general.lxd_profile。
概要
- 管理 LXD 配置文件 
参数
| 参数 | 注释 | 
|---|---|
| 客户端证书文件路径。 如果未指定,则默认为  | |
| 客户端证书密钥文件路径。 如果未指定,则默认为  | |
| 实例的配置(例如,{“limits.memory”: “4GB”})。请参阅 https://documentation.ubuntu.com/lxd/en/latest/api/#/profiles/profile_get。 如果配置文件已存在,并且其从 GET /1.0/profiles/<name> https://documentation.ubuntu.com/lxd/en/latest/api/#/profiles/profile_get 获取的元数据中的“config”值不同,则此模块会尝试应用配置 https://documentation.ubuntu.com/lxd/en/latest/api/#/profiles/profile_put。 并非所有配置值都支持应用于现有配置文件。您可能需要删除并重新创建配置文件。 | |
| 配置文件的描述。 | |
| 配置文件的设备(例如,{“rootfs”: {“path”: “/dev/kvm”, “type”: “unix-char”}})。请参阅 https://documentation.ubuntu.com/lxd/en/latest/api/#/profiles/profile_get。 | |
| 将当前配置文件的配置与新的期望配置合并,而不是替换它。 选项 
 | |
| 配置文件的名称。 | |
| 配置文件的名称。 如果指定了此参数,则配置文件将重命名为此名称。请参阅 https://documentation.ubuntu.com/lxd/en/latest/api/#/profiles/profile_post。 | |
| 当 LXD 通过 snap 包管理器安装时,Unix 域套接字路径。 默认值:  | |
| 定义配置文件的状态。 选项 
 | |
| 客户端信任密码。 您需要在运行此模块之前使用以下命令在 LXD 服务器上设置此密码。lxc config set core.trust_password <some random password> 请参阅 https://www.stgraber.org/2016/04/18/lxd-api-direct-interaction/ 如果设置了 trust_password,则此模块会在发送任何请求之前发送身份验证请求。 | |
| LXD 服务器的 Unix 域套接字路径或 https URL。 默认值:  | 
属性
| 属性 | 支持 | 描述 | 
|---|---|---|
| 支持: 无 | 可以在  | |
| 支持: 无 | 当处于差异模式时,将返回有关已更改(或可能需要在  | 
备注
注意
- 配置文件必须具有唯一的名称。如果您尝试创建名称已存在于用户命名空间中的配置文件,则该模块将简单地返回“未更改”。 
示例
# An example for creating a profile
- hosts: localhost
  connection: local
  tasks:
    - name: Create a profile
      community.general.lxd_profile:
        name: macvlan
        state: present
        config: {}
        description: my macvlan profile
        devices:
          eth0:
            nictype: macvlan
            parent: br0
            type: nic
# An example for creating a profile in project mytestproject
- hosts: localhost
  connection: local
  tasks:
    - name: Create a profile
      community.general.lxd_profile:
        name: testprofile
        project: mytestproject
        state: present
        config: {}
        description: test profile in project mytestproject
        devices: {}
# An example for creating a profile via http connection
- hosts: localhost
  connection: local
  tasks:
  - name: Create macvlan profile
    community.general.lxd_profile:
      url: https://127.0.0.1:8443
      # These client_cert and client_key values are equal to the default values.
      #client_cert: "{{ lookup('env', 'HOME') }}/.config/lxc/client.crt"
      #client_key: "{{ lookup('env', 'HOME') }}/.config/lxc/client.key"
      trust_password: mypassword
      name: macvlan
      state: present
      config: {}
      description: my macvlan profile
      devices:
        eth0:
          nictype: macvlan
          parent: br0
          type: nic
# An example for modify/merge a profile
- hosts: localhost
  connection: local
  tasks:
    - name: Merge a profile
      community.general.lxd_profile:
        merge_profile: true
        name: macvlan
        state: present
        config: {}
        description: my macvlan profile
        devices:
          eth0:
            nictype: macvlan
            parent: br0
            type: nic
# An example for deleting a profile
- hosts: localhost
  connection: local
  tasks:
    - name: Delete a profile
      community.general.lxd_profile:
        name: macvlan
        state: absent
# An example for renaming a profile
- hosts: localhost
  connection: local
  tasks:
    - name: Rename a profile
      community.general.lxd_profile:
        name: macvlan
        new_name: macvlan2
        state: present
返回值
常见的返回值记录在这里,以下是本模块特有的字段。
| 键 | 描述 | 
|---|---|
| 为配置文件执行的操作列表。 返回: 成功 示例:  | |
| 请求和响应的日志。 返回: 当使用 -vvvv 调用 ansible-playbook 时。 示例:  | |
| 配置文件的旧状态 返回: 成功 示例:  | 
