vmware.vmware_rest.content_locallibrary module – Creates a new local library.
Note
This module is part of the vmware.vmware_rest collection (version 4.4.0).
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_rest
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: vmware.vmware_rest.content_locallibrary
.
New in vmware.vmware_rest 2.0.0
Synopsis
Creates a new local library.
Requirements
The below requirements are needed on the host that executes this module.
vSphere 7.0.3 or greater
python >= 3.6
aiohttp
Parameters
Parameter |
Comments |
---|---|
A unique token generated on the client for each creation request. The token should be a universally unique identifier (UUID), for example: b8a2a2e3-2314-43cd-a871-6ede0f429751. This token can be used to guarantee idempotent creation. If not specified creation is not idempotent. |
|
The date and time when this library was created. This field is not used for the create operation. It will always be present in the result of the get or list operations. It is not used for the update operation. |
|
A human-readable description for this library. This field is optional for the create operation. Leaving it unset during creation will result in an empty string value. It will always be present in the result of a get or list operation. It is optional for the update operation. Leaving it unset during update indicates that the description should be left unchanged. |
|
An identifier which uniquely identifies this LibraryModel. This field is not used for the create operation. It will not be present in the result of the get or list operations. It is not used for the update operation. When clients pass a value of this structure as a parameter, the field must be the id of a resource returned by vmware.vmware_rest.content_library_info. |
|
The date and time when this library was last updated. This field is updated automatically when the library properties are changed. This field is not affected by adding, removing, or modifying a library item or its content within the library. Tagging the library or syncing the subscribed library does not alter this field. This field is not used for the create operation. It will always be present in the result of the get or list operations. It is not used for the update operation. |
|
The date and time when this library was last synchronized. This field applies only to subscribed libraries. It is updated every time a synchronization is triggered on the library. The value is unset for a local library. This field is not used for the create operation. It is optional in the result of the get or list operations. It is not used for the update operation. |
|
Identifier of the local library to delete. The parameter must be the id of a resource returned by vmware.vmware_rest.content_library_info. Required with state=[‘absent’, ‘present’, ‘publish’] |
|
The name of the library. A Library is identified by a human-readable name. Library names cannot be undefined or an empty string. Names do not have to be unique. This field must be provided for the create operation. It will always be present in the result of the get or list operations. It is optional for the update operation. |
|
Defines various optimizations and optimization parameters applied to this library. This field is optional for the create operation. It is optional in the result of the get or list operations. It is optional for the update operation. Valid attributes are:
Turn it on if remote publishing is dominant use case for this library. Remote publishing means here that publisher and subscribers are not the part of the same Vcenter SSO domain. Any optimizations could be done as result of turning on this optimization during library creation. For example, library content could be stored in different format but optimizations are not limited to just storage format. Note, that value of this toggle could be set only during creation of the library and you would need to migrate your library in case you need to change this value (optimize the library for different use case). This field is optional for the create operation. If not specified for the create, the default is for the library to not be optmized for specific use case. It is not used for the update operation. ([‘present’]) |
|
Defines how this library is published so that it can be subscribed to by a remote subscribed library. The PublishInfo defines where and how the metadata for this local library is accessible. A local library is only published publically if PublishInfo.published is true. This field is optional for the create and update operations. If not specified during creation, the default is for the library to not be published. If not specified during update, the field is left unchanged. Valid attributes are:
This field is required for the LocalLibrary.create operation. It is optional for the LocalLibrary.update operation, and if unset the value will not be changed. When the existing authentication method is BASIC and the local library is published, the PublishInfo.current-password field is required before turning off publishing. This field will always be present in the results of the LocalLibrary.get operation. ([‘present’])
This value can be used to set the SubscriptionInfo.subscription-url property when creating a subscribed library. This field is not used for the create operation. It will always be present in the result of the get or list operations. It is not used for the update operation. ([‘present’])
This field is optional for the LocalLibrary.create and LocalLibrary.update operations. When the authentication method is NONE, the username can be left unset. When the authentication method is BASIC, the username is ignored in the current release. It defaults to “vcsp”. It is preferable to leave this unset. If specified, it must be set to “vcsp”. ([‘present’])
This field is optional for the LocalLibrary.create operation. When the authentication method is NONE, the password can be left unset. When the authentication method is BASIC, the password should be a non-empty string. This field is optional for the LocalLibrary.update operation. Leaving it unset during update indicates that the password is not changed. When the password is changed, the PublishInfo.current-password field is required. This field is not used for the LocalLibrary.get operation. ([‘present’])
This field is unused for the LocalLibrary.create operation. This field is optional for the LocalLibrary.update operation. When the existing authentication method is NONE, the current password can be left unset. When the existing authentication method is BASIC, the current password is verified before applying the new PublishInfo.password, turning off authentication, or unpublishing the library. This field is not used for the LocalLibrary.get operation. ([‘present’])
Enabling JSON persistence allows you to synchronize a subscribed library manually instead of over HTTP. You copy the local library content and metadata to another storage backing manually and then create a subscribed library referencing the location of the library JSON file in the SubscriptionInfo.subscription-url. When the subscribed library’s storage backing matches the subscription URL, files do not need to be copied to the subscribed library. For a library backed by a datastore, the library JSON file will be stored at the path contentlib-{library_id}/lib.json on the datastore. For a library backed by a remote file system, the library JSON file will be stored at {library_id}/lib.json in the remote file system path. This field is optional for the create operation. It will always be present in the result of the get or list operations. It is optional for the update operation. ([‘present’]) |
|
Represents the security policy applied to this library. Setting the field will make the library secure. This field is ignored in update operation if LibraryModel.unset-security-policy-id is set to true. This field is optional for the create and update operations. If not set in create operation, the library will be insecure. If not specified in update operation, the field is left unchanged. When clients pass a value of this structure as a parameter, the field must be the id of a resource returned by vmware.vmware_rest.content_library_info. |
|
The unique identifier of the vCenter server where the library exists. This field is optional for the create operation. It will always be present in the result of the get or list operations. It is not used for the update operation. When clients pass a value of this structure as a parameter, the field must be the id of a resource returned by vmware.vmware_rest.vcenter_cluster_info. |
|
Timeout settings for client session. The maximal number of seconds for the whole operation including connection establishment, request sending and response. The default value is 300s. |
|
Choices:
|
|
The list of default storage backings which are available for this library. A StorageBacking defines a default storage location which can be used to store files for library items in this library. Some library items, for instance, virtual machine template items, support files that may be distributed across various storage backings. One or more item files may or may not be located on the default storage backing. Multiple default storage locations are not currently supported but may become supported in future releases. This field must be provided for the create operation. It will always be present in the result of the get or list operations. It is not used for the update operation. Valid attributes are:
This field is optional and it is only relevant when the value of StorageBacking.type is DATASTORE. When clients pass a value of this structure as a parameter, the field must be the id of a resource returned by vmware.vmware_rest.vcenter_datastore_info. ([‘present’])
The following URI formats are supported: vSphere 6.5
vSphere 6.0 Update 1
vSphere 6.0
This field is optional and it is only relevant when the value of StorageBacking.type is OTHER. ([‘present’]) |
|
Defines the subscription behavior for this Library. The SubscriptionInfo defines how this subscribed library synchronizes to a remote source. Setting the value will determine the remote source to which the library synchronizes, and how. Changing the subscription will result in synchronizing to a new source. If the new source differs from the old one, the old library items and data will be lost. Setting SubscriptionInfo.automatic-sync-enabled to false will halt subscription but will not remove existing cached data. This field is optional for the create and update operations. If not specified during creation, a default will be created without an active subscription. If not specified during update, the field is left unchanged. Valid attributes are:
This field must be provided for the create operation. It will always be present in the result of the get or list operations. It is optional for the update operation. ([‘present’])
If this is set to true, then the library item’s metadata will be synchronized but the item’s content (its files) will not be synchronized. The Content Library Service will synchronize the content upon request only. This can cause the first use of the content to have a noticeable delay. Items without synchronized content can be forcefully synchronized in advance using the SubscribedItem.sync call with forceSyncContent set to true. Once content has been synchronized, the content can removed with the SubscribedItem.evict call. If this value is set to false, all content will be synchronized in advance. This field must be provided for the create operation. It will always be present in the result of the get or list operations. It is optional for the update operation. ([‘present’])
The password must be set when using a password-based authentication method; empty strings are not allowed. This field is optional for the create operation. It will not be present in the result of the get or list operations. It is optional for the update operation. ([‘present’])
If this value is defined the SSL certificate will be verified by comparing it to the SSL thumbprint. The SSL certificate must verify against the thumbprint. When specified, the standard certificate chain validation behavior is not used. The certificate chain is validated normally if this value is unset. The specified sslThumbprint will not be checked for SSL certificate validation if {SubscriptionInfo#sslCertificate} is also set. This field is optional for the create operation. It will not be present in the result of the get or list operations. It is optional for the update operation. ([‘present’])
This URL can be the PublishInfo.publish-url of the published library (for example, https://server/path/lib.json). If the source content comes from a published library with PublishInfo.persist-json-enabled, the subscription URL can be a URL pointing to the library JSON file on a datastore or remote file system. The supported formats are: vSphere 6.5
vSphere 6.0
When you specify a DS subscription URL, the datastore must be on the same vCenter Server as the subscribed library. When you specify an NFS or SMB subscription URL, the StorageBacking.storage-uri of the subscribed library must be on the same remote file server and should share a common parent path with the subscription URL. This field must be provided for the create operation. It will always be present in the result of the get or list operations. It is optional for the update operation. ([‘present’])
The username must be set when using a password-based authentication method. Empty strings are allowed for usernames. This field is optional for the create operation. It is optional in the result of the get or list operations. It is optional for the update operation. ([‘present’])
This field is optional for the create operation. It is optional in the result of the get or list operations. It is optional for the update operation. ([‘present’])
This field must be provided for the create operation. It will always be present in the result of the get or list operations. It is optional for the update operation. When clients pass a value of this structure as a parameter, the field must be the id of a resource returned by vmware.vmware_rest.content_library_info.
This field must be provided for the create operation. It will always be present in the result of the get or list operations. It is optional for the update operation. When clients pass a value of this structure as a parameter, the field must be the id of a resource returned by vmware.vmware_rest.content_library_subscriptions_info. |
|
The list of subscriptions to publish this library to. Valid attributes are:
When clients pass a value of this structure as a parameter, the field must be the id of a resource returned by vmware.vmware_rest.content_library_subscriptions_info. ([‘publish’]) This key is required with [‘publish’]. |
|
The library_type enumerated type defines the type of a LibraryModel. The type of a library can be used to determine which additional services can be performed with a library. Choices:
|
|
This represents the intent of the change to LibraryModel.security-policy-id in update operation. If this field is set to true, any security policy applied to the library will be removed. If this field is set to false, any security policy applied to library will be changed to the value specified in LibraryModel.security-policy-id, if any. This field is optional for the update operation. If unset, any existing security policy will be changed to the value specified in LibraryModel.security-policy-id, if any. Choices:
|
|
The hostname or IP address of the vSphere vCenter If the value is not specified in the task, the value of environment variable |
|
The vSphere vCenter password If the value is not specified in the task, the value of environment variable |
|
You can use this optional parameter to set the location of a log file. This file will be used to record the HTTP REST interaction. The file will be stored on the host that runs the module. If the value is not specified in the task, the value of environment variable |
|
The vSphere vCenter username If the value is not specified in the task, the value of environment variable |
|
Allows connection when SSL certificates are not valid. Set to If the value is not specified in the task, the value of environment variable Choices:
|
|
A version number which is updated on metadata changes. This value allows clients to detect concurrent updates and prevent accidental clobbering of data. This value represents a number which is incremented every time library properties, such as name or description, are changed. It is not incremented by changes to a library item within the library, including adding or removing items. It is also not affected by tagging the library. This field is not used for the create operation. It will always be present in the result of a get or list operation. It is optional for the update operation. Leaving it unset during update indicates that you do not need to detect concurrent updates. |
Notes
Note
Tested on vSphere 7.0.3
Examples
- name: Create a content library pointing on a NFS share
vmware.vmware_rest.content_locallibrary:
name: my_library_on_nfs
description: automated
publish_info:
published: true
authentication_method: NONE
storage_backings:
- storage_uri: nfs://datastore.test/srv/share/content-library
type: OTHER
state: present
register: nfs_lib
- name: Create some more content libraries
vmware.vmware_rest.content_locallibrary:
name: my_library_on_nfs_{{ item }}
description: automated
publish_info:
published: true
authentication_method: NONE
storage_backings:
- storage_uri: nfs://datastore.test/srv/share/content-library
type: OTHER
state: present
with_sequence: 0-10
- name: Create a new local content library
vmware.vmware_rest.content_locallibrary:
name: local_library_001
description: automated
publish_info:
published: true
authentication_method: NONE
storage_backings:
- datastore_id: "{{ lookup('vmware.vmware_rest.datastore_moid', '/my_dc/datastore/rw_datastore') }}"
type: DATASTORE
state: present
register: ds_lib
- name: Create a content library based on a DataStore
vmware.vmware_rest.content_locallibrary:
name: my_library_on_datastore
description: automated
publish_info:
published: true
authentication_method: NONE
storage_backings:
- datastore_id: "{{ lookup('vmware.vmware_rest.datastore_moid', '/my_dc/datastore/local') }}"
type: DATASTORE
state: present
register: nfs_lib
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Delete all the local libraries Returned: On success Sample: |
|
Delete all the local libraries Returned: On success Sample: |