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
.
To use it in a playbook, specify: vmware.vmware_rest.content_subscribedlibrary
.
New in version 2.0.0: of vmware.vmware_rest
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. |
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: “All items completed” |
|
Delete all the subscribed libraries Returned: On success Sample: [{“_ansible_item_label”: {“creation_time”: “2022-06-23T22:38:29.995Z”, “description”: “”, “id”: “41bd5c47-e658-4876-bab2-03758f25a3e9”, “last_modified_time”: “2022-06-23T22:38:29.995Z”, “last_sync_time”: “2022-06-23T22:38:32.305Z”, “name”: “sub_lib”, “server_guid”: “b138c531-cd80-43f5-842d-657d9ddc98f8”, “storage_backings”: [{“datastore_id”: “datastore-1200”, “type”: “DATASTORE”}], “subscription_info”: {“authentication_method”: “NONE”, “automatic_sync_enabled”: 0, “on_demand”: 1, “subscription_url”: “https://vcenter.test:443/cls/vcsp/lib/c9b8f7da-d5ac-4076-86b9-39ee107d7da3/lib.json”}, “type”: “SUBSCRIBED”, “version”: “4”}, “_ansible_no_log”: null, “ansible_loop_var”: “item”, “changed”: 1, “failed”: 0, “invocation”: {“module_args”: {“client_token”: null, “creation_time”: null, “description”: null, “id”: null, “last_modified_time”: null, “last_sync_time”: null, “library_id”: “41bd5c47-e658-4876-bab2-03758f25a3e9”, “name”: null, “optimization_info”: null, “publish_info”: null, “server_guid”: null, “session_timeout”: null, “state”: “absent”, “storage_backings”: null, “subscription_info”: null, “type”: null, “vcenter_hostname”: “vcenter.test”, “vcenter_password”: “VALUE_SPECIFIED_IN_NO_LOG_PARAMETER”, “vcenter_rest_log_file”: null, “vcenter_username”: “administrator@vsphere.local”, “vcenter_validate_certs”: 0, “version”: null}}, “item”: {“creation_time”: “2022-06-23T22:38:29.995Z”, “description”: “”, “id”: “41bd5c47-e658-4876-bab2-03758f25a3e9”, “last_modified_time”: “2022-06-23T22:38:29.995Z”, “last_sync_time”: “2022-06-23T22:38:32.305Z”, “name”: “sub_lib”, “server_guid”: “b138c531-cd80-43f5-842d-657d9ddc98f8”, “storage_backings”: [{“datastore_id”: “datastore-1200”, “type”: “DATASTORE”}], “subscription_info”: {“authentication_method”: “NONE”, “automatic_sync_enabled”: 0, “on_demand”: 1, “subscription_url”: “https://vcenter.test:443/cls/vcsp/lib/c9b8f7da-d5ac-4076-86b9-39ee107d7da3/lib.json”}, “type”: “SUBSCRIBED”, “version”: “4”}, “value”: {}}] |
Authors
Ansible Cloud Team (@ansible-collections)