Compare commits
8 Commits
main
...
8183934d09
Author | SHA1 | Date | |
---|---|---|---|
8183934d09 | |||
1558f60810 | |||
138fcfc321 | |||
153ccfd4db | |||
eaceb3ecfa | |||
c0fd0330af | |||
fc49f06d75 | |||
17702b1396 |
197
playbook.yml
197
playbook.yml
@ -1,16 +1,34 @@
|
||||
---
|
||||
- name: System Setup and Configuration
|
||||
hosts: all
|
||||
become: yes
|
||||
|
||||
|
||||
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: |
|
||||
docker logs infernet-node -f
|
||||
cd ~/ritual; project=hello-world make deploy-container
|
||||
cd ~/ritual; project=hello-world make deploy-contracts
|
||||
cd ~/ritual; contract_address=$(jq -r '.transactions[0].contractAddress' projects/hello-world/contracts/broadcast/Deploy.s.sol/8453/run-latest.json); checksum_address=$(python3 toChecksumAddress.py $contract_address); sed -i "s/SaysGM(.*/SaysGM($checksum_address);/" projects/hello-world/contracts/script/CallContract.s.sol
|
||||
cd ~/ritual; project=hello-world make call-contract
|
||||
marker: ""
|
||||
mode: '0644'
|
||||
|
||||
- name: Update /etc/bash.bashrc
|
||||
blockinfile:
|
||||
ansible.builtin.blockinfile:
|
||||
path: /etc/bash.bashrc
|
||||
block: |
|
||||
export HISTTIMEFORMAT='%F, %T '
|
||||
@ -23,27 +41,23 @@
|
||||
export LC_ALL=C.UTF-8
|
||||
alias ls='ls --color=auto'
|
||||
shopt -s cmdhist
|
||||
create: true
|
||||
marker: ""
|
||||
mode: '0644'
|
||||
|
||||
- name: Ensure ~/.inputrc exists
|
||||
file:
|
||||
path: /root/.inputrc
|
||||
state: touch
|
||||
|
||||
- name: Update ~/.inputrc
|
||||
blockinfile:
|
||||
path: ~/.inputrc
|
||||
- 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
|
||||
|
||||
- name: Ensure ~/.nanorc exists
|
||||
file:
|
||||
path: /root/.nanorc
|
||||
state: touch
|
||||
create: true
|
||||
marker: ""
|
||||
mode: '0644'
|
||||
|
||||
- name: Update ~/.nanorc
|
||||
blockinfile:
|
||||
path: ~/.nanorc
|
||||
ansible.builtin.blockinfile:
|
||||
path: "{{ ansible_env.HOME }}/.nanorc"
|
||||
block: |
|
||||
set nohelp
|
||||
set tabsize 4
|
||||
@ -54,24 +68,31 @@
|
||||
set backupdir /tmp/
|
||||
set locking
|
||||
include /usr/share/nano/*.nanorc
|
||||
create: true
|
||||
marker: ""
|
||||
mode: '0644'
|
||||
|
||||
- name: Set hostname
|
||||
shell: |
|
||||
hostnamectl set-hostname {{ serverid }}
|
||||
echo "127.0.1.1 {{ serverid }}" >> /etc/hosts
|
||||
- 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
|
||||
apt:
|
||||
update_cache: yes
|
||||
ansible.builtin.apt:
|
||||
update_cache: true
|
||||
upgrade: dist
|
||||
force_apt_get: yes
|
||||
force_apt_get: true
|
||||
register: apt_update_result
|
||||
retries: 50
|
||||
delay: 50
|
||||
until: apt_update_result is succeeded
|
||||
until: apt_update_result is success
|
||||
|
||||
- name: Install necessary packages
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- apt-transport-https
|
||||
- ca-certificates
|
||||
@ -83,132 +104,120 @@
|
||||
state: present
|
||||
|
||||
- name: Install pip package web3
|
||||
pip:
|
||||
ansible.builtin.pip:
|
||||
name: web3
|
||||
extra_args: --break-system-packages
|
||||
|
||||
- name: Install Docker
|
||||
shell: curl -sL https://get.docker.com | sudo sh -
|
||||
|
||||
- name: Ensure /etc/docker/daemon.json exists
|
||||
file:
|
||||
path: /etc/docker/daemon.json
|
||||
state: touch
|
||||
ansible.builtin.shell: curl -sL https://get.docker.com | sudo sh -
|
||||
|
||||
- name: Update Docker daemon configuration for journald logging
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
dest: /etc/docker/daemon.json
|
||||
content: |
|
||||
{
|
||||
"log-driver": "journald"
|
||||
}
|
||||
{ "log-driver": "journald" }
|
||||
|
||||
- name: Restart Docker
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: docker
|
||||
state: restarted
|
||||
|
||||
- name: Docker login
|
||||
shell: docker login -u {{ docker_username }} -p {{ docker_password }}
|
||||
ansible.builtin.shell: docker login -u {{ docker_username }} -p {{ docker_password }}
|
||||
|
||||
- name: Update journald log SystemMaxUse=2G configuration
|
||||
lineinfile:
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/systemd/journald.conf
|
||||
regexp: '^SystemMaxUse='
|
||||
line: 'SystemMaxUse=2G'
|
||||
insertafter: EOF
|
||||
create: yes
|
||||
state: present
|
||||
backup: yes
|
||||
validate: 'journaldctl check-config %s'
|
||||
|
||||
- name: Restart journald
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: systemd-journald
|
||||
state: restarted
|
||||
|
||||
- name: Setup Foundry
|
||||
shell: |
|
||||
ansible.builtin.shell: |
|
||||
mkdir -p ~/foundry && cd ~/foundry
|
||||
curl -L https://foundry.paradigm.xyz | bash
|
||||
args:
|
||||
executable: /bin/bash
|
||||
|
||||
- name: Run foundryup
|
||||
shell: |
|
||||
ansible.builtin.shell: |
|
||||
source ~/.bashrc && foundryup
|
||||
args:
|
||||
executable: /bin/bash
|
||||
|
||||
- name: Clone ritual-says-gm repository
|
||||
git:
|
||||
repo: https://gitea.vvzvlad.xyz/vvzvlad/ritual-says-gm.git
|
||||
dest: ~/ritual-says-gm
|
||||
force: yes
|
||||
- name: Clone repository
|
||||
ansible.builtin.git:
|
||||
repo: https://gitea.vvzvlad.xyz/vvzvlad/ritual.git
|
||||
dest: "{{ ansible_env.HOME }}/ritual"
|
||||
version: "{{ git_version }}"
|
||||
force: true
|
||||
async: "{{ 60 * 15 }}"
|
||||
poll: 30
|
||||
|
||||
- name: Update wallet, private key and RPC URL in project
|
||||
shell: |
|
||||
cd ~/ritual-says-gm
|
||||
bash update.sh {{ wallet }} {{ private_key }} {{ rpc_url }}
|
||||
ansible.builtin.shell: bash update.sh {{ wallet }} {{ private_key }} {{ rpc_url }}
|
||||
args:
|
||||
chdir: "{{ ansible_env.HOME }}/ritual"
|
||||
|
||||
- name: Remove old Forge and Infernet SDK
|
||||
shell: |
|
||||
cd ~/ritual-says-gm
|
||||
rm -rf projects/hello-world/contracts/lib/forge-std
|
||||
rm -rf projects/hello-world/contracts/lib/infernet-sdk
|
||||
ansible.builtin.shell: |
|
||||
rm -rf {{ ansible_env.HOME }}/ritual/projects/hello-world/contracts/lib/forge-std
|
||||
rm -rf {{ ansible_env.HOME }}/ritual/projects/hello-world/contracts/lib/infernet-sdk
|
||||
|
||||
- name: Install Forge and Infernet SDK
|
||||
shell: |
|
||||
cd ~/foundry && source ~/.bashrc && foundryup
|
||||
cd ~/ritual-says-gm
|
||||
cd projects/hello-world/contracts
|
||||
ansible.builtin.shell: |
|
||||
cd {{ ansible_env.HOME }}/foundry && source {{ ansible_env.HOME }}/.bashrc && foundryup
|
||||
cd {{ ansible_env.HOME }}/ritual/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
|
||||
shell: |
|
||||
cd ~/ritual-says-gm && project=hello-world make deploy-container
|
||||
ansible.builtin.shell: project=hello-world make deploy-container
|
||||
args:
|
||||
chdir: "{{ ansible_env.HOME }}/ritual"
|
||||
|
||||
- name: Deploy contracts
|
||||
shell: cd ~/ritual-says-gm && project=hello-world make deploy-contracts 2>&1
|
||||
ansible.builtin.shell: project=hello-world make deploy-contracts 2>&1
|
||||
register: contract_deploy_output
|
||||
ignore_errors: yes
|
||||
retries: 3
|
||||
delay: 53
|
||||
until: '"ONCHAIN EXECUTION COMPLETE & SUCCESSFUL" in contract_deploy_output.stdout'
|
||||
args:
|
||||
chdir: "{{ ansible_env.HOME }}/ritual"
|
||||
retries: 2
|
||||
delay: 60
|
||||
failed_when: '"ONCHAIN EXECUTION COMPLETE & SUCCESSFUL" not in contract_deploy_output.stdout'
|
||||
|
||||
- name: Update CallContract.s.sol with contract address
|
||||
shell: |
|
||||
cd ~/ritual-says-gm
|
||||
ansible.builtin.shell: |
|
||||
contract_address=$(jq -r '.transactions[0].contractAddress' projects/hello-world/contracts/broadcast/Deploy.s.sol/8453/run-latest.json)
|
||||
checksum_address=$(python3 toChecksumAddress.py $contract_address)
|
||||
sed -i "s/SaysGM(.*/SaysGM($checksum_address);/" projects/hello-world/contracts/script/CallContract.s.sol
|
||||
args:
|
||||
chdir: "{{ ansible_env.HOME }}/ritual"
|
||||
|
||||
- name: Call contract
|
||||
shell: cd ~/ritual-says-gm && project=hello-world make call-contract 2>&1
|
||||
register: contract_output
|
||||
ignore_errors: yes
|
||||
retries: 3
|
||||
delay: 55
|
||||
until: '"ONCHAIN EXECUTION COMPLETE & SUCCESSFUL" in contract_output.stdout'
|
||||
ansible.builtin.shell: project=hello-world make call-contract 2>&1
|
||||
register: contract_call_output
|
||||
args:
|
||||
chdir: "{{ ansible_env.HOME }}/ritual"
|
||||
retries: 2
|
||||
delay: 60
|
||||
failed_when: '"ONCHAIN EXECUTION COMPLETE & SUCCESSFUL" not in contract_call_output.stdout'
|
||||
|
||||
- name: Set Docker containers to restart unless stopped
|
||||
shell: |
|
||||
ansible.builtin.shell: |
|
||||
docker update --restart unless-stopped hello-world
|
||||
docker update --restart unless-stopped infernet-node
|
||||
docker update --restart unless-stopped deploy-redis-1
|
||||
docker update --restart unless-stopped infernet-anvil
|
||||
docker update --restart unless-stopped deploy-fluentbit-1
|
||||
|
||||
- name: Create APT configuration file to assume yes
|
||||
copy:
|
||||
dest: /etc/apt/apt.conf.d/90forceyes
|
||||
content: |
|
||||
APT::Get::Assume-Yes "true";
|
||||
|
||||
- name: Set permissions on APT configuration file
|
||||
file:
|
||||
path: /etc/apt/apt.conf.d/90forceyes
|
||||
mode: '0644'
|
||||
|
||||
- name: Remove docker login credentials
|
||||
shell: rm -rf /root/.docker/config.json
|
||||
ignore_errors: yes
|
||||
ansible.builtin.shell: rm -rf /root/.docker/config.json
|
||||
|
@ -24,8 +24,8 @@
|
||||
},
|
||||
"forward_stats": true,
|
||||
"snapshot_sync": {
|
||||
"sleep": 2,
|
||||
"batch_size": 10000,
|
||||
"sleep": 3,
|
||||
"batch_size": 1800,
|
||||
"starting_sub_id": 100000
|
||||
},
|
||||
"containers": [
|
||||
|
Reference in New Issue
Block a user