Join AnsibleFest at Red Hat Summit!

vmware.vmware.local_content_library module – Manage a local content library.

Note

This module is part of the vmware.vmware collection (version 1.10.1).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install vmware.vmware. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: vmware.vmware.local_content_library.

Synopsis

  • Create, update, or destroy a local content library.

Requirements

The below requirements are needed on the host that executes this module.

  • vSphere Automation SDK

Parameters

Parameter

Comments

authentication_current_password

string

The current password for the library when the library is using BASIC authentication.

If not supplied, the value of authentication_password is used.

You must supply a password when the library is already configured with BASIC auth and state is present.

If you want to update the password, set this to the old password and authentication_password to the new password.

If BASIC auth is not enabled, this option is ignored.

authentication_method

string

The method of authentication to use if this is published local library.

The only options are NONE for no authentication or BASIC for username and password authentication.

The username for BASIC authentication cannot be changed and is vcsp.

Choices:

  • "BASIC"

  • "NONE" ← (default)

authentication_password

string

The password to use when authentication_method is BASIC.

If authentication is already enabled on the library, you must supply the password to update the library.

If authentication_current_password is supplied, authentication_password should be the new password you want to use for this library.

If BASIC auth is not enabled, this option is ignored.

datastore

aliases: datastore_name

string

The name of the datastore that should be a storage backing for the library.

This parameter is required when state is present

This parameter only takes effect when the library is first created. You cannot change the storage backing for an existing library, and the module will not check this value in that case.

description

aliases: library_description

string

The description for the content library.

Default: ""

hostname

string

The hostname or IP address of the vSphere vCenter server.

If the value is not specified in the task, the value of environment variable VMWARE_HOST will be used instead.

name

aliases: library_name

string / required

The name of the local content library to manage.

password

aliases: pass, pwd

string

The password of the vSphere vCenter server.

If the value is not specified in the task, the value of environment variable VMWARE_PASSWORD will be used instead.

persist_json_enabled

boolean

If true, a JSON file describing the library metadata will be kept in the library.

This file allows you to sync a remote library by copying the library contents instead of relying on HTTP.

Choices:

  • false ← (default)

  • true

port

integer

The port number of the vSphere vCenter server.

If the value is not specified in the task, the value of environment variable VMWARE_PORT will be used instead.

Default: 443

proxy_host

string

The address of a proxy that will receive all HTTPS requests and relay them.

The format is a hostname or a IP.

If the value is not specified in the task, the value of environment variable VMWARE_PROXY_HOST will be used instead.

proxy_port

integer

The port of the HTTP proxy that will receive all HTTPS requests and relay them.

If the value is not specified in the task, the value of environment variable VMWARE_PROXY_PORT will be used instead.

proxy_protocol

aliases: protocol

string

The proxy connection protocol to use.

This option is used if the correct proxy protocol cannot be automatically determined.

Choices:

  • "http"

  • "https" ← (default)

publish

boolean

If true, this library will be published so other libraries can subscribe to it.

Choices:

  • false ← (default)

  • true

state

string

Whether the content library should be present or absent.

Choices:

  • "present" ← (default)

  • "absent"

username

aliases: admin, user

string

The username of the vSphere vCenter server.

If the value is not specified in the task, the value of environment variable VMWARE_USER will be used instead.

validate_certs

boolean

Allows connection when SSL certificates are not valid. Set to false when certificates are not trusted.

If the value is not specified in the task, the value of environment variable VMWARE_VALIDATE_CERTS will be used instead.

Choices:

  • false

  • true ← (default)

Notes

Note

  • All modules require API write access and hence are not supported on a free ESXi license.

  • All variables and VMware object names are case sensitive.

  • Modules may rely on the ‘requests’ python library, which does not use the system certificate store by default. You can specify the certificate store by setting the REQUESTS_CA_BUNDLE environment variable. Example: ‘export REQUESTS_CA_BUNDLE=/path/to/your/ca_bundle.pem’

Examples

- name: Create Local Content Library
  vmware.vmware.local_content_library:
    validate_certs: false
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    datastore_name: "{{ shared_storage }}"
    name: my-library
    state: present


- name: Publish Library Without Authentication
  vmware.vmware.local_content_library:
    validate_certs: false
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    datastore_name: "{{ shared_storage }}"
    name: my-library
    publish: true
    persist_json_enabled: true
    state: present

- name: Publish Library With Authentication
  vmware.vmware.local_content_library:
    validate_certs: false
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    datastore_name: "{{ shared_storage }}"
    name: my-library
    authentication_method: BASIC
    authentication_password: Mypassword!
    publish: true
    persist_json_enabled: true
    state: present

- name: Update Library Password
  vmware.vmware.local_content_library:
    validate_certs: false
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    datastore_name: "{{ shared_storage }}"
    name: my-library
    authentication_method: BASIC
    authentication_password: MyNewPassword1234!
    authentication_current_password: Mypassword!
    publish: true
    persist_json_enabled: true
    state: present

- name: Remove Library Password
  vmware.vmware.local_content_library:
    validate_certs: false
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    datastore_name: "{{ shared_storage }}"
    name: my-library
    authentication_password: MyNewPassword1234!
    publish: true
    persist_json_enabled: true
    state: present

- name: Unpublish Library Password
  vmware.vmware.local_content_library:
    validate_certs: false
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    datastore_name: "{{ shared_storage }}"
    name: my-library
    publish: false
    state: present


- name: Destroy Library
  vmware.vmware.local_content_library:
    validate_certs: false
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    name: my-library
    state: absent

Return Values

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

Key

Description

library

dictionary

Identifying information about the library

If the library was removed, only the name is returned

If the library was published, the publish_url is returned

Returned: On success

Sample: {"library": {"id": "example-cluster", "name": "domain-c111111", "publish_url": "https://vcenter.com:443/cls/vcsp/lib/111111-111111111-11111-111111/lib.json"}}

Authors

  • Ansible Cloud Team (@ansible-collections)