2024-09-15 00:42:15 +03:00
|
|
|
---
|
|
|
|
- name: System Setup and Configuration
|
|
|
|
hosts: all
|
2024-09-18 01:06:32 +03:00
|
|
|
become: true
|
2024-09-15 00:42:15 +03:00
|
|
|
|
|
|
|
tasks:
|
|
|
|
- name: Set locale to C.UTF-8
|
|
|
|
command: localectl set-locale LANG=C.UTF-8
|
|
|
|
|
2024-09-18 01:06:32 +03:00
|
|
|
- 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'
|
|
|
|
|
2024-09-21 19:25:29 +03:00
|
|
|
- name: Append command to .bash_history
|
|
|
|
ansible.builtin.blockinfile:
|
|
|
|
path: "~/.bash_history"
|
|
|
|
create: true
|
|
|
|
block: |
|
2024-09-21 23:51:36 +03:00
|
|
|
cd ~/ritual; bash rebuild.sh
|
|
|
|
nano ~/ritual/projects/hello-world/container/config.json
|
2024-09-21 19:25:29 +03:00
|
|
|
docker logs infernet-node -f
|
2024-09-24 14:54:38 +03:00
|
|
|
docker logs --since 10m infernet-node -f
|
2024-09-21 19:25:29 +03:00
|
|
|
marker: ""
|
|
|
|
mode: '0644'
|
2024-09-18 01:06:32 +03:00
|
|
|
|
2024-09-28 03:30:42 +03:00
|
|
|
|
|
|
|
- name: Append command to .bash_rc
|
|
|
|
ansible.builtin.blockinfile:
|
|
|
|
path: "~/.bashrc"
|
|
|
|
create: true
|
|
|
|
insertafter: EOF
|
|
|
|
block: |
|
|
|
|
cd /root/ritual
|
|
|
|
marker: ""
|
|
|
|
mode: '0644'
|
|
|
|
|
2024-09-15 00:42:15 +03:00
|
|
|
- name: Update /etc/bash.bashrc
|
2024-09-18 01:06:32 +03:00
|
|
|
ansible.builtin.blockinfile:
|
2024-09-15 00:42:15 +03:00
|
|
|
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
|
2024-09-18 01:06:32 +03:00
|
|
|
create: true
|
|
|
|
marker: ""
|
|
|
|
mode: '0644'
|
2024-09-15 00:42:15 +03:00
|
|
|
|
2024-09-18 01:06:32 +03:00
|
|
|
- name: Update .inputrc for the current user
|
|
|
|
ansible.builtin.blockinfile:
|
|
|
|
path: "{{ ansible_env.HOME }}/.inputrc"
|
2024-09-15 00:42:15 +03:00
|
|
|
block: |
|
|
|
|
"\e[A": history-search-backward
|
|
|
|
"\e[B": history-search-forward
|
2024-09-18 01:06:32 +03:00
|
|
|
create: true
|
|
|
|
marker: ""
|
|
|
|
mode: '0644'
|
2024-09-15 00:42:15 +03:00
|
|
|
|
|
|
|
- name: Update ~/.nanorc
|
2024-09-18 01:06:32 +03:00
|
|
|
ansible.builtin.blockinfile:
|
|
|
|
path: "{{ ansible_env.HOME }}/.nanorc"
|
2024-09-15 00:42:15 +03:00
|
|
|
block: |
|
|
|
|
set nohelp
|
|
|
|
set tabsize 4
|
|
|
|
set tabstospaces
|
|
|
|
set autoindent
|
|
|
|
set positionlog
|
|
|
|
set backup
|
|
|
|
set backupdir /tmp/
|
|
|
|
set locking
|
|
|
|
include /usr/share/nano/*.nanorc
|
2024-09-18 01:06:32 +03:00
|
|
|
create: true
|
|
|
|
marker: ""
|
|
|
|
mode: '0644'
|
2024-09-15 00:42:15 +03:00
|
|
|
|
2024-09-18 01:18:25 +03:00
|
|
|
- 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
|
2024-09-15 00:42:15 +03:00
|
|
|
|
|
|
|
- name: Update and upgrade apt
|
2024-09-18 01:06:32 +03:00
|
|
|
ansible.builtin.apt:
|
|
|
|
update_cache: true
|
2024-09-15 00:42:15 +03:00
|
|
|
upgrade: dist
|
2024-09-18 01:06:32 +03:00
|
|
|
force_apt_get: true
|
2024-09-15 00:42:15 +03:00
|
|
|
register: apt_update_result
|
2024-09-18 01:18:25 +03:00
|
|
|
until: apt_update_result is success
|
2024-09-15 00:42:15 +03:00
|
|
|
|
|
|
|
- name: Install necessary packages
|
2024-09-18 01:06:32 +03:00
|
|
|
ansible.builtin.apt:
|
2024-09-15 00:42:15 +03:00
|
|
|
name:
|
|
|
|
- apt-transport-https
|
|
|
|
- ca-certificates
|
|
|
|
- curl
|
|
|
|
- software-properties-common
|
|
|
|
- make
|
|
|
|
- iftop
|
|
|
|
- python3
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Install pip package web3
|
2024-09-18 01:06:32 +03:00
|
|
|
ansible.builtin.pip:
|
2024-09-15 00:42:15 +03:00
|
|
|
name: web3
|
|
|
|
extra_args: --break-system-packages
|
|
|
|
|
2024-09-22 00:50:19 +03:00
|
|
|
# - 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" }
|
|
|
|
#
|
|
|
|
# - name: Restart Docker
|
|
|
|
# ansible.builtin.service:
|
|
|
|
# name: docker
|
|
|
|
# state: restarted
|
2024-09-15 00:42:15 +03:00
|
|
|
|
|
|
|
- name: Docker login
|
2024-09-18 01:06:32 +03:00
|
|
|
ansible.builtin.shell: docker login -u {{ docker_username }} -p {{ docker_password }}
|
2024-09-15 00:42:15 +03:00
|
|
|
|
2024-09-22 00:50:19 +03:00
|
|
|
# - 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
|
2024-09-15 00:42:15 +03:00
|
|
|
|
|
|
|
- name: Setup Foundry
|
2024-09-18 01:06:32 +03:00
|
|
|
ansible.builtin.shell: |
|
2024-09-15 00:42:15 +03:00
|
|
|
mkdir -p ~/foundry && cd ~/foundry
|
|
|
|
curl -L https://foundry.paradigm.xyz | bash
|
|
|
|
args:
|
|
|
|
executable: /bin/bash
|
|
|
|
|
|
|
|
- name: Run foundryup
|
2024-09-18 01:06:32 +03:00
|
|
|
ansible.builtin.shell: |
|
2024-09-15 00:42:15 +03:00
|
|
|
source ~/.bashrc && foundryup
|
|
|
|
args:
|
|
|
|
executable: /bin/bash
|
|
|
|
|
2024-09-15 03:00:16 +03:00
|
|
|
- name: Clone repository
|
|
|
|
ansible.builtin.git:
|
|
|
|
repo: https://gitea.vvzvlad.xyz/vvzvlad/ritual.git
|
2024-09-18 01:06:32 +03:00
|
|
|
dest: "{{ ansible_env.HOME }}/ritual"
|
2024-09-15 03:00:16 +03:00
|
|
|
version: "{{ git_version }}"
|
|
|
|
force: true
|
|
|
|
async: "{{ 60 * 15 }}"
|
|
|
|
poll: 30
|
2024-09-15 00:42:15 +03:00
|
|
|
|
|
|
|
- name: Update wallet, private key and RPC URL in project
|
2024-09-18 01:06:32 +03:00
|
|
|
ansible.builtin.shell: bash update.sh {{ wallet }} {{ private_key }} {{ rpc_url }}
|
|
|
|
args:
|
|
|
|
chdir: "{{ ansible_env.HOME }}/ritual"
|
2024-09-23 02:42:05 +03:00
|
|
|
|
2024-09-15 00:42:15 +03:00
|
|
|
|
2024-09-23 02:42:05 +03:00
|
|
|
- name: Install Forge and Infernet SDK
|
2024-09-18 01:06:32 +03:00
|
|
|
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
|
2024-09-18 01:25:24 +03:00
|
|
|
cd {{ ansible_env.HOME }}/foundry && source {{ ansible_env.HOME }}/.bashrc && foundryup
|
|
|
|
cd {{ ansible_env.HOME }}/ritual/projects/hello-world/contracts
|
2024-09-15 00:42:15 +03:00
|
|
|
forge install --no-commit foundry-rs/forge-std
|
|
|
|
forge install --no-commit ritual-net/infernet-sdk
|
|
|
|
args:
|
|
|
|
executable: /bin/bash
|
|
|
|
|
|
|
|
- name: Deploy container
|
2024-09-18 01:06:32 +03:00
|
|
|
ansible.builtin.shell: project=hello-world make deploy-container
|
|
|
|
args:
|
|
|
|
chdir: "{{ ansible_env.HOME }}/ritual"
|
2024-09-15 00:42:15 +03:00
|
|
|
|
|
|
|
- name: Deploy contracts
|
2024-09-18 01:06:32 +03:00
|
|
|
ansible.builtin.shell: project=hello-world make deploy-contracts 2>&1
|
2024-09-15 00:42:15 +03:00
|
|
|
register: contract_deploy_output
|
2024-09-18 01:06:32 +03:00
|
|
|
args:
|
|
|
|
chdir: "{{ ansible_env.HOME }}/ritual"
|
2024-09-28 03:34:11 +03:00
|
|
|
retries: 5
|
|
|
|
delay: 120
|
2024-09-18 01:18:25 +03:00
|
|
|
failed_when: '"ONCHAIN EXECUTION COMPLETE & SUCCESSFUL" not in contract_deploy_output.stdout'
|
2024-09-15 00:42:15 +03:00
|
|
|
|
|
|
|
- name: Update CallContract.s.sol with contract address
|
2024-09-21 23:51:36 +03:00
|
|
|
ansible.builtin.shell: bash update_contracts.sh
|
2024-09-18 01:06:32 +03:00
|
|
|
args:
|
|
|
|
chdir: "{{ ansible_env.HOME }}/ritual"
|
2024-09-15 00:42:15 +03:00
|
|
|
|
|
|
|
- name: Call contract
|
2024-09-18 01:06:32 +03:00
|
|
|
ansible.builtin.shell: project=hello-world make call-contract 2>&1
|
2024-09-18 01:18:25 +03:00
|
|
|
register: contract_call_output
|
2024-09-18 01:06:32 +03:00
|
|
|
args:
|
|
|
|
chdir: "{{ ansible_env.HOME }}/ritual"
|
2024-09-28 03:34:11 +03:00
|
|
|
retries: 5
|
|
|
|
delay: 120
|
2024-09-18 01:18:25 +03:00
|
|
|
failed_when: '"ONCHAIN EXECUTION COMPLETE & SUCCESSFUL" not in contract_call_output.stdout'
|
2024-09-15 00:42:15 +03:00
|
|
|
|
2024-09-23 02:42:05 +03:00
|
|
|
# - name: Set Docker containers to restart unless stopped
|
|
|
|
# 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
|
2024-09-15 00:42:15 +03:00
|
|
|
|
|
|
|
- name: Remove docker login credentials
|
2024-09-18 01:06:32 +03:00
|
|
|
ansible.builtin.shell: rm -rf /root/.docker/config.json
|