community.general.lxd_project (8.5.0) — module

Manage LXD projects

| "added in version" 4.8.0 of community.general"

Authors: Raymond Chang (@we10710aa)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Management of LXD projects.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# An example for creating a project
- hosts: localhost
  connection: local
  tasks:
    - name: Create a project
      community.general.lxd_project:
        name: ansible-test-project
        state: present
        config: {}
        description: my new project
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# An example for renaming a project
- hosts: localhost
  connection: local
  tasks:
    - name: Rename ansible-test-project to ansible-test-project-new-name
      community.general.lxd_project:
        name: ansible-test-project
        new_name: ansible-test-project-new-name
        state: present
        config: {}
        description: my new project

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
    type: str

name:
    description:
    - Name of the project.
    required: true
    type: str

state:
    choices:
    - present
    - absent
    default: present
    description:
    - Define the state of a project.
    required: false
    type: str

config:
    description:
    - 'The config for the project (for example V({"features.profiles": "true"})). See
      U(https://documentation.ubuntu.com/lxd/en/latest/api/#/projects/project_get).'
    - If the project already exists and its "config" value in metadata obtained from C(GET
      /1.0/projects/<name>) U(https://documentation.ubuntu.com/lxd/en/latest/api/#/projects/project_get)
      are different, then this module tries to apply the configurations U(https://documentation.ubuntu.com/lxd/en/latest/api/#/projects/project_put).
    type: dict

new_name:
    description:
    - A new name of a project.
    - If this parameter is specified a project will be renamed to this name. See U(https://documentation.ubuntu.com/lxd/en/latest/api/#/projects/project_post).
    required: false
    type: str

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
    type: str

client_key:
    aliases:
    - key_file
    description:
    - The client certificate key file path.
    - If not specified, it defaults to C($HOME/.config/lxc/client.key).
    required: false
    type: path

client_cert:
    aliases:
    - cert_file
    description:
    - The client certificate file path.
    - If not specified, it defaults to C($HOME/.config/lxc/client.crt).
    required: false
    type: path

description:
    description:
    - Description of the project.
    type: str

merge_project:
    default: false
    description:
    - Merge the configuration of the present project with the new desired configuration,
      instead of replacing it. If configuration is the same after merged, no change will
      be made.
    required: false
    type: bool

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: C(lxc config set core.trust_password <some random password>)
      See U(https://www.stgraber.org/2016/04/18/lxd-api-direct-interaction/).'
    - If O(trust_password) is set, this module send a request for authentication before
      sending any requests.
    required: false
    type: str

Outputs

actions:
  description: List of actions performed for the project.
  elements: str
  returned: success
  sample:
  - create
  type: list
logs:
  contains:
    request:
      contains:
        json:
          description: JSON body of HTTP request.
          sample: (too long to be placed here)
          type: str
        method:
          description: Method of HTTP request.
          sample: GET
          type: str
        timeout:
          description: Timeout of HTTP request, V(null) if unset.
          sample: null
          type: int
        url:
          description: URL path of HTTP request.
          sample: /1.0/projects/test-project
          type: str
      description: HTTP request sent to LXD server.
      type: dict
    response:
      contains:
        json:
          description: JSON of HTTP response.
          sample: (too long to be placed here)
          type: str
      description: HTTP response received from LXD server.
      type: dict
    type:
      description: Type of actions performed, currently only V(sent request).
      sample: sent request
      type: str
  description: The logs of requests and responses.
  elements: dict
  returned: when ansible-playbook is invoked with -vvvv.
  type: list
old_state:
  description: The old state of the project.
  returned: success
  sample: absent
  type: str