hyperledger.fabric_ansible_collection.installed_chaincode (2.0.7) — module

Manage a chaincode installed on a Hyperledger Fabric peer

Authors: Simon Stone (@sstone1)

preview | supported by community

Install collection

Install with ansible-galaxy collection install hyperledger.fabric_ansible_collection:==2.0.7


Add to requirements.yml

  collections:
    - name: hyperledger.fabric_ansible_collection
      version: 2.0.7

Description

Install a chaincode on a Hyperledger Fabric peer.

This module works with the IBM Support for Hyperledger Fabric software or the Hyperledger Fabric Open Source Stack running in a Red Hat OpenShift or Kubernetes cluster.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install the chaincode on the peer using Hyperledger Fabric v1.4 lifecycle
  hyperledger.fabric_ansible_collection.installed_chaincode:
    state: present
    api_endpoint: https://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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install the chaincode on the peer using Hyperledger Fabric v2.x lifecycle
  hyperledger.fabric_ansible_collection.installed_chaincode:
    state: present
    api_endpoint: https://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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Ensure the chaincode is not installed on the peer using Hyperledger Fabric v1.4 lifecycle
  hyperledger.fabric_ansible_collection.installed_chaincode:
    state: absent
    api_endpoint: https://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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Ensure the chaincode is not installed on the peer using Hyperledger Fabric v2.x lifecycle
  hyperledger.fabric_ansible_collection.installed_chaincode:
    state: absent
    api_endpoint: https://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

Inputs

    
hsm:
    description:
    - 'The PKCS #11 compliant HSM configuration to use for digital signatures.'
    - Only required if the identity specified in I(identity) was enrolled using an HSM.
    suboptions:
      label:
        description:
        - The HSM label that should be used for digital signatures.
        type: str
      pin:
        description:
        - The HSM pin that should be used for digital signatures.
        type: str
      pkcs11library:
        description:
        - 'The PKCS #11 library that should be used for digital signatures.'
        type: str
    type: dict

name:
    description:
    - The name of the chaincode.
    - Only required when I(state) is C(absent) and when using the chaincode lifecycle
      in Hyperledger Fabric v1.4.
    type: str

path:
    description:
    - 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 C(peer chaincode package) command 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 C(peer lifecycle chaincode package) command
      or a Hyperledger Fabric SDK.
    - Only required when I(state) is C(present).
    type: str

peer:
    description:
    - 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 Fabric
      operations console.
    - You can also pass a dict, which must match the result format of one of the M(peer_info)
      or M(peer) modules.
    required: true
    type: raw

state:
    choices:
    - absent
    - present
    default: present
    description:
    - C(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.
    - C(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

msp_id:
    description:
    - The MSP ID to use for interacting with the peer.
    required: true
    type: str

api_key:
    description:
    - The API key for the Fabric operations console.
    required: true
    type: str

version:
    description:
    - The version of the chaincode.
    - Only required when I(state) is C(absent) and when using the chaincode lifecycle
      in Hyperledger Fabric v1.4.
    type: str

identity:
    description:
    - 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 M(enrolled_identity_info)
      or M(enrolled_identity) modules.
    required: true
    type: raw

api_secret:
    description:
    - The API secret for the Fabric operations console.
    - Only required when I(api_authtype) is C(basic).
    type: str

package_id:
    description:
    - The package ID of the chaincode.
    - Only required when I(state) is C(absent) and when using the chaincode lifecycle
      in Hyperledger Fabric v2.x.
    type: str

api_timeout:
    default: 60
    description:
    - The timeout, in seconds, to use when interacting with the Fabric operations console.
    type: int

api_authtype:
    description:
    - C(basic) - Authenticate to the Fabric operations console using basic authentication.
      You must provide both a valid API key using I(api_key) and API secret using I(api_secret).
    required: true
    type: str

api_endpoint:
    description:
    - The URL for the Fabric operations console.
    required: true
    type: str

Outputs

installed_chaincode:
  contains:
    id:
      description:
      - The ID of the chaincode.
      returned: when using the chaincode lifecycle in Hyperledger Fabric v1.4
      sample: 5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03
      type: str
    label:
      description:
      - The label of the chaincode.
      returned: when using the chaincode lifecycle in Hyperledger Fabric v2.x
      sample: fabcar-1.0.0
      type: str
    name:
      description:
      - The name of the chaincode.
      returned: when using the chaincode lifecycle in Hyperledger Fabric v1.4
      sample: fabcar
      type: str
    package_id:
      description:
      - The package ID of the chaincode.
      returned: when using the chaincode lifecycle in Hyperledger Fabric v2.x
      sample: fabcar-1.0.0:5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03
      type: str
    version:
      description:
      - The version of the chaincode.
      returned: when using the chaincode lifecycle in Hyperledger Fabric v1.4
      sample: 1.0.0
      type: str
  description:
  - The installed chaincode.
  returned: when I(state) is C(present)
  type: dict