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

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


external_peer -- Manage an external Hyperledger Fabric peer
===========================================================

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


Synopsis
--------

Import or remove an external Hyperledger Fabric peer 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`` - A peer matching the specified name will be stopped and removed.

    ``present`` - Asserts that a peer matching the specified name and configuration exists. If no peer matches the specified name, a peer will be created. If a peer matches the specified name but the configuration does not match, then the peer will be updated, if it can be. If it cannot be updated, it will be removed and re-created with the specified configuration.

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

  name
    The name of the external peer.

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

    | **Type**: str

  peer
    The definition of the external peer

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

    | **Type**: dict

    name
      The name of the peer.

      | **Type**: str

    api_url
      The URL for the API of the peer.

      | **Type**: str

    operations_url
      The URL for the operations service of the peer.

      | **Type**: str

    grpcwp_url
      The URL for the gRPC web proxy of the peer.

      | **Type**: str

    msp_id
      The MSP ID of the peer.

      | **Type**: str

    pem
      The TLS certificate chain for the peer.

      The TLS certificate chain is returned as a base64 encoded PEM.

      | **Type**: str

    tls_ca_root_cert
      The TLS certificate chain for the peer.

      The TLS certificate chain is returned as a base64 encoded PEM.

      | **Type**: str

    tls_cert
      The TLS certificate for the peer.

      The TLS certificate is returned as a base64 encoded PEM.

      | **Type**: str

    location
      The location of the peer.

      | **Type**: str









Examples
--------

.. code-block:: yaml+jinja

    
    - name: Import the peer
      ibm.blockchain_platform.external_peer:
        status: present
        api_endpoint: https://ibp-console.example.org:32000
        api_authtype: basic
        api_key: xxxxxxxx
        api_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        peer: "{{ lookup('file', 'Org1 Peer.json') }}"

    - name: Remove the imported peer
      ibm.blockchain_platform.external_peer:
        state: absent
        api_endpoint: https://ibp-console.example.org:32000
        api_authtype: basic
        api_key: xxxxxxxx
        api_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        name: Org1 Peer



Return Values
-------------

  peer
    The peer.

    | **Returned**: when *state* is ``present``
    | **Type**: dict

    name
      The name of the peer.

      | **Type**: str
      | **Sample**: ``Org1 Peer``

    api_url
      The URL for the API of the peer.

      | **Type**: str
      | **Sample**: ``grpcs://org1peer-api.example.org:32000``

    operations_url
      The URL for the operations service of the peer.

      | **Type**: str
      | **Sample**: ``grpcs://org1peer-operations.example.org:32000``

    grpcwp_url
      The URL for the gRPC web proxy of the peer.

      | **Type**: str
      | **Sample**: ``grpcs://org1peer-grpcwebproxy.example.org:32000``

    msp_id
      The MSP ID of the peer.

      | **Type**: str
      | **Sample**: ``Org1MSP``

    pem
      The TLS certificate chain for the peer.

      The TLS certificate chain is returned as a base64 encoded PEM.

      | **Type**: str
      | **Sample**: ``LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0t...``

    tls_ca_root_cert
      The TLS certificate chain for the peer.

      The TLS certificate chain is returned as a base64 encoded PEM.

      | **Type**: str
      | **Sample**: ``LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0t...``

    tls_cert
      The TLS certificate for the peer.

      The TLS certificate is returned as a base64 encoded PEM.

      | **Type**: str
      | **Sample**: ``LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0t...``

    location
      The location of the peer.

      | **Type**: str
      | **Sample**: ``ibmcloud``



