Documentation

lxd_profile - Manage LXD profiles

New in version 2.2.

Synopsis

  • Management of LXD profiles

Parameters

Parameter Choices/Defaults Comments
cert_file Default:
"{}/.config/lxc/client.crt" .format(os.environ["HOME"])
The client certificate file path.
config
The config for the container (e.g. {"limits.memory": "4GB"}). See 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> 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.
description
(added in 2.5)
Description of the profile.
devices
The devices for the profile (e.g. {"rootfs": {"path": "/dev/kvm", "type": "unix-char"}). See https://github.com/lxc/lxd/blob/master/doc/rest-api.md#patch-3
key_file Default:
"{}/.config/lxc/client.key" .format(os.environ["HOME"])
The client certificate key file path.
name
required
Name of a profile.
new_name
A new name of a profile.
If this parameter is specified a profile will be renamed to this name. See https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-11
state
    Choices:
  • present ←
  • absent
Define the state of a profile.
trust_password
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 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.
url Default:
unix:/var/lib/lxd/unix.socket
The unix domain socket path or the https URL for the LXD server.

Notes

Note

  • Profiles must have a unique name. If you attempt to create a profile with a name that already existed in the users namespace the module will simply return as “unchanged”.

Examples

# 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

# 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 cert_file and key_file values are equal to the default values.
      #cert_file: "{{ lookup('env', 'HOME') }}/.config/lxc/client.crt"
      #key_file: "{{ 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 deleting a profile
- hosts: localhost
  connection: local
  tasks:
    - name: Delete a profile
      lxd_profile:
        name: macvlan
        state: absent

# An example for renaming a profile
- hosts: localhost
  connection: local
  tasks:
    - name: Rename a profile
      lxd_profile:
        name: macvlan
        new_name: macvlan2
        state: present

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
actions
list
success
List of actions performed for the profile.

Sample:
["create"]
logs
list
when ansible-playbook is invoked with -vvvv.
The logs of requests and responses.

Sample:
(too long to be placed here)
old_state
string
success
The old state of the profile

Sample:
absent


Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

Maintenance

This module is flagged as community which means that it is maintained by the Ansible Community. See Module Maintenance & Support for more info.

For a list of other modules that are also maintained by the Ansible Community, see here.

Author

  • Hiroaki Nakamura (@hnakamur)

Hint

If you notice any issues in this documentation you can edit this document to improve it.