Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Commit

Permalink
use the chainspec from it's in repo location rather than on deployer …
Browse files Browse the repository at this point in the history
…machine (#375)

* move chainspec location to var

* stop copying chainspec form local machine
  • Loading branch information
coburncoburn authored Jun 24, 2021
1 parent f01c57d commit 73c30b7
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 39 deletions.
3 changes: 2 additions & 1 deletion ops/ansible/playbooks/resync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
- include_role:
name: chain_node
tasks_from: purge-and-restart



4 changes: 2 additions & 2 deletions ops/ansible/roles/chain_node/tasks/build-chain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

- name: compile gateway
command:
cmd: '{{ cargo_bin }} +nightly build --release'
chdir: '{{ gateway_home }}'
cmd: "{{ cargo_bin }} build --release" # appropriate nightly is rustup default
chdir: "{{ gateway_home }}"
async: 3600
poll: 0
register: gateway
Expand Down
18 changes: 10 additions & 8 deletions ops/ansible/roles/chain_node/tasks/build-essentials.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@

- name: ensure a list of packages installed
apt:
pkg: "{{ packages }}"
state: present
update_cache: true
become: 'yes'
become: "yes"

- name: check for rustup
stat:
path: '{{ rustup_home }}'
path: "{{ rustup_home }}"
changed_when: false
register: rustup_home_binary

- when: not rustup_home_binary.stat.exists
block:
- name: download rustup-init...
get_url:
url: '{{ rustup_init_url }}'
url: "{{ rustup_init_url }}"
dest: /tmp/rustup-init
mode: 0755

- name: install rust...
command: /tmp/rustup-init -y
args:
creates: '{{ rustup_home }}'
creates: "{{ rustup_home }}"

- name: install stable rust
command: '{{ rustup_home }} default stable'
command: "{{ rustup_home }} default stable"

- name: install nightly toolchain
command: '{{ rustup_home }} toolchain install nightly'
command: "{{ rustup_home }} toolchain install nightly-2021-05-24"

- name: install wasm
command: '{{ rustup_home }} target add wasm32-unknown-unknown --toolchain nightly'
command: "{{ rustup_home }} target add wasm32-unknown-unknown --toolchain nightly-2021-05-24"

- name: default to nightly rust
command: "{{ rustup_home }} default nightly-2021-05-24"

always:
- name: clean rustup
Expand Down
25 changes: 12 additions & 13 deletions ops/ansible/roles/chain_node/tasks/purge-and-restart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
name: gateway.service
state: stopped

- name: bring chain spec
become: true
ansible.builtin.copy:
src: "{{ chain_spec }}"
dest: "{{ gateway_user_home }}/chainSpec.json"
owner: gateway
mode: '0644'
# chainspecs have gotten much more stable
# - name: bring chain spec
# become: true
# ansible.builtin.copy:
# src: "{{ chain_spec }}"
# dest: "{{ gateway_chain_spec_raw }}"
# owner: gateway
# mode: '0644'

- name: purge chain
become: true
shell: |
set -o pipefail
{{ gateway_bin }} purge-chain -y --chain "{{ gateway_user_home }}/chainSpec.json" --base-path {{ chain_data_dir }} --database paritydb
{{ gateway_bin }} purge-chain -y --chain {{ gateway_chain_spec_raw }} --base-path {{ chain_data_dir }} --database paritydb-experimental
args:
executable: /bin/bash
changed_when: False
Expand All @@ -29,21 +30,19 @@
vars:
peers: "{{ bootnodes }}"
authority: "{{ authority }}"
tags:
gateway-service
tags: gateway-service

- name: reinstall Gateway systemd unit file (full node)
template: src=gateway-full-node.j2 dest=/etc/systemd/system/gateway.service
become: true
when: "'full_node' in group_names"
vars:
peers: "{{ groups['authority_node'] }}"
tags:
gateway-service
tags: gateway-service

- name: start gateway service
become: true
systemd:
name: gateway.service
state: started
daemon_reload: yes
daemon_reload: yes
20 changes: 9 additions & 11 deletions ops/ansible/roles/chain_node/tasks/resync_fulls.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

- name: stop gateway service
when: "'full_node' in group_names"
become: true
Expand All @@ -11,7 +10,7 @@
when: "'full_node' in group_names"
shell: |
set -o pipefail
{{ gateway_bin }} purge-chain -y --chain "{{ gateway_user_home }}/chainSpec.json" --base-path {{ chain_data_dir }} --database paritydb-experimental
{{ gateway_bin }} purge-chain -y --chain {{ gateway_chain_spec_raw }} --base-path {{ chain_data_dir }} --database paritydb-experimental
args:
executable: /bin/bash
changed_when: False
Expand All @@ -22,13 +21,12 @@
when: "'full_node' in group_names"
vars:
peers: "{{ groups['authority_node'] }}"
tags:
gateway-service
tags: gateway-service

# - name: start gateway service
# when: "'full_node' in group_names"
# become: true
# systemd:
# name: gateway.service
# state: started
# daemon_reload: yes
- name: start gateway service
when: "'full_node' in group_names"
become: true
systemd:
name: gateway.service
state: started
daemon_reload: yes
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ Environment="KEYRING_TYPE={{ keyring_type | default('IN_MEMORY') }}"
Environment="MINER={{ miner }}"
ExecStart={{ gateway_bin }} \
--base-path {{ chain_data_dir }} \
--chain "{{ gateway_user_home }}/chainSpec.json" \
--chain {{ gateway_chain_spec_raw }} \
--port 30333 \
--ws-port 9944 \
--ws-external \
--rpc-port 9933 \
--rpc-methods Unsafe \
--rpc-external \
--no-mdns \
--log pallet_cash=debug \
--node-key-file {{ node_key_priv_file }} \
{% for bootnode_multi_addr in peers -%}
--bootnodes {{ bootnode_multi_addr }} \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ WorkingDirectory={{ gateway_user_home }}
Environment="MINER={{ miner }}"
ExecStart={{ gateway_bin }} \
--base-path {{ chain_data_dir }} \
--chain "{{ gateway_user_home }}/chainSpec.json" \
--chain {{ gateway_chain_spec_raw }} \
--port 30333 \
--ws-port 9944 \
--ws-external \
Expand Down
2 changes: 1 addition & 1 deletion ops/ansible/roles/chain_node/vars/main/git.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ssh_home: "{{ ansible_env.HOME }}/.ssh"
git_deploy_key: "{{ ssh_home }}/id_rsa_gateway_deploy"
git_repo: "ssh://[email protected]/compound-finance/gateway.git"
git_branch: "cob/rpcs"
git_branch: "develop"
2 changes: 1 addition & 1 deletion ops/ansible/roles/chain_node/vars/main/paths.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

rustup_init_url: https://sh.rustup.rs
cargo_home: "{{ ansible_env.HOME }}/.cargo"
cargo_bin_dir: "{{ cargo_home }}/bin"
Expand All @@ -7,3 +6,4 @@ subkey_bin: "{{ cargo_bin_dir }}/subkey"
rustup_home: "{{ cargo_home }}/bin/rustup"
gateway_home: "{{ ansible_env.HOME }}/gateway"
gateway_bin: "{{ ansible_env.HOME }}/gateway/target/release/gateway"
gateway_chain_spec_raw: "{{ ansible_env.HOME }}/gateway/chains/testnet/chain-spec-raw.json"

0 comments on commit 73c30b7

Please sign in to comment.