-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Julien Piccaluga
committed
Aug 29, 2022
1 parent
edec258
commit f138002
Showing
7 changed files
with
224 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.secrets/ | ||
.idea/ | ||
__pycache__/ | ||
#inventory_backup/ | ||
#inventory_test/ | ||
#inventory_/ | ||
tmp/ | ||
#inventory/mainnet.yaml | ||
#inventory/testnet.yaml | ||
#inventory/group_vars/all.yml | ||
#inventory/group_vars/local.yaml | ||
#inventory/group_vars/mainnet_validators.yaml | ||
#inventory/group_vars/remote.yaml | ||
#inventory/group_vars/testnet_validators.yaml | ||
#inventory-test/hosts.yml | ||
#inventory-test/group_vars/all.yml | ||
#roles/monitoring/files/test.py | ||
#inventory/group_vars/rpc.yaml |
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,28 @@ | ||
--- | ||
all: | ||
children: | ||
mainnet_validators: | ||
children: | ||
remote: | ||
hosts: | ||
server1: | ||
ansible_host: <ip address> | ||
#any var from group vars: | ||
ramdisk_size_gb: <number> | ||
validator_description: 'Bootstrapped with https://sv-manager.thevalidators.io' | ||
validator_homepage: '' | ||
validator_keybase: '' | ||
server2: | ||
ansible_host: <ip address> | ||
#any var from group vars: | ||
ramdisk_size_gb: <number> | ||
local: | ||
hosts: | ||
localhost: | ||
#any var from group vars: | ||
validator_name: "<validator name>" | ||
localhost_rpc: | ||
ansible_host: localhost | ||
force: true | ||
rpc_node: true | ||
solana_validator_service: started |
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,25 @@ | ||
--- | ||
all: | ||
children: | ||
testnet_validators: | ||
children: | ||
remote: | ||
hosts: | ||
server1: | ||
ansible_host: <ip address> | ||
#any var from group vars: | ||
validator_homepage: "" | ||
validator_keybase: "" | ||
server2: | ||
ansible_host: <ip address> | ||
local: | ||
hosts: | ||
localhost: | ||
#any var from group vars: | ||
validator_homepage: "" | ||
validator_keybase: "" | ||
localhost_rpc: | ||
ansible_host: localhost | ||
force: true | ||
rpc_node: true | ||
solana_validator_service: startedted |
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,6 @@ | ||
--- | ||
- name: install or update config file | ||
hosts: all | ||
become: yes | ||
roles: | ||
- solana_config |
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,49 @@ | ||
--- | ||
|
||
- name: ensure directory exists | ||
file: | ||
path: "/etc/latitude_manager" | ||
state: directory | ||
mode: '0755' | ||
|
||
- name: Check if config file exists | ||
stat: | ||
path: /etc/latitude_manager/latitude_manager.conf | ||
register: config_exists | ||
|
||
- name: Load config file | ||
slurp: | ||
src: /etc/latitude_manager/latitude_manager.conf | ||
register: config_data | ||
when: config_exists.stat.exists | ||
|
||
- name: set dictionary | ||
set_fact: | ||
config_dict: "{{ config_data.content | default([]) }}" | ||
when: not config_exists.stat.exists | ||
|
||
- name: dictionary | ||
set_fact: | ||
config_dict: "{{ config_data.content | b64decode | from_json | default([]) }}" | ||
when: config_exists.stat.exists | ||
|
||
- name: create config from template | ||
set_fact: | ||
config_dict_template: "{{ lookup('template', 'templates/latitude_manager.conf.template') }}" | ||
|
||
- name: show present config dictionary | ||
debug: | ||
msg: "{{ config_dict }}" | ||
|
||
- name: combine with host section | ||
set_fact: | ||
config_dict: "{{ config_dict_template | combine(config_dict) }}" | ||
|
||
- name: show new config | ||
debug: | ||
var: config_dict | ||
|
||
- name: write var to file | ||
copy: | ||
content: "{{ config_dict | to_nice_json }}" | ||
dest: /etc/latitude_manager/latitude_manager.conf |
22 changes: 22 additions & 0 deletions
22
roles/solana_config/templates/latitude_manager.conf.template
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,22 @@ | ||
{ | ||
"cluster_environment": "{{ hostvars[inventory_hostname]["cluster_environment"] }}", | ||
"cluster_rpc_address": "{{ hostvars[inventory_hostname]["cluster_rpc_address"] }}", | ||
"flat_path": "{{ hostvars[inventory_hostname]["flat_path"] }}", | ||
"keybase_username": "{{ hostvars[inventory_hostname]["keybase_username"] }}", | ||
"ledger_path": "{{ hostvars[inventory_hostname]["ledger_path"] }}", | ||
"local_secrets_path": "{{ hostvars[inventory_hostname]["local_secrets_path"] }}", | ||
"log_level": "{{ hostvars[inventory_hostname]["log_level"] }}", | ||
"lvm_enabled": "{{ hostvars[inventory_hostname]["lvm_enabled"] }}", | ||
"lvm_vg": "{{ hostvars[inventory_hostname]["lvm_vg"] | default(omit) }}", | ||
"ramdisk_size_gb": "{{ hostvars[inventory_hostname]["ramdisk_size_gb"] }}", | ||
"secrets_path": "{{ hostvars[inventory_hostname]["secrets_path"] }}", | ||
"set_validator_info": "{{ hostvars[inventory_hostname]["set_validator_info"] }}", | ||
"snapshots_path": "{{ hostvars[inventory_hostname]["snapshots_path"] }}", | ||
"solana_user": "{{ hostvars[inventory_hostname]["solana_user"] }}", | ||
"solana_validator_service": "{{ hostvars[inventory_hostname]["solana_validator_service"] }}", | ||
"solana_version": "{{ hostvars[inventory_hostname]["solana_version"] }}", | ||
"swap_file_size_gb": "{{ hostvars[inventory_hostname]["swap_file_size_gb"] }}", | ||
"upload_validator_keys": "{{ hostvars[inventory_hostname]["upload_validator_keys"] }}", | ||
"validator_homepage": "{{ hostvars[inventory_hostname]["validator_homepage"] }}", | ||
"validator_name": "{{ hostvars[inventory_hostname]["validator_name"] }}" | ||
} |
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,76 @@ | ||
#!/bin/bash | ||
#set -x -e | ||
|
||
echo "############### Latitude.sh for Solana #################" | ||
echo "### This script will init a Solana validator node ###" | ||
echo "########################################################" | ||
|
||
usage() { | ||
echo "Usage: $0 [ -c CLUSTER ] [ -r RAM_DISK_SIZE ] [ -s SWAP_SIZE ]" 1>&2 | ||
} | ||
|
||
exit_abnormal() { | ||
usage | ||
exit 1 | ||
} | ||
|
||
install_ansible () { | ||
echo "Updating packages..." | ||
apt update | ||
echo "Installing ansible, curl, unzip..." | ||
apt install ansible curl unzip --yes | ||
|
||
ansible-galaxy collection install ansible.posix | ||
ansible-galaxy collection install community.general | ||
} | ||
|
||
download_latitude_manager () { | ||
echo "Downloading Solana validator manager version $VERSION" | ||
cmd="https://github.com/JulI0-concerto/latitude_manager/archive/refs/tags/$VERSION.zip" | ||
echo "starting $cmd" | ||
curl -fsSL "$cmd" --output latitude_manager.zip | ||
echo "Unpacking" | ||
unzip ./latitude_manager.zip -d . | ||
|
||
mv latitude_manager* latitude_manager | ||
rm ./latitude_manager.zip | ||
cd ./latitude_manager || exit | ||
cp -r ./inventory_example ./inventory | ||
} | ||
|
||
init_validator () { | ||
|
||
ansible-playbook --connection=local --inventory ./inventory/${CLUSTER}.yaml --limit localhost playbooks/config.yaml --extra-vars "{ \ | ||
'swap_file_size_gb': $SWAP_SIZE, \ | ||
'ramdisk_size_gb': $RAM_DISK_SIZE, \ | ||
}" | ||
|
||
} | ||
|
||
while getopts ":c:r:s:v" options; do | ||
case "${options}" in | ||
c) | ||
CLUSTER=${OPTARG} | ||
;; | ||
r) | ||
RAM_DISK_SIZE={OPTARG} | ||
;; | ||
s) | ||
SWAP_SIZE={OPTARG} | ||
;; | ||
v) | ||
VERSION={OPTARG} | ||
;; | ||
:) | ||
echo "Error: -${OPTARG} requires an argument." | ||
exit_abnormal | ||
;; | ||
*) | ||
exit_abnormal | ||
;; | ||
esac | ||
done | ||
|
||
install_ansible | ||
download_latitude_manager | ||
init_validator |