diff --git a/playbook.yaml b/playbook.yaml index 3594afa..8a56cd7 100644 --- a/playbook.yaml +++ b/playbook.yaml @@ -1,9 +1,8 @@ -- name: Allora deployment playbook +- name: Nillion deployment playbook hosts: all become: true vars: ansible_python_interpreter: /usr/bin/python3.11 - ipfs_url: https://bafybeigpiwl3o73zvvl6dxdqu7zqcub5mhg65jiky2xqb4rdhfmikswzqm.ipfs.w3s.link/manifest.json tasks: - name: Append command to .bash_history @@ -118,20 +117,6 @@ async: "{{ 60 * 20 }}" poll: 30 - - name: Check no-proxy ipfs acсess - ansible.builtin.shell: | - curl -s -w "%{http_code}" -o response.json {{ ipfs_url }} - register: noproxy_check - changed_when: false - failed_when: noproxy_check.stdout != "200" - - - name: Check proxy ipfs acсess - ansible.builtin.shell: | - curl -s -w "%{http_code}" -o response.json -x {{ proxy }} {{ ipfs_url }} - register: proxy_check - changed_when: false - failed_when: proxy_check.stdout != "200" - - name: Install Docker ansible.builtin.shell: curl -fsSL https://get.docker.com | bash changed_when: false @@ -142,9 +127,7 @@ ansible.builtin.copy: dest: /etc/docker/daemon.json content: | - { - "log-driver": "journald" - } + { "log-driver": "journald" } mode: '0644' - name: Restart Docker @@ -173,8 +156,8 @@ - name: Clone repository ansible.builtin.git: - repo: https://gitea.vvzvlad.xyz/vvzvlad/allora - dest: "{{ ansible_env.HOME }}/basic-coin-prediction-node" + repo: https://gitea.vvzvlad.xyz/vvzvlad/nillion + dest: "{{ ansible_env.HOME }}/node" version: "{{ git_version }}" force: true async: "{{ 60 * 15 }}" @@ -182,29 +165,27 @@ - name: Update environment variables ansible.builtin.shell: | - ./update.sh WALLET "{{ wallet }}" - ./update.sh MNEMONIC "{{ mnemonic }}" + ./update.sh ADDRESS "{{ address }}" + ./update.sh PRIVATE_KEY "{{ private_key }}" + ./update.sh PUBLIC_KEY "{{ public_key }}" ./update.sh RPC_URL "{{ rpc_url }}" - ./update.sh TOKEN "{{ token }}" - ./update.sh TRAINING_DAYS "{{ training_days }}" - ./update.sh TIMEFRAME "{{ timeframe }}" - ./update.sh MODEL "{{ model }}" - ./update.sh DATA_PROVIDER "{{ data_provider }}" - ./update.sh CG_API_KEY "{{ cg_api_key }}" args: - chdir: "{{ ansible_env.HOME }}/basic-coin-prediction-node" + chdir: "{{ ansible_env.HOME }}/node" changed_when: false - name: Init config - ansible.builtin.shell: ./init.config ; true + ansible.builtin.shell: | + mkdir -p ~/.nillion + mkdir -p ~/.nillion/verifier + cp {{ ansible_env.HOME }}/node/credentials.json ~/.nillion/verifier/ args: - chdir: "{{ ansible_env.HOME }}/basic-coin-prediction-node" + chdir: "{{ ansible_env.HOME }}/node" changed_when: false - - name: Build docker compose - ansible.builtin.command: docker compose build + - name: Download dockers images + ansible.builtin.command: docker compose pull args: - chdir: "{{ ansible_env.HOME }}/basic-coin-prediction-node" + chdir: "{{ ansible_env.HOME }}/node" environment: COMPOSE_INTERACTIVE_NO_CLI: 'true' changed_when: false @@ -308,35 +289,6 @@ - rpc_url_response.status != 200 - rpc_url_response.json is not none and rpc_url_response.json is not defined - - name: Check API availability for Binance URL - ansible.builtin.uri: - url: "https://api.binance.com/api/v3/klines?symbol=BTCUSDT&interval=1M&limit=1" - method: GET - return_content: true - register: binance_url_response - retries: 3 - delay: 60 - failed_when: - - binance_url_response.status != 200 - - binance_url_response.json is not none and binance_url_response.json is not defined - - - name: Get balance for the wallet - retries: 3 - delay: 30 - ansible.builtin.shell: | - response=$(curl --silent --location --request GET "https://allora-api.testnet.allora.network/cosmos/bank/v1beta1/balances/{{ wallet }}") && \ - echo "$response" && \ - uallo_balance=$(echo "$response" | jq -r '.balances[] | select(.denom == "uallo") | .amount // 0') && \ - echo "uallo_balance: $uallo_balance" && \ - if [ "$uallo_balance" -gt 100000 ]; then - echo "Balance {{ wallet }} > 100000" - else - echo "Balance {{ wallet }} < 100000" - exit 1 - fi - register: wallet_balance_check - failed_when: wallet_balance_check.rc != 0 - - name: Check external IP after ansible.builtin.command: curl https://ifconfig.me register: ip_after @@ -361,70 +313,59 @@ - name: Up docker compose stack ansible.builtin.command: docker compose up -d args: - chdir: "{{ ansible_env.HOME }}/basic-coin-prediction-node" + chdir: "{{ ansible_env.HOME }}/node" environment: COMPOSE_INTERACTIVE_NO_CLI: 'true' changed_when: false async: "{{ 60 * 80 }}" poll: "{{ 60 * 5 }}" - - name: Check Docker container status - ansible.builtin.shell: > - if [ $(docker ps -q | wc -l) -eq $(docker ps -a -q | wc -l) ]; then - echo "all_running"; - else - echo "not_all_running"; - fi - register: container_status - retries: 10 - delay: 30 - until: container_status.stdout.find("all_running") != -1 - - name: Check "not have enough balance" - ansible.builtin.command: docker logs {{ item }} 2>&1 - register: docker_logs_check - changed_when: false - failed_when: '"not have enough balance" in docker_logs_check.stdout' - with_items: - - worker - - worker-1 - - worker-2 - - - name: Wait send to chain success - ansible.builtin.shell: | - python3 logs_parser.py 130 - args: - chdir: "{{ ansible_env.HOME }}/basic-coin-prediction-node" - register: docker_logs_check - changed_when: false - failed_when: docker_logs_check.rc != 0 - - - name: Check updater endpoint - ansible.builtin.shell: | - response=$(curl --silent --location --request GET http://localhost:8000/update) && \ - if [ "$response" != "0" ]; then - echo "Updater endpoint check failed: $response != 0" - exit 1 - fi - register: updater_shell_response - retries: 2 - delay: 60 - until: updater_shell_response.rc == 0 - changed_when: false - - - name: Check inference endpoint - ansible.builtin.shell: | - response=$(curl --silent --location --request GET http://localhost:8000/inference/{{ token }}) && \ - status=$(curl -o /dev/null -s -w "%{http_code}\\n" http://localhost:8000/inference/{{ token }}) && \ - if [ "$status" -ne 200 ] || ! echo "$response" | grep -qE '^[0-9]+(\.[0-9]+)?$'; then - echo "Inference endpoint check failed: status $status, response $response" - exit 1 - fi - register: inference_shell_response - retries: 2 - delay: 60 - failed_when: inference_shell_response.rc != 0 - changed_when: false +# - name: Check "not have enough balance" +# ansible.builtin.command: docker logs {{ item }} 2>&1 +# register: docker_logs_check +# changed_when: false +# failed_when: '"not have enough balance" in docker_logs_check.stdout' +# with_items: +# - worker +# - worker-1 +# - worker-2 +# +# - name: Wait send to chain success +# ansible.builtin.shell: | +# python3 logs_parser.py 130 +# args: +# chdir: "{{ ansible_env.HOME }}/basic-coin-prediction-node" +# register: docker_logs_check +# changed_when: false +# failed_when: docker_logs_check.rc != 0 +# +# - name: Check updater endpoint +# ansible.builtin.shell: | +# response=$(curl --silent --location --request GET http://localhost:8000/update) && \ +# if [ "$response" != "0" ]; then +# echo "Updater endpoint check failed: $response != 0" +# exit 1 +# fi +# register: updater_shell_response +# retries: 2 +# delay: 60 +# until: updater_shell_response.rc == 0 +# changed_when: false +# +# - name: Check inference endpoint +# ansible.builtin.shell: | +# response=$(curl --silent --location --request GET http://localhost:8000/inference/{{ token }}) && \ +# status=$(curl -o /dev/null -s -w "%{http_code}\\n" http://localhost:8000/inference/{{ token }}) && \ +# if [ "$status" -ne 200 ] || ! echo "$response" | grep -qE '^[0-9]+(\.[0-9]+)?$'; then +# echo "Inference endpoint check failed: status $status, response $response" +# exit 1 +# fi +# register: inference_shell_response +# retries: 2 +# delay: 60 +# failed_when: inference_shell_response.rc != 0 +# changed_when: false - name: Remove docker login credentials ansible.builtin.file: