ansible.builtin.lxd_profile (v2.9.27) — module

Manage LXD profiles

| "added in version" 2.2 of ansible.builtin"

Authors: Hiroaki Nakamura (@hnakamur)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.27

Description

Management of LXD profiles

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# An example for creating a profile
- hosts: localhost
  connection: local
  tasks:
    - name: Create a profile
      lxd_profile:
        name: macvlan
        state: present
        config: {}
        description: my macvlan profile
        devices:
          eth0:
            nictype: macvlan
            parent: br0
            type: nic
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# An example for creating a profile via http connection
- hosts: localhost
  connection: local
  tasks:
  - name: create macvlan profile
    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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# An example for deleting a profile
- hosts: localhost
  connection: local
  tasks:
    - name: Delete a profile
      lxd_profile:
        name: macvlan
        state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# An example for renaming a profile
- hosts: localhost
  connection: local
  tasks:
    - name: Rename a profile
      lxd_profile:
        name: macvlan
        new_name: macvlan2
        state: present

Inputs

    
url:
    default: unix:/var/lib/lxd/unix.socket
    description:
    - The unix domain socket path or the https URL for the LXD server.
    required: false

name:
    description:
    - Name of a profile.
    required: true

state:
    choices:
    - present
    - absent
    default: present
    description:
    - Define the state of a profile.
    required: false

config:
    description:
    - 'The config for the container (e.g. {"limits.memory": "4GB"}). See U(https://github.com/lxc/lxd/blob/master/doc/rest-api.md#patch-3)'
    - If the profile already exists and its "config" value in metadata obtained from GET
      /1.0/profiles/<name> U(https://github.com/lxc/lxd/blob/master/doc/rest-api.md#get-19)
      are different, they this module tries to apply the configurations.
    - Not all config values are supported to apply the existing profile. Maybe you need
      to delete and recreate a profile.
    required: false

devices:
    description:
    - 'The devices for the profile (e.g. {"rootfs": {"path": "/dev/kvm", "type": "unix-char"}).
      See U(https://github.com/lxc/lxd/blob/master/doc/rest-api.md#patch-3)'
    required: false

new_name:
    description:
    - A new name of a profile.
    - If this parameter is specified a profile will be renamed to this name. See U(https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-11)
    required: false

snap_url:
    default: unix:/var/snap/lxd/common/lxd/unix.socket
    description:
    - The unix domain socket path when LXD is installed by snap package manager.
    required: false
    version_added: '2.8'
    version_added_collection: ansible.builtin

client_key:
    aliases:
    - key_file
    default: '"{}/.config/lxc/client.key" .format(os.environ["HOME"])'
    description:
    - The client certificate key file path.
    required: false

client_cert:
    aliases:
    - cert_file
    default: '"{}/.config/lxc/client.crt" .format(os.environ["HOME"])'
    description:
    - The client certificate file path.
    required: false

description:
    description:
    - Description of the profile.
    version_added: '2.5'
    version_added_collection: ansible.builtin

trust_password:
    description:
    - The client trusted password.
    - You need to set this password on the LXD server before running this module using
      the following command. lxc config set core.trust_password <some random password>
      See U(https://www.stgraber.org/2016/04/18/lxd-api-direct-interaction/)
    - If trust_password is set, this module send a request for authentication before sending
      any requests.
    required: false

Outputs

actions:
  description: List of actions performed for the profile.
  returned: success
  sample: '["create"]'
  type: list
logs:
  description: The logs of requests and responses.
  returned: when ansible-playbook is invoked with -vvvv.
  sample: (too long to be placed here)
  type: list
old_state:
  description: The old state of the profile
  returned: success
  sample: absent
  type: str