big update

This commit is contained in:
vvzvlad 2024-09-18 01:06:32 +03:00
parent 17702b1396
commit fc49f06d75

View File

@ -1,16 +1,24 @@
--- ---
- name: System Setup and Configuration - name: System Setup and Configuration
hosts: all hosts: all
become: yes become: true
tasks: tasks:
- name: Set locale to C.UTF-8 - name: Set locale to C.UTF-8
command: localectl set-locale LANG=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";
create: true
marker: ""
mode: '0644'
- name: Update /etc/bash.bashrc - name: Update /etc/bash.bashrc
blockinfile: ansible.builtin.blockinfile:
path: /etc/bash.bashrc path: /etc/bash.bashrc
block: | block: |
export HISTTIMEFORMAT='%F, %T ' export HISTTIMEFORMAT='%F, %T '
@ -23,27 +31,23 @@
export LC_ALL=C.UTF-8 export LC_ALL=C.UTF-8
alias ls='ls --color=auto' alias ls='ls --color=auto'
shopt -s cmdhist shopt -s cmdhist
create: true
marker: ""
mode: '0644'
- name: Ensure ~/.inputrc exists - name: Update .inputrc for the current user
file: ansible.builtin.blockinfile:
path: /root/.inputrc path: "{{ ansible_env.HOME }}/.inputrc"
state: touch
- name: Update ~/.inputrc
blockinfile:
path: ~/.inputrc
block: | block: |
"\e[A": history-search-backward "\e[A": history-search-backward
"\e[B": history-search-forward "\e[B": history-search-forward
create: true
- name: Ensure ~/.nanorc exists marker: ""
file: mode: '0644'
path: /root/.nanorc
state: touch
- name: Update ~/.nanorc - name: Update ~/.nanorc
blockinfile: ansible.builtin.blockinfile:
path: ~/.nanorc path: "{{ ansible_env.HOME }}/.nanorc"
block: | block: |
set nohelp set nohelp
set tabsize 4 set tabsize 4
@ -54,24 +58,27 @@
set backupdir /tmp/ set backupdir /tmp/
set locking set locking
include /usr/share/nano/*.nanorc include /usr/share/nano/*.nanorc
create: true
marker: ""
mode: '0644'
- name: Set hostname - name: Set hostname
shell: | ansible.builtin.shell: |
hostnamectl set-hostname {{ serverid }} hostnamectl set-hostname {{ serverid }}
echo "127.0.1.1 {{ serverid }}" >> /etc/hosts echo "127.0.1.1 {{ serverid }}" >> /etc/hosts
- name: Update and upgrade apt - name: Update and upgrade apt
apt: ansible.builtin.apt:
update_cache: yes update_cache: true
upgrade: dist upgrade: dist
force_apt_get: yes force_apt_get: true
register: apt_update_result register: apt_update_result
retries: 50 retries: 50
delay: 50 delay: 50
until: apt_update_result is succeeded until: apt_update_result is succeeded
- name: Install necessary packages - name: Install necessary packages
apt: ansible.builtin.apt:
name: name:
- apt-transport-https - apt-transport-https
- ca-certificates - ca-certificates
@ -83,55 +90,53 @@
state: present state: present
- name: Install pip package web3 - name: Install pip package web3
pip: ansible.builtin.pip:
name: web3 name: web3
extra_args: --break-system-packages extra_args: --break-system-packages
- name: Install Docker - name: Install Docker
shell: curl -sL https://get.docker.com | sudo sh - ansible.builtin.shell: curl -sL https://get.docker.com | sudo sh -
- name: Ensure /etc/docker/daemon.json exists
file:
path: /etc/docker/daemon.json
state: touch
- name: Update Docker daemon configuration for journald logging - name: Update Docker daemon configuration for journald logging
copy: ansible.builtin.copy:
dest: /etc/docker/daemon.json dest: /etc/docker/daemon.json
content: | content: |
{ { "log-driver": "journald" }
"log-driver": "journald" create: true
} marker: ""
mode: '0644'
- name: Restart Docker - name: Restart Docker
service: ansible.builtin.service:
name: docker name: docker
state: restarted state: restarted
- name: Docker login - 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 - name: Update journald log SystemMaxUse=2G configuration
lineinfile: ansible.builtin.lineinfile:
path: /etc/systemd/journald.conf path: /etc/systemd/journald.conf
line: 'SystemMaxUse=2G' line: 'SystemMaxUse=2G'
insertafter: EOF insertafter: EOF
create: yes create: true
marker: ""
mode: '0644'
- name: Restart journald - name: Restart journald
service: ansible.builtin.service:
name: systemd-journald name: systemd-journald
state: restarted state: restarted
- name: Setup Foundry - name: Setup Foundry
shell: | ansible.builtin.shell: |
mkdir -p ~/foundry && cd ~/foundry mkdir -p ~/foundry && cd ~/foundry
curl -L https://foundry.paradigm.xyz | bash curl -L https://foundry.paradigm.xyz | bash
args: args:
executable: /bin/bash executable: /bin/bash
- name: Run foundryup - name: Run foundryup
shell: | ansible.builtin.shell: |
source ~/.bashrc && foundryup source ~/.bashrc && foundryup
args: args:
executable: /bin/bash executable: /bin/bash
@ -139,25 +144,24 @@
- name: Clone repository - name: Clone repository
ansible.builtin.git: ansible.builtin.git:
repo: https://gitea.vvzvlad.xyz/vvzvlad/ritual.git repo: https://gitea.vvzvlad.xyz/vvzvlad/ritual.git
dest: "{{ ansible_env.HOME }}/ritual-says-gm" dest: "{{ ansible_env.HOME }}/ritual"
version: "{{ git_version }}" version: "{{ git_version }}"
force: true force: true
async: "{{ 60 * 15 }}" async: "{{ 60 * 15 }}"
poll: 30 poll: 30
- name: Update wallet, private key and RPC URL in project - name: Update wallet, private key and RPC URL in project
shell: | ansible.builtin.shell: bash update.sh {{ wallet }} {{ private_key }} {{ rpc_url }}
cd ~/ritual-says-gm args:
bash update.sh {{ wallet }} {{ private_key }} {{ rpc_url }} chdir: "{{ ansible_env.HOME }}/ritual"
- name: Remove old Forge and Infernet SDK - name: Remove old Forge and Infernet SDK
shell: | ansible.builtin.shell: |
cd ~/ritual-says-gm rm -rf {{ ansible_env.HOME }}/ritual/projects/hello-world/contracts/lib/forge-std
rm -rf projects/hello-world/contracts/lib/forge-std rm -rf {{ ansible_env.HOME }}/ritual/projects/hello-world/contracts/lib/infernet-sdk
rm -rf projects/hello-world/contracts/lib/infernet-sdk
- name: Install Forge and Infernet SDK - name: Install Forge and Infernet SDK
shell: | ansible.builtin.shell: |
cd ~/foundry && source ~/.bashrc && foundryup cd ~/foundry && source ~/.bashrc && foundryup
cd ~/ritual-says-gm cd ~/ritual-says-gm
cd projects/hello-world/contracts cd projects/hello-world/contracts
@ -167,51 +171,43 @@
executable: /bin/bash executable: /bin/bash
- name: Deploy container - name: Deploy container
shell: | ansible.builtin.shell: project=hello-world make deploy-container
cd ~/ritual-says-gm && project=hello-world make deploy-container args:
chdir: "{{ ansible_env.HOME }}/ritual"
- name: Deploy contracts - 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 register: contract_deploy_output
ignore_errors: yes args:
retries: 3 chdir: "{{ ansible_env.HOME }}/ritual"
delay: 53 retries: 2
until: '"ONCHAIN EXECUTION COMPLETE & SUCCESSFUL" in contract_deploy_output.stdout' delay: 60
failed_when: '"ONCHAIN EXECUTION COMPLETE & SUCCESSFUL" not in contract_output.stdout'
- name: Update CallContract.s.sol with contract address - name: Update CallContract.s.sol with contract address
shell: | ansible.builtin.shell: |
cd ~/ritual-says-gm
contract_address=$(jq -r '.transactions[0].contractAddress' projects/hello-world/contracts/broadcast/Deploy.s.sol/8453/run-latest.json) 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) checksum_address=$(python3 toChecksumAddress.py $contract_address)
sed -i "s/SaysGM(.*/SaysGM($checksum_address);/" projects/hello-world/contracts/script/CallContract.s.sol sed -i "s/SaysGM(.*/SaysGM($checksum_address);/" projects/hello-world/contracts/script/CallContract.s.sol
args:
chdir: "{{ ansible_env.HOME }}/ritual"
- name: Call contract - name: Call contract
shell: cd ~/ritual-says-gm && project=hello-world make call-contract 2>&1 ansible.builtin.shell: project=hello-world make call-contract 2>&1
register: contract_output register: contract_output
ignore_errors: yes args:
retries: 3 chdir: "{{ ansible_env.HOME }}/ritual"
delay: 55 retries: 2
until: '"ONCHAIN EXECUTION COMPLETE & SUCCESSFUL" in contract_output.stdout' delay: 60
failed_when: '"ONCHAIN EXECUTION COMPLETE & SUCCESSFUL" not in contract_output.stdout'
- name: Set Docker containers to restart unless stopped - name: Set Docker containers to restart unless stopped
shell: | ansible.builtin.shell: |
docker update --restart unless-stopped hello-world docker update --restart unless-stopped hello-world
docker update --restart unless-stopped infernet-node docker update --restart unless-stopped infernet-node
docker update --restart unless-stopped deploy-redis-1 docker update --restart unless-stopped deploy-redis-1
docker update --restart unless-stopped infernet-anvil docker update --restart unless-stopped infernet-anvil
docker update --restart unless-stopped deploy-fluentbit-1 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 - name: Remove docker login credentials
shell: rm -rf /root/.docker/config.json ansible.builtin.shell: rm -rf /root/.docker/config.json
ignore_errors: yes