From 78ddcc08e15990ead7fb326df5667d1e8788c6d0 Mon Sep 17 00:00:00 2001 From: Greg Szabo Date: Mon, 19 Jun 2017 19:04:34 +0000 Subject: [PATCH] removed python dependency from package, remove jq dependency from ansible --- ansible/config.toml | 16 --------------- ansible/config.yml | 8 ++++++++ ansible/rmdb.yml | 8 ++++++++ ansible/roles/config/tasks/main.yml | 4 ++-- .../config/templates/genesis-server.json.j2 | 5 ++++- ansible/roles/install/tasks/centos.yml | 20 ++++++++++++------- ansible/roles/install/tasks/debian.yml | 11 ++++++---- devops/rpmbuild/Makefile | 8 ++++---- .../extrafiles/DEBIAN-basecoin/postinst | 4 ++-- .../extrafiles/DEBIAN-ethermint/postinst | 4 ++-- devops/rpmbuild/spectemplates/basecoin.spec | 2 +- devops/rpmbuild/spectemplates/ethermint.spec | 5 ++--- 12 files changed, 53 insertions(+), 42 deletions(-) delete mode 100644 ansible/config.toml create mode 100644 ansible/config.yml create mode 100644 ansible/rmdb.yml diff --git a/ansible/config.toml b/ansible/config.toml deleted file mode 100644 index 42cc8a4fe..000000000 --- a/ansible/config.toml +++ /dev/null @@ -1,16 +0,0 @@ -# This is a TOML config file. -# For more information, see https://github.com/toml-lang/toml - -proxy_app = "tcp://127.0.0.1:46658" -moniker = "146.185.178.252" -fast_sync = true -db_backend = "leveldb" -log_level = "debug" - -[rpc] -laddr = "tcp://0.0.0.0:46657" - -[p2p] -laddr = "tcp://0.0.0.0:46656" -seeds = "138.197.154.40:46656,138.68.244.161:46656,128.199.192.199:46656,46.101.41.147:46656,162.243.247.32:46656,207.154.231.86:46656" - diff --git a/ansible/config.yml b/ansible/config.yml new file mode 100644 index 000000000..04ae6ff6c --- /dev/null +++ b/ansible/config.yml @@ -0,0 +1,8 @@ +--- + +#variable "service" is required + +- hosts: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}" + roles: + - {role: config, testnet_name: "{{lookup('env','TF_VAR_TESTNET_NAME')}}"} + diff --git a/ansible/rmdb.yml b/ansible/rmdb.yml new file mode 100644 index 000000000..49f84863a --- /dev/null +++ b/ansible/rmdb.yml @@ -0,0 +1,8 @@ +--- + +#variable "service" is required + +- hosts: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}" + roles: + - rmdb + diff --git a/ansible/roles/config/tasks/main.yml b/ansible/roles/config/tasks/main.yml index 2b3e5c675..bbb5955a9 100644 --- a/ansible/roles/config/tasks/main.yml +++ b/ansible/roles/config/tasks/main.yml @@ -2,13 +2,13 @@ - name: gather tendermint public keys when: validators == true and tendermint_genesis_file is not defined - command: "jq '.pub_key | .data' /etc/{{service}}/tendermint/priv_validator.json" + shell: "tendermint show_validator --home /etc/{{service}}/tendermint --log_level error" register: pubkeys changed_when: false - name: register tendermint public keys as host facts when: validators == true and tendermint_genesis_file is not defined - set_fact: "pubkey={{pubkeys.stdout_lines[0]}}" + set_fact: "pubkey='{{pubkeys.stdout}}'" connection: local - name: copy generated tendermint genesis.json - genesis_time will be updated diff --git a/ansible/roles/config/templates/genesis-server.json.j2 b/ansible/roles/config/templates/genesis-server.json.j2 index c8dd4635a..e7093b950 100644 --- a/ansible/roles/config/templates/genesis-server.json.j2 +++ b/ansible/roles/config/templates/genesis-server.json.j2 @@ -8,7 +8,10 @@ {% for host in groups[testnet_name] %} {{ comma() }} { - "pub_key":{"type":"ed25519","data":{{hostvars[host]["pubkey"]}}}, + "pub_key": { + "data": "{{hostvars[host]["pubkey"]["data"]}}", + "type": "ed25519" + }, "amount":10, "name":"{{hostvars[host]["ansible_hostname"]}}" } diff --git a/ansible/roles/install/tasks/centos.yml b/ansible/roles/install/tasks/centos.yml index e11f1359c..41b14c5c5 100644 --- a/ansible/roles/install/tasks/centos.yml +++ b/ansible/roles/install/tasks/centos.yml @@ -1,19 +1,25 @@ --- -- name: Add tendermint repository and key on CentOS/RedHat + +#Three commands to install a service on CentOS/RedHat +#wget -O - http://tendermint-packages.s3-website-us-west-1.amazonaws.com/centos/7/os/x86_64/RPM-GPG-KEY-Tendermint | rpm --import - +#wget -O /etc/yum.repos.d/tendermint.repo http://tendermint-packages.s3-website-us-west-1.amazonaws.com/centos/7/os/x86_64/tendermint.repo +#yum update && yum install basecoin + +- name: Add repository key on CentOS/RedHat + when: ansible_os_family == "RedHat" + rpm_key: key=http://tendermint-packages.s3-website-us-west-1.amazonaws.com/centos/7/os/x86_64/RPM-GPG-KEY-Tendermint + +- name: Install tendermint repository on CentOS/RedHat when: ansible_os_family == "RedHat" yum_repository: name: tendermint baseurl: http://tendermint-packages.s3-website-us-west-1.amazonaws.com/centos/7/os/x86_64 description: "Tendermint repo" gpgcheck: yes - gpgkey: http://tendermint-packages.s3-website-us-west-1.amazonaws.com/centos/RPM-GPG-KEY-Tendermint + gpgkey: http://tendermint-packages.s3-website-us-west-1.amazonaws.com/centos/7/os/x86_64/RPM-GPG-KEY-Tendermint repo_gpgcheck: yes - name: Install package on CentOS/RedHat when: ansible_os_family == "RedHat" - yum: pkg={{item}} - with_items: - - epel-release - - jq - - "{{service}}" + yum: "pkg={{service}}" diff --git a/ansible/roles/install/tasks/debian.yml b/ansible/roles/install/tasks/debian.yml index 89e32a075..bb7058038 100644 --- a/ansible/roles/install/tasks/debian.yml +++ b/ansible/roles/install/tasks/debian.yml @@ -1,4 +1,10 @@ --- + +#Three commands to install a service on Debian/Ubuntu +#wget -O - http://tendermint-packages.s3-website-us-west-1.amazonaws.com/centos/7/os/x86_64/RPM-GPG-KEY-Tendermint | apt-key add - +#echo "deb http://tendermint-packages.s3-website-us-west-1.amazonaws.com/debian stable main" > /etc/apt/sources.list.d/tendermint.list +#apt-get update && apt-get install basecoin + - name: Add repository key on Debian/Ubuntu when: ansible_os_family == "Debian" apt_key: @@ -12,8 +18,5 @@ - name: Install package on Debian/Ubuntu when: ansible_os_family == "Debian" - apt: pkg={{item}} - with_items: - - jq - - "{{service}}" + apt: "pkg={{service}}" diff --git a/devops/rpmbuild/Makefile b/devops/rpmbuild/Makefile index 2ad4863b5..1e5f82626 100644 --- a/devops/rpmbuild/Makefile +++ b/devops/rpmbuild/Makefile @@ -132,7 +132,7 @@ package-deb-%: version-% install-rpm-%: version-% #Make sure your host has the IAM role to read/write the S3 bucket OR that you set up ~/.boto @echo "*** Uploading $*-$($*_version)-$(BUILD_NUMBER).x86_64.rpm to AWS CentOS repository" - aws s3 sync s3://tendermint-packages/centos/ tmp/s3/ + aws s3 sync s3://tendermint-packages/centos/ tmp/s3/ --delete mkdir -p tmp/s3/7/os/x86_64/Packages cp RPMS/x86_64/$*-$($*_version)-$(BUILD_NUMBER).x86_64.rpm tmp/s3/7/os/x86_64/Packages cp repofiles/RPM-GPG-KEY-Tendermint tmp/s3/7/os/x86_64/ @@ -140,14 +140,14 @@ install-rpm-%: version-% rm -f tmp/s3/7/os/x86_64/repodata/*.bz2 tmp/s3/7/os/x86_64/repodata/*.gz tmp/s3/7/os/x86_64/repodata/repomd.xml.asc createrepo tmp/s3/7/os/x86_64/Packages -u http://tendermint-packages.s3-website-us-west-1.amazonaws.com/centos/7/os/x86_64/Packages -o tmp/s3/7/os/x86_64 --update -S --repo Tendermint --content tendermint --content basecoin --content ethermint gpg --batch --passphrase "$(GPG_PASSPHRASE)" --sign -a tmp/s3/7/os/x86_64/repodata/repomd.xml - aws s3 sync tmp/s3/ s3://tendermint-packages/centos/ --acl public-read + aws s3 sync tmp/s3/ s3://tendermint-packages/centos/ --delete --acl public-read @echo "*** Uploaded $* to AWS CentOS repository" install-deb-%: version-% @echo "*** Uploading $*-$($*_version)-$(BUILD_NUMBER)_amd64.deb to AWS Debian repository" @echo "Testing if $*-$($*_version)-$(BUILD_NUMBER)_amd64.deb is already uploaded" test ! -f tmp/debian-s3/pool/$*-$($*_version)-$(BUILD_NUMBER)_amd64.deb - aws s3 sync s3://tendermint-packages/debian/ tmp/debian-s3/ + aws s3 sync s3://tendermint-packages/debian/ tmp/debian-s3/ --delete @echo "Testing if $*-$($*_version)-$(BUILD_NUMBER)_amd64.deb is already uploaded" test ! -f tmp/debian-s3/pool/$*-$($*_version)-$(BUILD_NUMBER)_amd64.deb mkdir -p tmp/debian-s3/pool tmp/debian-s3/dists/stable/main/binary-amd64 @@ -205,7 +205,7 @@ install-deb-%: version-% gpg --batch --passphrase "$(GPG_PASSPHRASE)" --digest-algo SHA512 --clearsign tmp/debian-s3/dists/stable/Release mv tmp/debian-s3/dists/stable/Release.asc tmp/debian-s3/dists/stable/InRelease - aws s3 sync tmp/debian-s3/ s3://tendermint-packages/debian/ --acl public-read + aws s3 sync tmp/debian-s3/ s3://tendermint-packages/debian/ --delete --acl public-read @echo "*** Uploaded $*-$($*_version)-$(BUILD_NUMBER)_amd64.deb to AWS Debian repository" mostlyclean: diff --git a/devops/rpmbuild/extrafiles/DEBIAN-basecoin/postinst b/devops/rpmbuild/extrafiles/DEBIAN-basecoin/postinst index cf7250e1b..c6beabebd 100644 --- a/devops/rpmbuild/extrafiles/DEBIAN-basecoin/postinst +++ b/devops/rpmbuild/extrafiles/DEBIAN-basecoin/postinst @@ -25,7 +25,7 @@ case "$1" in chown basecoin.basecoin /etc/basecoin/tendermint/config.toml test ! -f /etc/basecoin/priv_validator.json && tendermint gen_validator > /etc/basecoin/priv_validator.json && chmod 0400 /etc/basecoin/priv_validator.json && chown basecoin.basecoin /etc/basecoin/priv_validator.json test ! -f /etc/basecoin/tendermint/priv_validator.json && tendermint gen_validator > /etc/basecoin/tendermint/priv_validator.json && chmod 0400 /etc/basecoin/tendermint/priv_validator.json && chown basecoin.basecoin /etc/basecoin/tendermint/priv_validator.json - tendermint_pubkey=`python -uc "import json ; print json.loads(open('/etc/basecoin/tendermint/priv_validator.json').read())['pub_key']['data']"` + tendermint_pubkey="`tendermint show_validator --home /etc/basecoin/tendermint --log_level error`" test ! -f /etc/basecoin/tendermint/genesis.json && cat << EOF > /etc/basecoin/tendermint/genesis.json { "genesis_time": "2017-06-10T03:37:03Z", @@ -33,7 +33,7 @@ case "$1" in "validators": [ { - "pub_key":{"type":"ed25519","data":"$tendermint_pubkey"}, + "pub_key": $tendermint_pubkey, "amount":10, "name":"my_testchain_node" } diff --git a/devops/rpmbuild/extrafiles/DEBIAN-ethermint/postinst b/devops/rpmbuild/extrafiles/DEBIAN-ethermint/postinst index c83ce75d6..44a2323f8 100644 --- a/devops/rpmbuild/extrafiles/DEBIAN-ethermint/postinst +++ b/devops/rpmbuild/extrafiles/DEBIAN-ethermint/postinst @@ -29,7 +29,7 @@ case "$1" in /usr/bin/ethermint --datadir /etc/ethermint init /etc/ethermint/genesis.json chown -R ethermint.ethermint /etc/ethermint/ethermint test ! -f /etc/ethermint/tendermint/priv_validator.json && tendermint gen_validator > /etc/ethermint/tendermint/priv_validator.json && chmod 0400 /etc/ethermint/tendermint/priv_validator.json && chown ethermint.ethermint /etc/ethermint/tendermint/priv_validator.json - tendermint_pubkey=`python -uc "import json ; print json.loads(open('/etc/ethermint/tendermint/priv_validator.json').read())['pub_key']['data']"` + tendermint_pubkey="`tendermint show_validator --home /etc/ethermint/tendermint --log_level error`" test ! -f /etc/ethermint/tendermint/genesis.json && cat << EOF > /etc/ethermint/tendermint/genesis.json { "genesis_time": "2017-06-10T03:37:03Z", @@ -37,7 +37,7 @@ case "$1" in "validators": [ { - "pub_key":{"type":"ed25519","data":"$tendermint_pubkey"}, + "pub_key": $tendermint_pubkey, "amount":10, "name":"my_testchain_node" } diff --git a/devops/rpmbuild/spectemplates/basecoin.spec b/devops/rpmbuild/spectemplates/basecoin.spec index 45cfb36c9..cbd3fc511 100644 --- a/devops/rpmbuild/spectemplates/basecoin.spec +++ b/devops/rpmbuild/spectemplates/basecoin.spec @@ -51,7 +51,7 @@ cd %{name}-%{version} %post test ! -f %{_sysconfdir}/%{name}/priv_validator.json && tendermint gen_validator > %{_sysconfdir}/%{name}/priv_validator.json && %{__chmod} 0400 %{_sysconfdir}/%{name}/priv_validator.json && %{__chown} %{name}.%{name} %{_sysconfdir}/%{name}/priv_validator.json test ! -f %{_sysconfdir}/%{name}/tendermint/priv_validator.json && tendermint gen_validator > %{_sysconfdir}/%{name}/tendermint/priv_validator.json && %{__chmod} 0400 %{_sysconfdir}/%{name}/tendermint/priv_validator.json && %{__chown} %{name}.%{name} %{_sysconfdir}/%{name}/tendermint/priv_validator.json -tendermint_pubkey="`tendermint show_validator --home /etc/%{name}/tendermint --log_level error`" +tendermint_pubkey="`tendermint show_validator --home %{_sysconfdir}/%{name}/tendermint --log_level error`" test ! -f %{_sysconfdir}/%{name}/tendermint/genesis.json && %{__cat} << EOF > %{_sysconfdir}/%{name}/tendermint/genesis.json { "genesis_time": "2017-06-10T03:37:03Z", diff --git a/devops/rpmbuild/spectemplates/ethermint.spec b/devops/rpmbuild/spectemplates/ethermint.spec index 4f878f0ef..66fbfc127 100644 --- a/devops/rpmbuild/spectemplates/ethermint.spec +++ b/devops/rpmbuild/spectemplates/ethermint.spec @@ -10,7 +10,6 @@ URL: https://tendermint.com/ Packager: Greg Szabo Requires: tendermint >= 0.10.0 Requires(pre): /sbin/useradd -Requires(post): %{__python} %description Ethermint enables ethereum to run as an ABCI application on tendermint and the COSMOS hub. This application allows you to get all the benefits of ethereum without having to run your own miners. @@ -49,7 +48,7 @@ cd %{name}-%{version} %post %{_bindir}/%{name} --datadir %{_sysconfdir}/%{name} init %{_sysconfdir}/%{name}/genesis.json test ! -f %{_sysconfdir}/%{name}/tendermint/priv_validator.json && tendermint gen_validator > %{_sysconfdir}/%{name}/tendermint/priv_validator.json && %{__chmod} 0400 %{_sysconfdir}/%{name}/tendermint/priv_validator.json && %{__chown} %{name}.%{name} %{_sysconfdir}/%{name}/tendermint/priv_validator.json -tendermint_pubkey=`%{__python} -uc "import json ; print json.loads(open('%{_sysconfdir}/%{name}/tendermint/priv_validator.json').read())['pub_key']['data']"` +tendermint_pubkey="`tendermint show_validator --home %{_sysconfdir}/%{name}/tendermint --log_level error`" test ! -f %{_sysconfdir}/%{name}/tendermint/genesis.json && %{__cat} << EOF > %{_sysconfdir}/%{name}/tendermint/genesis.json { "genesis_time": "2017-06-10T03:37:03Z", @@ -57,7 +56,7 @@ test ! -f %{_sysconfdir}/%{name}/tendermint/genesis.json && %{__cat} << EOF > %{ "validators": [ { - "pub_key":{"type":"ed25519","data":"$tendermint_pubkey"}, + "pub_key": $tendermint_pubkey, "amount":10, "name":"my_testchain_node" }