..
.. SPDX-License-Identifier: Apache-2.0
..

:github_url: https://github.com/IBM-Blockchain/ansible-collection/edit/main/plugins/modules/peer_channel.py


peer_channel -- Manage the list of channels joined by a Hyperledger Fabric peer
===============================================================================

.. contents::
   :local:
   :depth: 1


Synopsis
--------

Join a Hyperledger Fabric peer to a channel by using the IBM Blockchain Platform.

This module works with the IBM Blockchain Platform managed service running in IBM Cloud, or the IBM Blockchain Platform software running in a Red Hat OpenShift or Kubernetes cluster.






Parameters
----------

  api_endpoint (required)
    The URL for the IBM Blockchain Platform console.

    | **Type**: str

  api_authtype (required)
    ``ibmcloud`` - Authenticate to the IBM Blockchain Platform console using IBM Cloud authentication. You must provide a valid API key using *api_key*.

    ``basic`` - Authenticate to the IBM Blockchain Platform console using basic authentication. You must provide both a valid API key using *api_key* and API secret using *api_secret*.

    | **Type**: str

  api_key (required)
    The API key for the IBM Blockchain Platform console.

    | **Type**: str

  api_secret
    The API secret for the IBM Blockchain Platform console.

    Only required when *api_authtype* is ``basic``.

    | **Type**: str

  api_timeout
    The timeout, in seconds, to use when interacting with the IBM Blockchain Platform console.

    | **Type**: int
    | **Default value**: ``60``

  api_token_endpoint
    The IBM Cloud IAM token endpoint to use when using IBM Cloud authentication.

    Only required when *api_authtype* is ``ibmcloud``, and you are using IBM internal staging servers for testing.

    | **Type**: str
    | **Default value**: ``https://iam.cloud.ibm.com/identity/token``

  state
    ``absent`` - If the peer has joined the channel with the specified name, then an error will be thrown, as it is not possible for a peer to leave a channel.

    ``present`` - Asserts that the peer has joined the channel with the specified name. If the peer has not joined the channel with the specified name, then the peer will be joined to the channel using the specified configuration block.

    | **Type**: str
    | **Default value**: ``present``

  peer (required)
    The peer to join to the channel.

    You can pass a string, which is the display name of a peer registered with the IBM Blockchain Platform console.

    You can also pass a dict, which must match the result format of one of the :ref:`peer_info <peer_info_module>` or :ref:`peer <peer_module>` modules.

    | **Type**: raw

  identity (required)
    The identity to use when interacting with the peer.

    You can pass a string, which is the path to the JSON file where the enrolled identity is stored.

    You can also pass a dict, which must match the result format of one of the :ref:`enrolled_identity_info <enrolled_identity_info_module>` or :ref:`enrolled_identity <enrolled_identity_module>` modules.

    | **Type**: raw

  msp_id (required)
    The MSP ID to use for interacting with the peer.

    | **Type**: str

  hsm
    The PKCS #11 compliant HSM configuration to use for digital signatures.

    Only required if the identity specified in *identity* was enrolled using an HSM.

    | **Type**: dict

    pkcs11library
      The PKCS #11 library that should be used for digital signatures.

      | **Type**: str

    label
      The HSM label that should be used for digital signatures.

      | **Type**: str

    pin
      The HSM pin that should be used for digital signatures.

      | **Type**: str


  name
    The name of the channel.

    Only required when *state* is ``absent``.

    | **Type**: str

  path
    The path to the file where the channel genesis block is stored.

    Only required when *state* is ``present``.

    | **Type**: str








Examples
--------

.. code-block:: yaml+jinja

    
    - name: Join the peer to the channel
      ibm.blockchain_platform.peer_channel:
        state: present
        api_endpoint: https://ibp-console.example.org:32000
        api_authtype: basic
        api_key: xxxxxxxx
        api_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        peer: Org1 Peer
        identity: Org1 Admin.json
        msp_id: Org1MSP
        path: channel_genesis_block.bin

    - name: Ensure the peer is not joined to the channel
      ibm.blockchain_platform.peer_channel:
        state: absent
        api_endpoint: https://ibp-console.example.org:32000
        api_authtype: basic
        api_key: xxxxxxxx
        api_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        peer: Org1 Peer
        identity: Org1 Admin.json
        msp_id: Org1MSP
        name: channel1



