vmware.vmware_rest.content_subscribedlibrary module – Creates a new subscribed library
Note
This module is part of the vmware.vmware_rest collection (version 2.2.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_subscribedlibrary
.
New in vmware.vmware_rest 2.0.0
Synopsis
Creates a new subscribed library. <p> Once created, the subscribed library will be empty. If the {@link LibraryModel#subscriptionInfo} property is set, the Content Library Service will attempt to synchronize to the remote source. This is an asynchronous operation so the content of the published library may not immediately appear.
Requirements
The below requirements are needed on the host that executes this module.
vSphere 7.0.2 or greater
python >= 3.6
aiohttp
Parameters
Parameter |
Comments |
---|---|
Unique token generated on the client for each creation request. The token should be a universally unique identifier (UUID), for example: |
|
The date and time when this library was created. |
|
A human-readable description for this library. |
|
An identifier which uniquely identifies this |
|
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. |
|
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 not set for a local library. |
|
Identifier of the subscribed library whose content should be evicted. Required with state=[‘absent’, ‘evict’, ‘present’, ‘sync’] |
|
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. |
|
Defines various optimizations and optimization parameters applied to this library. Valid attributes are:
|
|
Defines how this library is published so that it can be subscribed to by a remote subscribed library. The Valid attributes are:
|
|
The unique identifier of the vCenter server where the library exists. |
|
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 storage backing 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. Valid attributes are:
|
|
Defines the subscription behavior for this Library. The Valid attributes are:
|
|
The 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 run 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. |
Notes
Note
Tested on vSphere 7.0.2
Examples
- name: Build a list of subscribed libraries
vmware.vmware_rest.content_subscribedlibrary_info:
register: result
- name: Delete all the subscribed libraries
vmware.vmware_rest.content_subscribedlibrary:
library_id: '{{ item.id }}'
state: absent
with_items: '{{ result.value }}'
- 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 subscribed library
vmware.vmware_rest.content_subscribedlibrary:
name: sub_lib
subscription_info:
subscription_url: '{{ nfs_lib.value.publish_info.publish_url }}'
authentication_method: NONE
automatic_sync_enabled: false
on_demand: true
storage_backings:
- datastore_id: "{{ lookup('vmware.vmware_rest.datastore_moid', '/my_dc/datastore/rw_datastore')\
\ }}"
type: DATASTORE
register: sub_lib
- name: Create subscribed library (again)
vmware.vmware_rest.content_subscribedlibrary:
name: sub_lib
subscription_info:
subscription_url: '{{ nfs_lib.value.publish_info.publish_url }}'
authentication_method: NONE
automatic_sync_enabled: false
on_demand: true
storage_backings:
- datastore_id: "{{ lookup('vmware.vmware_rest.datastore_moid', '/my_dc/datastore/rw_datastore')\
\ }}"
type: DATASTORE
register: result
- name: Clean up the cache
vmware.vmware_rest.content_subscribedlibrary:
name: sub_lib
library_id: '{{ sub_lib.id }}'
state: evict
- name: Trigger a library sync
vmware.vmware_rest.content_subscribedlibrary:
name: sub_lib
library_id: '{{ sub_lib.id }}'
state: sync
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Delete all the subscribed libraries Returned: On success Sample: |
|
Delete all the subscribed libraries Returned: On success Sample: |