community.general.pubnub_blocks module – PubNub blocks management module
Note
This module is part of the community.general collection (version 8.6.4).
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 community.general
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.general.pubnub_blocks
.
Synopsis
This module allows Ansible to interface with the PubNub BLOCKS infrastructure by providing the following operations: create / remove, start / stop and rename for blocks and create / modify / remove for event handlers.
Aliases: cloud.pubnub.pubnub_blocks
Requirements
The below requirements are needed on the host that executes this module.
pubnub_blocks_client >= 1.0
Parameters
Parameter |
Comments |
---|---|
Name of PubNub account for from which User’s account will be used if value not set or empty. Default: |
|
Name of target PubNub application for which blocks configuration on specific |
|
In case if single play use blocks management module few times it is preferred to enabled ‘caching’ by making previous module to share gathered artifacts and pass them to this parameter. Default: |
|
List of fields which should be changed by block itself (doesn’t affect any event handlers). Possible options for change is: Default: |
|
Short block description which will be later visible on admin.pubnub.com. Used only if block doesn’t exists and won’t change description for existing block. |
|
Email from account for which new session should be started. Not required if Default: |
|
List of event handlers which should be updated for specified block Each entry for new event handler should contain:
Each entry for existing handlers should contain It is possible to rename event handler by adding To remove particular event handler it is possible to set Default: |
|
Name of application’s keys set which is bound to managed blocks. |
|
Name of managed block which will be later visible on admin.pubnub.com. |
|
Intended block state after event handlers creation / update process will be completed. Choices:
|
|
This key allow to try skip certificates check when performing REST API calls. Sometimes host may have issues with certificates on it and this will cause problems to call PubNub REST API. If check should be ignored Choices:
|
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full |
Can run in |
|
Support: none |
Will return details on what has changed (or possibly needs changing in |
Examples
# Event handler create example.
- name: Create single event handler
community.general.pubnub_blocks:
email: '{{ email }}'
password: '{{ password }}'
application: '{{ app_name }}'
keyset: '{{ keyset_name }}'
name: '{{ block_name }}'
event_handlers:
-
src: '{{ path_to_handler_source }}'
name: '{{ handler_name }}'
event: 'js-before-publish'
channels: '{{ handler_channel }}'
# Change event handler trigger event type.
- name: Change event handler 'event'
community.general.pubnub_blocks:
email: '{{ email }}'
password: '{{ password }}'
application: '{{ app_name }}'
keyset: '{{ keyset_name }}'
name: '{{ block_name }}'
event_handlers:
-
name: '{{ handler_name }}'
event: 'js-after-publish'
# Stop block and event handlers.
- name: Stopping block
community.general.pubnub_blocks:
email: '{{ email }}'
password: '{{ password }}'
application: '{{ app_name }}'
keyset: '{{ keyset_name }}'
name: '{{ block_name }}'
state: stop
# Multiple module calls with cached result passing
- name: Create '{{ block_name }}' block
register: module_cache
community.general.pubnub_blocks:
email: '{{ email }}'
password: '{{ password }}'
application: '{{ app_name }}'
keyset: '{{ keyset_name }}'
name: '{{ block_name }}'
state: present
- name: Add '{{ event_handler_1_name }}' handler to '{{ block_name }}'
register: module_cache
community.general.pubnub_blocks:
cache: '{{ module_cache }}'
application: '{{ app_name }}'
keyset: '{{ keyset_name }}'
name: '{{ block_name }}'
state: present
event_handlers:
-
src: '{{ path_to_handler_1_source }}'
name: '{{ event_handler_1_name }}'
channels: '{{ event_handler_1_channel }}'
event: 'js-before-publish'
- name: Add '{{ event_handler_2_name }}' handler to '{{ block_name }}'
register: module_cache
community.general.pubnub_blocks:
cache: '{{ module_cache }}'
application: '{{ app_name }}'
keyset: '{{ keyset_name }}'
name: '{{ block_name }}'
state: present
event_handlers:
-
src: '{{ path_to_handler_2_source }}'
name: '{{ event_handler_2_name }}'
channels: '{{ event_handler_2_channel }}'
event: 'js-before-publish'
- name: Start '{{ block_name }}' block
register: module_cache
community.general.pubnub_blocks:
cache: '{{ module_cache }}'
application: '{{ app_name }}'
keyset: '{{ keyset_name }}'
name: '{{ block_name }}'
state: started
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Cached account information. In case if with single play module used few times it is better to pass cached data to next module calls to speed up process. Returned: always |