installed_chaincode – Manage a chaincode installed on a Hyperledger Fabric peer

Synopsis

Install a chaincode on a 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 - If a chaincode matching the specified name and version is installed, then an error will be thrown, as it is not possible to uninstall chaincode.

present - Asserts that a chaincode matching the specified name and version is installed. If it is not installed, then the chaincode is installed using the chaincode package at the specified path. If it is installed, then the chaincode is checked to make sure that the installed chaincode matches the chaincode in the chaincode package at the specified path. If the installed chaincode does not match, then an error will be thrown, as it is not possible to update installed chaincode.

Type: str
Default value: present
peer (required)

The peer to use to manage the installed chaincode.

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 ERROR while parsing: While parsing “M(peer_info)” at index 76: Module name “peer_info” is not a FQCN or ERROR while parsing: While parsing “M(peer)” at index 92: Module name “peer” is not a FQCN 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 ERROR while parsing: While parsing “M(enrolled_identity_info)” at index 76: Module name “enrolled_identity_info” is not a FQCN or ERROR while parsing: While parsing “M(enrolled_identity)” at index 105: Module name “enrolled_identity” is not a FQCN 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 chaincode.

Only required when state is absent and when using the chaincode lifecycle in Hyperledger Fabric v1.4.

Type: str
version

The version of the chaincode.

Only required when state is absent and when using the chaincode lifecycle in Hyperledger Fabric v1.4.

Type: str
package_id

The package ID of the chaincode.

Only required when state is absent and when using the chaincode lifecycle in Hyperledger Fabric v2.x.

Type: str
path

The path to the chaincode package.

When using the chaincode lifecycle in Hyperledger Fabric v1.4, the chaincode package must be a CDS file created using the peer chaincode package command, the IBM Blockchain Platform extension for Visual Studio Code, or a Hyperledger Fabric SDK.

When using the chaincode lifecycle in Hyperledger Fabric v2.x, the chaincode package must be a tar file created using the peer lifecycle chaincode package command, the IBM Blockchain Platform extension for Visual Studio Code, or a Hyperledger Fabric SDK.

Only required when state is present.

Type: str

Examples

- name: Install the chaincode on the peer using Hyperledger Fabric v1.4 lifecycle
  ibm.blockchain_platform.installed_chaincode:
    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: fabcar@1.0.0.cds

- name: Install the chaincode on the peer using Hyperledger Fabric v2.x lifecycle
  ibm.blockchain_platform.installed_chaincode:
    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: fabcar@1.0.0.tgz

- name: Ensure the chaincode is not installed on the peer using Hyperledger Fabric v1.4 lifecycle
  ibm.blockchain_platform.installed_chaincode:
    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: fabcar
    version: 1.0.0

- name: Ensure the chaincode is not installed on the peer using Hyperledger Fabric v2.x lifecycle
  ibm.blockchain_platform.installed_chaincode:
    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
    package_id: fabcar:8eaffdff050ff04779879aa524a51b308da9327b4a5bb1e0477db5a96598455b

Return Values

installed_chaincode

The installed chaincode.

Returned: when state is present
Type: dict
name

The name of the chaincode.

Returned: when using the chaincode lifecycle in Hyperledger Fabric v1.4
Type: str
Sample: fabcar
version

The version of the chaincode.

Returned: when using the chaincode lifecycle in Hyperledger Fabric v1.4
Type: str
Sample: 1.0.0
id

The ID of the chaincode.

Returned: when using the chaincode lifecycle in Hyperledger Fabric v1.4
Type: str
Sample: 5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03
label

The label of the chaincode.

Returned: when using the chaincode lifecycle in Hyperledger Fabric v2.x
Type: str
Sample: fabcar-1.0.0
package_id

The package ID of the chaincode.

Returned: when using the chaincode lifecycle in Hyperledger Fabric v2.x
Type: str
Sample: fabcar-1.0.0:5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03