add ability to compile from source (#14)

pull/15/head
Benjamin Burns 5 years ago committed by GitHub
parent af0c33ea1d
commit 1ebaf3850c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      README.md
  2. 5
      defaults/main.yml
  3. 39
      tasks/compile.yml
  4. 4
      tasks/install.yml
  5. 11
      tasks/main.yml

@ -30,7 +30,10 @@ All variables which can be overridden are stored in [defaults/main.yml](defaults
| Name | Default Value | Description |
| -------------- | ------------- | -----------------------------------|
| `besu_version` | ___unset___ | __REQUIRED__ Version of Besu to install and run. All available versions are listed on our Besu [solutions](https://pegasys.tech/solutions/hyperledger-besu/) page |
| `besu_build_from_source` | ___unset___ | When set to `true`, Besu is build from git sources. See also `besu_git_repo` and `besu_git_commit` |
| `besu_version` | ___unset___ | __REQUIRED__ if `besu_build_from_source` is false. Version of Besu to install and run. All available versions are listed on our Besu [solutions](https://pegasys.tech/solutions/hyperledger-besu/) page |
| `besu_git_repo` | https://github.com/hyperledger/besu.git | The URL to use when cloning besu sources. Only necessary when `besu_build_from_source` is `true`. |
| `besu_git_commit` | master | The git commit to use when building Besu from source. Can be a branchname, commit hash, or anything that's legal to be used as an argument to `git checkout`. Only used if `besu_build_from_source` is `true`. |
| `besu_user` | besu | Besu user |
| `besu_group` | besu | Besu group |
| `besu_download_url` | https://bintray.com/hyperledger-org/besu-repo/download_file?file_path=besu-{{ besu_version }}.tar.gz | The download tar.gz file used. You can use this if you need to retrieve besu from a custom location such as an internal repository. |

@ -7,6 +7,11 @@ besu_group: "{{ besu_user }}"
# Version to install
besu_download_url: "https://bintray.com/hyperledger-org/besu-repo/download_file?file_path=besu-{{ besu_version }}.tar.gz"
# Building from source
besu_build_from_source: false
besu_git_repo: "https://github.com/hyperledger/besu.git"
besu_git_commit: "master"
# Directory paths
besu_base_dir: "/opt/besu"
besu_install_dir: "{{ besu_base_dir }}/besu-{{ besu_version }}"

@ -0,0 +1,39 @@
---
- name: Ensure we have sane configuration
fail:
msg: You must set "besu_git_repo" for this role to run when "besu_build_from_source" is enabled
when: not (besu_git_repo is defined) or besu_git_repo|length == 0
- name: Check JDK version
shell: javac -version | egrep -o '[0-9]+\.[0-9]+\.[0-9]+'
register: jdk_version
ignore_errors: true
- name: Ensure JDK is installed
fail:
msg: "You must have JDK 11 or later installed. {{ 'No version found.' if jdk_version is failed else 'Found version ' + jdk_version.stdout }}"
when: jdk_version.stdout is version('11.0.0', '<')
- name: Clone Besu Sources
git:
repo: "{{ besu_git_repo }}"
dest: '/tmp/besu'
version: "{{ besu_git_commit }}"
- name: Build Besu
shell: ./gradlew --no-daemon --parallel clean assemble
args:
chdir: /tmp/besu
- name: Get Besu Version
shell: "awk '/version=/ { gsub(/version=/,\"\"); print $1 }' gradle.properties"
args:
chdir: /tmp/besu
register: besu_version_cmd
- name: Set Besu Version Fact
set_fact:
besu_version: "{{ besu_version_cmd.stdout }}"

@ -44,8 +44,8 @@
- name: Extract Besu source to install directory
unarchive:
src: "{{ besu_download_url }}"
remote_src: true
src: "{{ '/tmp/besu/build/distributions/besu-' + besu_version + '.tar.gz' if besu_build_from_source else besu_download_url }}"
remote_src: "{{ false if besu_build_from_source else true }}"
dest: "{{ besu_install_dir }}"
owner: "{{ besu_user }}"
group: "{{ besu_group }}"

@ -2,8 +2,11 @@
- name: Ensure we have sane configuration
block:
- fail:
msg: You must set "besu_version" for this role to run
when: besu_version is not defined
msg: You must set "besu_version" for this role to run when not building Besu from source
when: besu_version is not defined and not besu_build_from_source
- fail:
msg: The vars "besu_version" and "besu_build_from_source" are incompatible. If trying to build a specific git refspec, use "besu_git_refspec" instead of besu_version.
when: besu_version is defined and besu_build_from_source
- fail:
msg: Orion and Fast-Sync are incompatible
when: orion_version is defined and besu_sync_mode == "FAST"
@ -16,6 +19,10 @@
- "{{ ansible_os_family|lower }}.yml"
skip: true
- name: Compile besu
include_tasks: "compile.yml"
when: besu_build_from_source
- name: Install besu
include_tasks: "install.yml"

Loading…
Cancel
Save