diff --git a/src/agent/ansible/roles/deploy_compose/fabricbuild/tasks/apply.yml b/src/agent/ansible/roles/deploy_compose/fabricbuild/tasks/apply.yml index fb4eedc7..9a1595cb 100755 --- a/src/agent/ansible/roles/deploy_compose/fabricbuild/tasks/apply.yml +++ b/src/agent/ansible/roles/deploy_compose/fabricbuild/tasks/apply.yml @@ -27,59 +27,52 @@ - "absent" - "directory" -- name: Extract hyperledger fabric code - git: - repo: "{{ GIT_URL | default('http://gerrit.hyperledger.org/r/fabric') }}" - dest: "{{ fabricpath }}" - force: yes - refspec: "{{ GERRIT_REFSPEC | default('') }}" - version: "{{ (GERRIT_REFSPEC == '') | ternary('HEAD','FETCH_HEAD') }}" - depth: 1 - tags: "code" +- name: Download fabric docker images + include_tasks: "download.yml" + when: fabric.baseimage_tag|length > 0 + tag: "downloadartifacts" -- name: Make targets - shell: "make {{ item }} >> {{ gopath }}/build.log" - args: - chdir: "{{ fabricpath }}" - with_items: "{{ target.split(',') }}" - environment: - GOROOT: "{{ goroot }}" - GOPATH: "{{ gopath }}" - PATH: "{{ ansible_env.PATH}}:{{ goroot }}/bin" - tags: "make" +- name: build fabric artifacts + include_tasks: "build.yml" + when: fabric.baseimage_tag|length == 0 + tags: "buildartifacts" -- name: Figure out the build tag - shell: "git rev-parse --short HEAD" - args: - chdir: "{{ fabricpath }}" - register: rawtag +- name: Setup hyperledger directory + file: + path: "{{ fabricpath }}/build" + state: directory + force: yes + mode: 0775 -- name: Get base version - shell: grep '^BASE_VERSION' Makefile | cut -d '=' -f 2 | xargs - args: - chdir: "{{ fabricpath }}" - register: baseversion +- stat: + path: "{{ fabricpath }}/build/bin/cryptogen" + register: binexists -- name: Check if it is a release - shell: grep '^IS_RELEASE' Makefile | cut -d '=' -f 2 | xargs - args: - chdir: "{{ fabricpath }}" - register: isrelease +- name: Download fabric binaries + unarchive: + src: "{{ fabric.repo.bin }}" + dest: "{{ fabricpath }}/build" + remote_src: yes + when: fabric.repo.bin|length > 0 and binexists.stat.exists == false + tags: "downloadbin" -- name: Get the project version - set_fact: - project_version: >- - {{ (isrelease.stdout|lower == 'true') | ternary(baseversion.stdout, - baseversion.stdout+'-snapshot-'+rawtag.stdout) | trim }} +- name: Validate the version, baseimage_tag and helper_tag to be deployed + fail: + msg: >- + the project version is empty, most likely configuration is not correct. + Please check baseimage_tag and helper_tag are set correct or you set + up to build fabric binaries and docker images! + when: > + project_version|length == 0 or baseimage_tag|length == 0 or + helper_tag|length == 0 -- name: Get all images for this build +- name: Get all images for this deployment shell: >- - docker images --format {% raw %}'{{.Repository}}:{{.Tag }}' {% endraw %} | - grep {{ project_version }} + docker images --format {% raw %}'{{.Repository}}:{{.Tag }}' {% endraw %} + | grep 'hyperledger/fabric-' || : args: chdir: "{{ fabricpath }}" register: rawimages - when: fabric.baseimage_tag == '' - name: Save all the docker images shell: >- @@ -87,7 +80,8 @@ {{ rawimages.stdout_lines | join(' ') }} args: chdir: "{{ gopath }}" - when: fabric.baseimage_tag == '' and rawimages is defined and rawimages.stdout_lines|length > 0 + when: rawimages.stdout_lines|length > 0 and fabric.baseimage_tag == '' + tags: "saveimages" - name: Create the project version file template: diff --git a/src/agent/ansible/roles/deploy_compose/fabricbuild/tasks/build.yml b/src/agent/ansible/roles/deploy_compose/fabricbuild/tasks/build.yml new file mode 100755 index 00000000..d79c4400 --- /dev/null +++ b/src/agent/ansible/roles/deploy_compose/fabricbuild/tasks/build.yml @@ -0,0 +1,67 @@ +--- +- name: Figuring out the server architecture + shell: uname -m + register: rawarch + +- name: Setup hyperledger directory + file: + path: "{{ fabricpath }}/build" + state: absent + force: yes + mode: 0775 + +- name: Extract hyperledger fabric code + git: + repo: "{{ GIT_URL | default('http://gerrit.hyperledger.org/r/fabric') }}" + dest: "{{ fabricpath }}" + force: yes + refspec: "{{ GERRIT_REFSPEC | default('') }}" + version: "{{ (GERRIT_REFSPEC == '') | ternary('HEAD','FETCH_HEAD') }}" + depth: 1 + tags: "extractcode" + +- name: Figure out the build tag + shell: "git rev-parse --short HEAD" + args: + chdir: "{{ fabricpath }}" + register: rawtag + +- name: Add docker targets if absent + set_fact: + target: "{{ target }},docker" + when: fabric.baseimage_tag|length == 0 and 'docker' not in target + +- name: Make targets + shell: "make {{ item }} >> {{ gopath }}/build.log" + args: + chdir: "{{ fabricpath }}" + with_items: "{{ target.split(',') }}" + environment: + GOROOT: "{{ goroot }}" + GOPATH: "{{ gopath }}" + PATH: "{{ ansible_env.PATH}}:{{ goroot }}/bin" + when: target | length > 0 + tags: "makeimages" + +- name: Get base version + shell: grep '^BASE_VERSION' Makefile | cut -d '=' -f 2 | xargs + args: + chdir: "{{ fabricpath }}" + register: baseversion + +- name: Check if it is a release + shell: grep '^IS_RELEASE' Makefile | cut -d '=' -f 2 | xargs + args: + chdir: "{{ fabricpath }}" + register: isrelease + +- name: Get the project version + set_fact: + project_version: >- + {{ (isrelease.stdout|lower == 'true') | ternary(baseversion.stdout, + baseversion.stdout+'-snapshot-'+rawtag.stdout) | trim }} + +- name: Set project version and container tags + set_fact: + baseimage_tag: "{{ rawarch.stdout }}-{{ project_version }}" + helper_tag: "{{ fabric.helper_tag }}" diff --git a/src/agent/ansible/roles/deploy_compose/fabricbuild/tasks/destroy.yml b/src/agent/ansible/roles/deploy_compose/fabricbuild/tasks/destroy.yml index 6f505a8c..f042f307 100755 --- a/src/agent/ansible/roles/deploy_compose/fabricbuild/tasks/destroy.yml +++ b/src/agent/ansible/roles/deploy_compose/fabricbuild/tasks/destroy.yml @@ -20,4 +20,5 @@ GOROOT: "{{ goroot }}" GOPATH: "{{ gopath }}" PATH: "{{ ansible_env.PATH}}:{{ goroot }}/bin" + when: fabric.baseimage_tag|length == 0 tags: "clean" diff --git a/src/agent/ansible/roles/deploy_compose/fabricbuild/tasks/download.yml b/src/agent/ansible/roles/deploy_compose/fabricbuild/tasks/download.yml new file mode 100755 index 00000000..75478b79 --- /dev/null +++ b/src/agent/ansible/roles/deploy_compose/fabricbuild/tasks/download.yml @@ -0,0 +1,14 @@ +--- +- name: Try to get the project version from the baseimage_tag + set_fact: + project_version: >- + {{ fabric.baseimage_tag | + regex_replace('.*([0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}).*', '\1') }} + baseimage_tag: "{{ fabric.baseimage_tag }}" + helper_tag: "{{ fabric.helper_tag | default(fabric.baseimage_tag) }}" + +- name: Set the version to 1.1.0 if the tag is a commit hashcode + set_fact: + project_version: >- + {{ fabric.baseimage_tag | match(project_version) | + ternary('1.1.0', project_version) }} diff --git a/src/agent/ansible/roles/deploy_compose/fabricbuild/templates/VERSION.j2 b/src/agent/ansible/roles/deploy_compose/fabricbuild/templates/VERSION.j2 index 5f311cd6..d4478f69 100755 --- a/src/agent/ansible/roles/deploy_compose/fabricbuild/templates/VERSION.j2 +++ b/src/agent/ansible/roles/deploy_compose/fabricbuild/templates/VERSION.j2 @@ -1 +1 @@ -{{ project_version }} \ No newline at end of file +{{ baseimage_tag }} \ No newline at end of file diff --git a/src/agent/ansible/roles/deploy_compose/fabricsetup/tasks/apply.yml b/src/agent/ansible/roles/deploy_compose/fabricsetup/tasks/apply.yml index f4a04cfc..7172d4ff 100755 --- a/src/agent/ansible/roles/deploy_compose/fabricsetup/tasks/apply.yml +++ b/src/agent/ansible/roles/deploy_compose/fabricsetup/tasks/apply.yml @@ -1,14 +1,9 @@ --- -- name: Figuring out the server architecture - shell: uname -m - register: rawarch - - name: Setup and initialize variables set_fact: current_host: "{{ hostvars[inventory_hostname].inter_name }}" fabricworkdir: "/opt/gopath/{{ env }}/fabric" gopath: "/opt/gopath/{{ env }}" - arch: "{{ rawarch.stdout}}" peers: "{{ [] }}" orderers: "{{ [] }}" cas: "{{ [] }}" @@ -29,8 +24,6 @@ allpeers: "{{ [] }}" clihost: "" filterstr: "" - thetag: "{{ rawarch.stdout + '-' + fabric.baseimage_tag }}" - helpertag: "{{ rawarch.stdout + '-' + fabric.helper_tag }}" - name: Make sure that working directory is clean become: true @@ -143,23 +136,25 @@ scp -i "/opt/gopath/id_rsa" -r -o "StrictHostKeyChecking no" "{{ fabric. ssh_user }}@{{ hostvars[groups['builders'][0]].private_ip }}:{{ fabricworkdir }}/images/VERSION" "{{ fabricworkdir }}/VERSION" - when: fabric.baseimage_tag == '' - -- name: Load all the docker images created by build machine - shell: >- - docker load -i {{ fabricworkdir }}/fabricimages.tar - when: fabric.baseimage_tag == '' and inventory_hostname not in groups['builders'] - name: Find out the image tags slurp: src: "{{ fabricworkdir }}/VERSION" - register: project_version - when: fabric.baseimage_tag == '' + register: imagetag -- name: Set the container tag +- name: Set image tag from the file set_fact: - thetag: "{{ arch + '-' + (project_version['content'] | b64decode) }}" - when: fabric.baseimage_tag == '' + thetag: "{{ imagetag['content'] | b64decode }}" + helpertag: "{{ fabric.helper_tag }}" + +- stat: + path: "{{ fabricworkdir }}/fabricimages.tar" + register: imagepack + +- name: Load all the docker images created by build machine + shell: >- + docker load -i {{ fabricworkdir }}/fabricimages.tar + when: imagepack.stat.exists == true and inventory_hostname not in groups['builders'] - name: Unpack the certificates unarchive: @@ -199,17 +194,19 @@ set_fact: orgmembers: "{{ peers | map(attribute='org') | list | unique | sort | join(\".member' '\") | trim | replace(' ', ',') }}" -- name: Pull container images from the docker hub - command: "docker pull {{ item }}" - when: fabric.baseimage_tag | length > 0 +- name: Pull necessary container images from the docker hub + command: "docker pull {{ fabric.repo.url }}{{ item.name }}" + when: item.flag | length > 0 and fabric.baseimage_tag | length > 0 with_items: - - "hyperledger/fabric-tools:{{ thetag }}" - - "hyperledger/fabric-ccenv:{{ thetag }}" - - "hyperledger/fabric-kafka:{{ thetag }}" - - "hyperledger/fabric-zookeeper:{{ thetag }}" - - "hyperledger/fabric-peer:{{ thetag }}" - - "hyperledger/fabric-orderer:{{ thetag }}" - - "hyperledger/fabric-couchdb:{{ thetag }}" + - { name: "fabric-ca:{{ helpertag }}", flag: "{{ cas }}" } + - { name: "fabric-zookeeper:{{ helpertag }}", flag: "{{ zookeepers }}" } + - { name: "fabric-kafka:{{ helpertag }}", flag: "{{ kafkas }}" } + - { name: "fabric-couchdb:{{ helpertag }}", flag: "{{ peers }}" } + - { name: "fabric-orderer:{{ thetag }}", flag: "{{ orderers }}" } + - { name: "fabric-peer:{{ thetag }}", flag: "{{ peers }}" } + - { name: "fabric-ccenv:{{ thetag }}", flag: "{{ peers }}" } + - { name: "fabric-tools:{{ thetag }}", flag: "tools" } + tags: "pullimages" - name: Create docker compose files template: diff --git a/src/agent/ansible/roles/deploy_compose/fabricsetup/templates/ca-compose.j2 b/src/agent/ansible/roles/deploy_compose/fabricsetup/templates/ca-compose.j2 index e31a0da0..2517e6e7 100755 --- a/src/agent/ansible/roles/deploy_compose/fabricsetup/templates/ca-compose.j2 +++ b/src/agent/ansible/roles/deploy_compose/fabricsetup/templates/ca-compose.j2 @@ -6,7 +6,7 @@ services: {% for ca in cas %} {{ ca.name }}: container_name: {{ ca.name}} - image: hyperledger/fabric-ca:{{ (fabric.helper_tag == "") | ternary(thetag, helpertag) }} + image: {{ fabric.repo.url }}fabric-ca:{{ helpertag | default(thetag) }} network_mode: bridge hostname: {{ ca.name}} environment: diff --git a/src/agent/ansible/roles/deploy_compose/fabricsetup/templates/cli-compose.j2 b/src/agent/ansible/roles/deploy_compose/fabricsetup/templates/cli-compose.j2 index c9c498ed..c59069b7 100755 --- a/src/agent/ansible/roles/deploy_compose/fabricsetup/templates/cli-compose.j2 +++ b/src/agent/ansible/roles/deploy_compose/fabricsetup/templates/cli-compose.j2 @@ -5,7 +5,7 @@ services: fabriccli: container_name: fabriccli - image: hyperledger/fabric-tools:{{ thetag }} + image: {{ fabric.repo.url }}fabric-tools:{{ thetag }} network_mode: bridge hostname: fabriccli environment: diff --git a/src/agent/ansible/roles/deploy_compose/fabricsetup/templates/kafka-compose.j2 b/src/agent/ansible/roles/deploy_compose/fabricsetup/templates/kafka-compose.j2 index c9b3d79b..43fd22b7 100755 --- a/src/agent/ansible/roles/deploy_compose/fabricsetup/templates/kafka-compose.j2 +++ b/src/agent/ansible/roles/deploy_compose/fabricsetup/templates/kafka-compose.j2 @@ -6,7 +6,7 @@ services: {% for kafka in kafkas %} {{ kafka }}: container_name: {{ kafka }} - image: hyperledger/fabric-kafka:{{ (fabric.helper_tag == "") | ternary(thetag, helpertag) }} + image: {{ fabric.repo.url }}fabric-kafka:{{ helpertag | default(thetag) }} restart: always network_mode: bridge hostname: {{ kafka }} diff --git a/src/agent/ansible/roles/deploy_compose/fabricsetup/templates/orderer-compose.j2 b/src/agent/ansible/roles/deploy_compose/fabricsetup/templates/orderer-compose.j2 index 447aea4f..c2ca94f9 100755 --- a/src/agent/ansible/roles/deploy_compose/fabricsetup/templates/orderer-compose.j2 +++ b/src/agent/ansible/roles/deploy_compose/fabricsetup/templates/orderer-compose.j2 @@ -6,7 +6,7 @@ services: {% for orderer in orderers %} {{ orderer.name }}: container_name: {{ orderer.name }} - image: hyperledger/fabric-orderer:{{ thetag }} + image: {{ fabric.repo.url }}fabric-orderer:{{ thetag }} network_mode: bridge hostname: {{ orderer.name }} environment: diff --git a/src/agent/ansible/roles/deploy_compose/fabricsetup/templates/peer-compose.j2 b/src/agent/ansible/roles/deploy_compose/fabricsetup/templates/peer-compose.j2 index 7ae80ea9..e73092a5 100755 --- a/src/agent/ansible/roles/deploy_compose/fabricsetup/templates/peer-compose.j2 +++ b/src/agent/ansible/roles/deploy_compose/fabricsetup/templates/peer-compose.j2 @@ -7,14 +7,14 @@ services: {% if fabric.peer_db == 'CouchDB' %} couchdb-{{ peer.name }}: container_name: couchdb-{{ peer.name }} - image: hyperledger/fabric-couchdb:{{ (fabric.helper_tag == "") | ternary(thetag, helpertag) }} + image: {{ fabric.repo.url }}fabric-couchdb:{{ helpertag | default(thetag) }} network_mode: bridge hostname: couchdb-{{ peer.name }} {% endif %} {{ peer.name }}: container_name: {{ peer.name }} - image: hyperledger/fabric-peer:{{ thetag }} + image: {{ fabric.repo.url }}fabric-peer:{{ thetag }} network_mode: bridge hostname: {{ peer.name }} environment: diff --git a/src/agent/ansible/roles/deploy_compose/fabricsetup/templates/zookeeper-compose.j2 b/src/agent/ansible/roles/deploy_compose/fabricsetup/templates/zookeeper-compose.j2 index 79ee3eb5..ba140c4b 100755 --- a/src/agent/ansible/roles/deploy_compose/fabricsetup/templates/zookeeper-compose.j2 +++ b/src/agent/ansible/roles/deploy_compose/fabricsetup/templates/zookeeper-compose.j2 @@ -6,7 +6,7 @@ services: {% for zookeeper in zookeepers %} {{ zookeeper }}: container_name: {{ zookeeper }} - image: hyperledger/fabric-zookeeper:{{ (fabric.helper_tag == "") | ternary(thetag, helpertag) }} + image: {{ fabric.repo.url }}fabric-zookeeper:{{ helpertag | default(thetag) }} network_mode: bridge hostname: {{ zookeeper }} restart: always diff --git a/src/agent/ansible/roles/deploy_compose/plays.yml b/src/agent/ansible/roles/deploy_compose/plays.yml index 6c823fb9..dbccf142 100755 --- a/src/agent/ansible/roles/deploy_compose/plays.yml +++ b/src/agent/ansible/roles/deploy_compose/plays.yml @@ -6,7 +6,7 @@ vars_files: - "./../../vars/{{ env }}.yml" tasks: - - include: "fabricbuild/tasks/{{ mode }}.yml" + - include_tasks: "fabricbuild/tasks/{{ mode }}.yml" tags: "fabricbuild" - name: generate certificates diff --git a/src/agent/ansible/roles/deploy_k8s/fabricsetup/tasks/apply.yml b/src/agent/ansible/roles/deploy_k8s/fabricsetup/tasks/apply.yml index 3e4c8ed4..0bb437a0 100755 --- a/src/agent/ansible/roles/deploy_k8s/fabricsetup/tasks/apply.yml +++ b/src/agent/ansible/roles/deploy_k8s/fabricsetup/tasks/apply.yml @@ -1,14 +1,9 @@ --- -- name: Figuring out the server architecture - shell: uname -m - register: rawarch - - name: Setup and initialize variables set_fact: current_host: "{{ hostvars[inventory_hostname].inter_name }}" fabricworkdir: "/opt/gopath/{{ env }}/fabric" gopath: "/opt/gopath/{{ env }}" - arch: "{{ rawarch.stdout}}" peers: "{{ [] }}" orderers: "{{ [] }}" cas: "{{ [] }}" @@ -28,8 +23,6 @@ cals: "{{ [] }}" allpeers: "{{ [] }}" clihost: "" - thetag: "{{ rawarch.stdout + '-' + fabric.baseimage_tag }}" - helpertag: "{{ rawarch.stdout + '-' + fabric.helper_tag }}" filterstr: "" k8s_server: "{{ hostvars[groups['allnodes'][0]].private_ip }}" @@ -134,30 +127,32 @@ scp -i "/opt/gopath/id_rsa" -r -o "StrictHostKeyChecking no" "{{ fabric. ssh_user }}@{{ hostvars[groups['builders'][0]].private_ip }}:{{ fabricworkdir }}/images/fabricimages.tar" "{{ fabricworkdir }}/fabricimages.tar" - when: fabric.baseimage_tag == '' + when: fabric.baseimage_tag == '' and inventory_hostname not in groups['builders'] - name: Pull container version file from the build machine command: >- scp -i "/opt/gopath/id_rsa" -r -o "StrictHostKeyChecking no" "{{ fabric. ssh_user }}@{{ hostvars[groups['builders'][0]].private_ip }}:{{ fabricworkdir }}/images/VERSION" "{{ fabricworkdir }}/VERSION" - when: fabric.baseimage_tag == '' + +- stat: + path: "{{ fabricworkdir }}/fabricimages.tar" + register: imagepack - name: Load all the docker images created by build machine shell: >- docker load -i {{ fabricworkdir }}/fabricimages.tar - when: fabric.baseimage_tag == '' + when: imagepack.stat.exists == true and inventory_hostname not in groups['builders'] - name: Find out the image tags slurp: src: "{{ fabricworkdir }}/VERSION" - register: project_version - when: fabric.baseimage_tag == '' + register: imagetag -- name: Set the container tag +- name: Set image tag from the file set_fact: - thetag: "{{ arch + '-' + (project_version['content'] | b64decode) }}" - when: fabric.baseimage_tag == '' + thetag: "{{ imagetag['content'] | b64decode }}" + helpertag: "{{ fabric.helper_tag }}" - name: Unpack the certificates unarchive: @@ -217,18 +212,19 @@ - "{{ kafkas }}" - "fabriccli" -- name: Pull container images from the docker hub - command: "docker pull {{ item }}" - when: fabric.baseimage_tag | length > 0 +- name: Pull necessary container images from the docker hub + command: "docker pull {{ fabric.repo.url }}{{ item.name }}" + when: item.flag | length > 0 and fabric.baseimage_tag | length > 0 with_items: - - "hyperledger/fabric-ca:{{ thetag }}" - - "hyperledger/fabric-tools:{{ thetag }}" - - "hyperledger/fabric-ccenv:{{ thetag }}" - - "hyperledger/fabric-kafka:{{ thetag }}" - - "hyperledger/fabric-zookeeper:{{ thetag }}" - - "hyperledger/fabric-peer:{{ thetag }}" - - "hyperledger/fabric-orderer:{{ thetag }}" - - "hyperledger/fabric-couchdb:{{ thetag }}" + - { name: "fabric-ca:{{ helpertag }}", flag: "{{ cas }}" } + - { name: "fabric-zookeeper:{{ helpertag }}", flag: "{{ zookeepers }}" } + - { name: "fabric-kafka:{{ helpertag }}", flag: "{{ kafkas }}" } + - { name: "fabric-couchdb:{{ helpertag }}", flag: "{{ peers }}" } + - { name: "fabric-orderer:{{ thetag }}", flag: "{{ orderers }}" } + - { name: "fabric-peer:{{ thetag }}", flag: "{{ peers }}" } + - { name: "fabric-ccenv:{{ thetag }}", flag: "{{ peers }}" } + - { name: "fabric-tools:{{ thetag }}", flag: "tools" } + tags: "pullimages" - name: Start fabric pods command: "/opt/fabric/bin/kubectl --server {{ k8s_server }}:8080 create -f {{ fabricworkdir }}/run/fabric-pod.yml" diff --git a/src/agent/ansible/roles/deploy_k8s/fabricsetup/templates/cli-k8s.j2 b/src/agent/ansible/roles/deploy_k8s/fabricsetup/templates/cli-k8s.j2 index a8cdf982..fc69371a 100755 --- a/src/agent/ansible/roles/deploy_k8s/fabricsetup/templates/cli-k8s.j2 +++ b/src/agent/ansible/roles/deploy_k8s/fabricsetup/templates/cli-k8s.j2 @@ -20,7 +20,7 @@ spec: path: {{ fabricworkdir }}/run/keyfiles/chaincode containers: - name: fabriccli - image: hyperledger/fabric-tools:{{ thetag }} + image: {{ fabric.repo.url }}fabric-tools:{{ thetag }} imagePullPolicy: IfNotPresent securityContext: privileged: true diff --git a/src/agent/ansible/roles/deploy_k8s/fabricsetup/templates/dochannel.j2 b/src/agent/ansible/roles/deploy_k8s/fabricsetup/templates/dochannel.j2 index f4e635d2..d3b4dffa 100755 --- a/src/agent/ansible/roles/deploy_k8s/fabricsetup/templates/dochannel.j2 +++ b/src/agent/ansible/roles/deploy_k8s/fabricsetup/templates/dochannel.j2 @@ -7,6 +7,8 @@ export CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/allorgs/{{ clipeer.org }}/peers/{ export CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/allorgs/{{ clipeer.org }}/peers/{{ clipeer.name }}.{{ clipeer.org }}/tls/ca.crt export CORE_PEER_ID={{ clipeer.name }} export CORE_PEER_ADDRESS={{ clipeer.name }}:7051 +export CORE_PEER_LISTENADDRESS={{ clipeer.name }}:7051 +export CORE_PEER_CHAINCODELISTENADDRESS={{ clipeer.name }}:7052 export CORE_PEER_LOCALMSPID={{ clipeer.org }} export CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/allorgs/{{ clipeer.org }}/users/Admin@{{ clipeer.org }}/msp @@ -26,6 +28,8 @@ export CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/allorgs/{{ peer.org }}/peers/{{ p export CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/allorgs/{{ peer.org }}/peers/{{ peer.name }}.{{ peer.org }}/tls/ca.crt export CORE_PEER_ID={{ peer.name }} export CORE_PEER_ADDRESS={{ peer.name }}:7051 +export CORE_PEER_LISTENADDRESS={{ peer.name }}:7051 +export CORE_PEER_CHAINCODELISTENADDRESS={{ peer.name }}:7052 export CORE_PEER_LOCALMSPID={{ peer.org }} export CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/allorgs/{{ peer.org }}/users/Admin@{{ peer.org }}/msp @@ -43,6 +47,8 @@ export CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/allorgs/{{ chainpeer.org }}/peers export CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/allorgs/{{ chainpeer.org }}/peers/{{ chainpeer.name }}.{{ chainpeer.org }}/tls/ca.crt export CORE_PEER_ID={{ chainpeer.name }} export CORE_PEER_ADDRESS={{ chainpeer.name }}:7051 +export CORE_PEER_LISTENADDRESS={{ chainpeer.name }}:7051 +export CORE_PEER_CHAINCODELISTENADDRESS={{ chainpeer.name }}:7052 export CORE_PEER_LOCALMSPID={{ chainpeer.org }} export CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/allorgs/{{ chainpeer.org }}/users/Admin@{{ chainpeer.org }}/msp @@ -58,6 +64,8 @@ echo '-------------- Query chaincode' {% else %} export CORE_PEER_ID={{ clipeer.name }} export CORE_PEER_ADDRESS={{ clipeer.name }}:7051 +export CORE_PEER_LISTENADDRESS={{ clipeer.name }}:7051 +export CORE_PEER_CHAINCODELISTENADDRESS={{ clipeer.name }}:7052 export CORE_PEER_LOCALMSPID={{ clipeer.org }} export CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/allorgs/{{ clipeer.org }}/users/Admin@{{ clipeer.org }}/msp @@ -74,6 +82,9 @@ mkdir -p $GOPATH/src/chaincode export CORE_PEER_ID={{ peer.name }} export CORE_PEER_ADDRESS={{ peer.name }}:7051 +export CORE_PEER_LISTENADDRESS={{ peer.name }}:7051 +export CORE_PEER_CHAINCODELISTENADDRESS={{ peer.name }}:7052 + export CORE_PEER_LOCALMSPID={{ peer.org }} export CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/allorgs/{{ peer.org }}/users/Admin@{{ peer.org }}/msp @@ -89,6 +100,8 @@ echo '-------------- Instantiate chaincode' {% set chainpeer = peers[0] %} export CORE_PEER_ID={{ chainpeer.name }} export CORE_PEER_ADDRESS={{ chainpeer.name }}:7051 +export CORE_PEER_LISTENADDRESS={{ chainpeer.name }}:7051 +export CORE_PEER_CHAINCODELISTENADDRESS={{ chainpeer.name }}:7052 export CORE_PEER_LOCALMSPID={{ chainpeer.org }} export CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/allorgs/{{ chainpeer.org }}/users/Admin@{{ chainpeer.org }}/msp diff --git a/src/agent/ansible/roles/deploy_k8s/fabricsetup/templates/fabric-pod.j2 b/src/agent/ansible/roles/deploy_k8s/fabricsetup/templates/fabric-pod.j2 index 96dc5912..19019e78 100755 --- a/src/agent/ansible/roles/deploy_k8s/fabricsetup/templates/fabric-pod.j2 +++ b/src/agent/ansible/roles/deploy_k8s/fabricsetup/templates/fabric-pod.j2 @@ -15,7 +15,7 @@ spec: restartPolicy: Always containers: - name: {{ zookeeper }} - image: hyperledger/fabric-zookeeper:{{ (fabric.helper_tag == "") | ternary(thetag, helpertag) }} + image: {{ fabric.repo.url }}fabric-zookeeper:{{ helpertag }} imagePullPolicy: IfNotPresent env: - { name: "ZOO_MY_ID", value: "{{ zoo_ids[zookeeper] }}" } @@ -53,7 +53,7 @@ spec: restartPolicy: Always containers: - name: {{ kafka }} - image: hyperledger/fabric-kafka:{{ (fabric.helper_tag == "") | ternary(thetag, helpertag) }} + image: {{ fabric.repo.url }}fabric-kafka:{{ helpertag }} imagePullPolicy: IfNotPresent env: - { name: "KAFKA_MESSAGE_MAX_BYTES", value: "103809024" } @@ -96,7 +96,7 @@ spec: path: {{ fabricworkdir }}/run/keyfiles/{{ ca.org }} containers: - name: {{ ca.name }} - image: hyperledger/fabric-ca:{{ (fabric.helper_tag == "") | ternary(thetag, helpertag) }} + image: {{ fabric.repo.url }}fabric-ca:{{ helpertag }} imagePullPolicy: IfNotPresent env: - { name: "FABRIC_CA_HOME", value: "/etc/hyperledger/fabric-ca-server-config/ca" } @@ -152,13 +152,13 @@ spec: containers: {% if fabric.peer_db == 'CouchDB' %} - name: couchdb-{{ peer.name }} - image: hyperledger/fabric-couchdb:{{ (fabric.helper_tag == "") | ternary(thetag, helpertag) }} + image: {{ fabric.repo.url }}fabric-couchdb:{{ helpertag }} imagePullPolicy: IfNotPresent securityContext: privileged: true {% endif %} - name: {{ peer.name }} - image: hyperledger/fabric-peer:{{ thetag }} + image: {{ fabric.repo.url }}fabric-peer:{{ thetag }} imagePullPolicy: IfNotPresent securityContext: privileged: true @@ -177,8 +177,10 @@ spec: - { name: "CORE_PEER_TLS_ROOTCERT_FILE", value: "/etc/hyperledger/fabric/tls/ca.crt" } {% endif %} - { name: "CORE_PEER_ID", value: "{{ peer.name }}" } - - { name: "CORE_PEER_ADDRESS", value: "{{ peer.name }}:7051" } - { name: "CORE_PEER_GOSSIP_EXTERNALENDPOINT", value: "{{ peer.name }}:7051" } + - { name: "CORE_PEER_ADDRESS", value: "{{ peer.name }}:7051" } + - { name: "CORE_PEER_LISTENADDRESS", value: "{{ peer.name }}:7051" } + - { name: "CORE_PEER_CHAINCODELISTENADDRESS", value: "{{ peer.name }}:7052" } - { name: "CORE_PEER_LOCALMSPID", value: "{{ peer.org }}" } - { name: "CORE_PEER_MSPCONFIGPATH", value: "/etc/hyperledger/fabric/msp" } {% if fabric.peer_db == 'CouchDB' %} @@ -204,6 +206,8 @@ spec: ports: - name: port1 port: 7051 + - name: port2 + port: 7052 {% endfor %} {% for orderer in orderers %} @@ -226,7 +230,7 @@ spec: path: {{ fabricworkdir }}/run/keyfiles/{{ orderer.org }}/orderers/{{ orderer.name }}.{{ orderer.org }} containers: - name: {{ orderer.name }} - image: hyperledger/fabric-orderer:{{ thetag }} + image: {{ fabric.repo.url }}fabric-orderer:{{ thetag }} imagePullPolicy: IfNotPresent env: - { name: "ORDERER_GENERAL_LOGLEVEL", value: "debug" } diff --git a/src/agent/ansible/vars/bc1st.yml b/src/agent/ansible/vars/bc1st.yml index 3659a19e..e2b4a639 100755 --- a/src/agent/ansible/vars/bc1st.yml +++ b/src/agent/ansible/vars/bc1st.yml @@ -50,8 +50,35 @@ fabric: { } }, - baseimage_tag: "1.1.0-preview", - # This tag defines image tag for containers such as kafka, zookeeper and couchdb - helper_tag: "1.1.0-preview", - ca: { admin: "admin", adminpw: "adminpw" } + # the container tag for main fabric components such as orderer, peer, + # tools and chaincode. If left blank, then fabric components will be built + # from the latest fabric source code with the combination of the refspec + # specified above. If it is not empty, then its values must be the full + # container tag like the following: + # x86_64-1.1.0-alpha # alpha release + # DAILY_STABLE # daily stable + # DEV_STABLE # dev stable + # s390x-0.4.2 # release 0.4.2 for s390x + # 048c91eb47812582f36665fbea3d7e0e68e396bf # commit build + # x86_64-1.0.0-snapshot-8d3275f # snapshot build + baseimage_tag: "x86_64-1.1.0-alpha", + + # The container tag for accessory fabric components such as ca, kafka, + # zookeeper and couchdb. It has to be the full tag just like the + # baseimage_tag + helper_tag: "x86_64-1.1.0-preview", + ca: { admin: "admin", adminpw: "adminpw" }, + + # Only use this field when you have a docker repository. + repo: { + # the url defines docker hub project access point + # official hub - url: "hyperledger/", + # fabric build hub - url: "nexus3.hyperledger.org:10001/hyperledger/", + url: "hyperledger/", + + # locations to download fabric binaries. This url should point to a + # compressed such as tar or zip file which contains necessary binaries + # such as configtxgen, configtxlator, cryptogen etc. + bin: "https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric-build/linux-amd64-ff6f6dbffed57efb9f7d8886b4a47949ce2d4396/hyperledger-fabric-build-linux-amd64-ff6f6dbffed57efb9f7d8886b4a47949ce2d4396.tar.gz" + } } diff --git a/src/agent/ansible/vars/bc2nd.yml b/src/agent/ansible/vars/bc2nd.yml index 239bec59..8544b305 100755 --- a/src/agent/ansible/vars/bc2nd.yml +++ b/src/agent/ansible/vars/bc2nd.yml @@ -22,8 +22,35 @@ fabric: { } }, - baseimage_tag: "1.1.0-preview", - # This tag defines image tag for containers such as kafka, zookeeper and couchdb - helper_tag: "1.1.0-preview", - ca: { admin: "admin", adminpw: "adminpw" } + # the container tag for main fabric components such as orderer, peer, + # tools and chaincode. If left blank, then fabric components will be built + # from the latest fabric source code with the combination of the refspec + # specified above. If it is not empty, then its values must be the full + # container tag like the following: + # x86_64-1.1.0-alpha # alpha release + # DAILY_STABLE # daily stable + # DEV_STABLE # dev stable + # s390x-0.4.2 # release 0.4.2 for s390x + # 048c91eb47812582f36665fbea3d7e0e68e396bf # commit build + # x86_64-1.0.0-snapshot-8d3275f # snapshot build + baseimage_tag: "x86_64-1.1.0-alpha", + + # The container tag for accessory fabric components such as ca, kafka, + # zookeeper and couchdb. It has to be the full tag just like the + # baseimage_tag + helper_tag: "x86_64-1.1.0-preview", + ca: { admin: "admin", adminpw: "adminpw" }, + + # Only use this field when you have a docker repository. + repo: { + # the url defines docker hub project access point + # official hub - url: "hyperledger/", + # fabric build hub - url: "nexus3.hyperledger.org:10001/hyperledger/", + url: "hyperledger/", + + # locations to download fabric binaries. This url should point to a + # compressed such as tar or zip file which contains necessary binaries + # such as configtxgen, configtxlator, cryptogen etc. + bin: "https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric-build/linux-amd64-ff6f6dbffed57efb9f7d8886b4a47949ce2d4396/hyperledger-fabric-build-linux-amd64-ff6f6dbffed57efb9f7d8886b4a47949ce2d4396.tar.gz" + } } diff --git a/src/agent/ansible/vars/vb.yml b/src/agent/ansible/vars/vb.yml index 8d463e9f..11f37e6f 100755 --- a/src/agent/ansible/vars/vb.yml +++ b/src/agent/ansible/vars/vb.yml @@ -1,7 +1,7 @@ --- auth: { # Define where the VirtualBox(VB) system is - auth_url: "192.168.0.36", + auth_url: "192.168.0.35", # User name to log in to the remote VB system username: "tongli", # Password to the VB system, can specify at command line @@ -55,7 +55,7 @@ cluster: { flannel_repo: "https://github.com/coreos/flannel/releases/download/v0.7.1/flannel-v0.7.1-linux-amd64.tar.gz", etcd_repo: "https://github.com/coreos/etcd/releases/download/v3.2.0/etcd-v3.2.0-linux-amd64.tar.gz", k8s_repo: "https://storage.googleapis.com/kubernetes-release/release/v1.7.0/bin/linux/amd64/", - go_repo: "https://dl.google.com/go/go1.9.3.linux-amd64.tar.gz", + go_repo: "https://dl.google.com/go/go1.9.2.linux-amd64.tar.gz", # If volume want to be used, specify a size in GB, make volume size 0 if wish # not to use volume from your cloud diff --git a/src/agent/ansible/vars/vb1st.yml b/src/agent/ansible/vars/vb1st.yml index 71892143..1fdb3e77 100755 --- a/src/agent/ansible/vars/vb1st.yml +++ b/src/agent/ansible/vars/vb1st.yml @@ -7,7 +7,7 @@ GIT_URL: "http://gerrit.hyperledger.org/r/fabric" # GERRIT_REFSPEC: "refs/changes/47/12047/3" # 1.0.1 # GERRIT_REFSPEC: "refs/changes/13/13113/1" # GERRIT_REFSPEC: "refs/tags/v1.0.4" # 1.0.4 -GERRIT_REFSPEC: "refs/tags/v1.0.5" # 1.0.5 +GERRIT_REFSPEC: "" # 1.0.5 # This variable defines fabric network attributes fabric: { @@ -43,8 +43,35 @@ fabric: { } }, - baseimage_tag: "1.1.0-preview", - # This tag defines image tag for containers such as kafka, zookeeper and couchdb - helper_tag: "1.1.0-preview", - ca: { admin: "admin", adminpw: "adminpw" } + # the container tag for main fabric components such as orderer, peer, + # tools and chaincode. If left blank, then fabric components will be built + # from the latest fabric source code with the combination of the refspec + # specified above. If it is not empty, then its values must be the full + # container tag like the following: + # x86_64-1.1.0-alpha # alpha release + # DAILY_STABLE # daily stable + # DEV_STABLE # dev stable + # s390x-0.4.2 # release 0.4.2 for s390x + # 048c91eb47812582f36665fbea3d7e0e68e396bf # commit build + # x86_64-1.0.0-snapshot-8d3275f # snapshot build + baseimage_tag: "x86_64-1.1.0-alpha", + + # The container tag for accessory fabric components such as ca, kafka, + # zookeeper and couchdb. It has to be the full tag just like the + # baseimage_tag + helper_tag: "x86_64-1.1.0-preview", + ca: { admin: "admin", adminpw: "adminpw" }, + + # Only use this field when you have a docker repository. + repo: { + # the url defines docker hub project access point + # official hub - url: "hyperledger/", + # fabric build hub - url: "nexus3.hyperledger.org:10001/hyperledger/", + url: "hyperledger/", + + # locations to download fabric binaries. This url should point to a + # compressed such as tar or zip file which contains necessary binaries + # such as configtxgen, configtxlator, cryptogen etc. + bin: "https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric-build/linux-amd64-ff6f6dbffed57efb9f7d8886b4a47949ce2d4396/hyperledger-fabric-build-linux-amd64-ff6f6dbffed57efb9f7d8886b4a47949ce2d4396.tar.gz" + } }