-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CE-255] Allow ansible agent to avoid build any thing
Currently ansible agent requires download fabric source code to at least build cryptogen and configtxgen binary to produce org certificats. With this change, agent now can simply download binaries and docker images from a configuration location such as a location docker hub. This patch set also improves the docker images download so that the not needed images will not be pulled off of the hub. It also contains the recent changes on fabric for peers to have a listen address and port to be configured. Change-Id: Ic132fe8bc3ece96e6b99990664eec21b0b9cd568 Signed-off-by: tongliofcary <litong01@us.ibm.com>
- Loading branch information
tongliofcary
committed
Jan 31, 2018
1 parent
a902a14
commit f79f349
Showing
21 changed files
with
297 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/agent/ansible/roles/deploy_compose/fabricbuild/tasks/build.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/agent/ansible/roles/deploy_compose/fabricbuild/tasks/download.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) }} |
2 changes: 1 addition & 1 deletion
2
src/agent/ansible/roles/deploy_compose/fabricbuild/templates/VERSION.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{{ project_version }} | ||
{{ baseimage_tag }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.