ritual/playbook.yml
vvzvlad 63e27f31ac Remove grpc-balancer.py and update deployment configuration
- Deleted grpc-balancer.py as part of the cleanup process, streamlining the application setup.
- Updated playbook.yml to include new commands for managing the grpcbalancer service and SSL certificate.
- Modified docker-compose.yaml to remove the mounting of the SSL certificate, reflecting the updated deployment strategy.
- Adjusted rebuild.sh to change the working directory to ~/node for consistency in project structure.
2025-01-20 23:55:26 +03:00

269 lines
7.8 KiB
YAML

---
- name: System Setup and Configuration
hosts: all
become: true
tasks:
- name: Set locale to C.UTF-8
command: localectl set-locale LANG=C.UTF-8
- name: Create APT configuration file to assume yes
ansible.builtin.copy:
dest: /etc/apt/apt.conf.d/90forceyes
content: |
APT::Get::Assume-Yes "true";
mode: '0644'
- name: Append command to .bash_history
ansible.builtin.blockinfile:
path: "~/.bash_history"
create: true
block: |
cd ~/node; bash rebuild.sh
nano ~/node/projects/hello-world/container/config.json
docker logs infernet-node -f
docker logs --since 10m infernet-node -f
journalctl -u node-checker.service
journalctl -u grpcbalancer.service
nano ~/node/deploy/config.json
docker compose -f deploy/docker-compose.yaml down; docker compose -f deploy/docker-compose.yaml up -d
marker: ""
mode: '0644'
- name: Append command to .bash_rc
ansible.builtin.blockinfile:
path: "~/.bashrc"
create: true
insertafter: EOF
block: |
cd /root/node
marker: ""
mode: '0644'
- name: Update /etc/bash.bashrc
ansible.builtin.blockinfile:
path: /etc/bash.bashrc
block: |
export HISTTIMEFORMAT='%F, %T '
export HISTSIZE=10000
export HISTFILESIZE=10000
shopt -s histappend
export PROMPT_COMMAND='history -a'
export HISTCONTROL=ignoredups
export LANG=C.UTF-8
export LC_ALL=C.UTF-8
alias ls='ls --color=auto'
shopt -s cmdhist
create: true
marker: ""
mode: '0644'
- name: Update .inputrc for the current user
ansible.builtin.blockinfile:
path: "{{ ansible_env.HOME }}/.inputrc"
block: |
"\e[A": history-search-backward
"\e[B": history-search-forward
create: true
marker: ""
mode: '0644'
- name: Update ~/.nanorc
ansible.builtin.blockinfile:
path: "{{ ansible_env.HOME }}/.nanorc"
block: |
set nohelp
set tabsize 4
set tabstospaces
set autoindent
set positionlog
set backup
set backupdir /tmp/
set locking
include /usr/share/nano/*.nanorc
create: true
marker: ""
mode: '0644'
- name: Set hostname
ansible.builtin.hostname:
name: "{{ serverid }}"
- name: Ensure hostname is in /etc/hosts
ansible.builtin.lineinfile:
path: /etc/hosts
regexp: '^127\.0\.1\.1\s+'
line: "127.0.1.1 {{ serverid }}"
state: present
#- name: Update and upgrade apt
# ansible.builtin.apt:
# update_cache: true
# upgrade: dist
# force_apt_get: true
# register: apt_update_result
# until: apt_update_result is success
- name: Install necessary packages
ansible.builtin.apt:
name:
- apt-transport-https
- ca-certificates
- curl
- software-properties-common
- make
- iftop
- python3
state: present
- name: Install pip package web3
ansible.builtin.pip:
name: web3
extra_args: --break-system-packages
# - name: Install Docker
# ansible.builtin.shell: curl -sL https://get.docker.com | sudo sh -
#
- name: Update Docker daemon configuration for journald logging
ansible.builtin.copy:
dest: /etc/docker/daemon.json
content: |
{
"log-driver": "journald",
"registry-mirrors": ["https://dockerregistry.vvzvlad.xyz"]
}
- name: Restart Docker
ansible.builtin.service:
name: docker
state: restarted
- name: Docker pull hello-world
ansible.builtin.shell: docker pull ritualnetwork/hello-world-infernet:latest
# - name: Update journald log SystemMaxUse=2G configuration
# ansible.builtin.lineinfile:
# path: /etc/systemd/journald.conf
# regexp: '^SystemMaxUse='
# line: 'SystemMaxUse=2G'
# state: present
# backup: yes
# validate: 'journaldctl check-config %s'
#
# - name: Restart journald
# ansible.builtin.service:
# name: systemd-journald
# state: restarted
- name: Setup Foundry
ansible.builtin.shell: |
mkdir -p ~/foundry && cd ~/foundry
curl -L https://foundry.paradigm.xyz | bash
args:
executable: /bin/bash
- name: Run foundryup
ansible.builtin.shell: |
source ~/.bashrc && foundryup
args:
executable: /bin/bash
- name: Clone repository
ansible.builtin.git:
repo: https://gitea.vvzvlad.xyz/vvzvlad/ritual.git
dest: "{{ ansible_env.HOME }}/node"
version: "{{ git_version }}"
force: true
async: "{{ 60 * 15 }}"
poll: 30
- name: Update environment variables
ansible.builtin.shell: |
chmod +x ./update.sh
./update.sh ID "{{ serverid }}"
./update.sh GRIST_SERVER "{{ grist_server }}"
./update.sh GRIST_DOC_ID "{{ grist_doc_id }}"
./update.sh GRIST_API_KEY "{{ grist_api_key }}"
./update.sh WALLET_ADDRESS "{{ wallet }}"
./update.sh PRIVATE_KEY "{{ private_key }}"
./update.sh RPC_URL "{{ rpc_url }}"
args:
chdir: "{{ ansible_env.HOME }}/node"
changed_when: false
- name: Install Forge and Infernet SDK
ansible.builtin.shell: |
rm -rf {{ ansible_env.HOME }}/node/projects/hello-world/contracts/lib/forge-std
rm -rf {{ ansible_env.HOME }}/node/projects/hello-world/contracts/lib/infernet-sdk
cd {{ ansible_env.HOME }}/foundry && source {{ ansible_env.HOME }}/.bashrc && foundryup
cd {{ ansible_env.HOME }}/node/projects/hello-world/contracts
forge install --no-commit foundry-rs/forge-std
forge install --no-commit ritual-net/infernet-sdk
args:
executable: /bin/bash
- name: Deploy container
ansible.builtin.shell: project=hello-world make deploy-container
args:
chdir: "{{ ansible_env.HOME }}/node"
- name: Deploy contracts
ansible.builtin.shell: project=hello-world make deploy-contracts 2>&1
register: contract_deploy_output
args:
chdir: "{{ ansible_env.HOME }}/node"
executable: /bin/bash
retries: 5
delay: 120
async: 120
poll: 30
until: '"ONCHAIN EXECUTION COMPLETE & SUCCESSFUL" in contract_deploy_output.stdout'
failed_when: false
- name: Update CallContract.s.sol with contract address
ansible.builtin.shell: bash update_contracts.sh
args:
chdir: "{{ ansible_env.HOME }}/node"
- name: Call contract
ansible.builtin.shell: project=hello-world make call-contract 2>&1
register: contract_call_output
args:
chdir: "{{ ansible_env.HOME }}/node"
executable: /bin/bash
retries: 5
delay: 120
async: 120
poll: 30
until: '"ONCHAIN EXECUTION COMPLETE & SUCCESSFUL" in contract_call_output.stdout'
failed_when: false
- name: Copy checker service file
ansible.builtin.copy:
dest: /etc/systemd/system/node-checker.service
content: |
[Unit]
Description=Node Checker Service
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory={{ ansible_env.HOME }}/node
ExecStart=/usr/bin/python3 {{ ansible_env.HOME }}/node/checker.py
Restart=always
RestartSec=600
[Install]
WantedBy=multi-user.target
mode: '0644'
- name: Enable and start node-checker service
ansible.builtin.systemd:
name: node-checker
enabled: yes
state: started
daemon_reload: yes