diff --git a/depin/core/roles/metrics/default.yml b/depin/core/roles/metrics/default.yml new file mode 100644 index 00000000..51478ea9 --- /dev/null +++ b/depin/core/roles/metrics/default.yml @@ -0,0 +1,2 @@ +--- +xai_metrics_port: 33005 diff --git a/depin/core/roles/metrics/defaults/main.yml b/depin/core/roles/metrics/defaults/main.yml index 48769996..c2b54ef1 100644 --- a/depin/core/roles/metrics/defaults/main.yml +++ b/depin/core/roles/metrics/defaults/main.yml @@ -8,3 +8,4 @@ metrics_port: autonomi: 33002 hychain: 33003 storagechain: 33004 + xai: 33005 diff --git a/depin/services/roles/xai/defaults/main.yml b/depin/services/roles/xai/defaults/main.yml new file mode 100644 index 00000000..783fb609 --- /dev/null +++ b/depin/services/roles/xai/defaults/main.yml @@ -0,0 +1,14 @@ +--- +xai_cmd: "{{ depin_cmd | default('install') }}" +xai_version: 1.1.14 +xai_download_url: "https://github.com/xai-foundation/sentry/releases/latest/download/sentry-node-cli-linux.zip" +xai_install_path: "/opt/xai/{{ xai_version }}" +xai_node_count: 1 +xai_node_port: 8545 + +xai_programs: + - name: sentry-node-cli-linux + url: "{{ xai_download_url }}" + checksum: "" + install_path: "{{ xai_install_path }}" + symlink: /usr/local/bin/xai diff --git a/depin/services/roles/xai/tasks/commands/install.yml b/depin/services/roles/xai/tasks/commands/install.yml new file mode 100644 index 00000000..602f7740 --- /dev/null +++ b/depin/services/roles/xai/tasks/commands/install.yml @@ -0,0 +1,63 @@ +--- +- name: Install programs using core.installer + ansible.builtin.include_role: + name: depin.core.installer + vars: + programs: "{{ xai_programs }}" + +- name: Create program folder + become: true + ansible.builtin.file: + state: directory + owner: root + group: root + mode: '0755' + dest: "{{ item.install_path }}" + loop: "{{ xai_programs }}" + +- name: Download binary to tmp + become: true + ansible.builtin.unarchive: + remote_src: true + src: "{{ item.url }}" + dest: /tmp + loop: "{{ xai_programs }}" + failed_when: false + +- name: Find binary + become: true + ansible.builtin.find: + paths: + - /tmp + patterns: "{{ item.name }}" + use_regex: true + get_checksum: true + recurse: true + loop: "{{ xai_programs }}" + register: _downloads + +- name: Install node + become: true + block: + - name: Copy required files + ansible.builtin.copy: + remote_src: true + src: "{{ (_downloads.results[loop.index0]['files'] | first).path }}" + dest: "{{ item.install_path }}" + mode: '0755' + + - name: Symlink binary to path + become: true + ansible.builtin.file: + src: "{{ item.install_path }}/{{ item.name }}" + path: "{{ item.symlink }}" + mode: '0755' + owner: root + group: root + state: link + force: true + loop: "{{ xai_programs }}" + +- name: Start node + ansible.builtin.include_tasks: + file: commands/start.yml diff --git a/depin/services/roles/xai/tasks/commands/reset.yml b/depin/services/roles/xai/tasks/commands/reset.yml new file mode 100644 index 00000000..d967402b --- /dev/null +++ b/depin/services/roles/xai/tasks/commands/reset.yml @@ -0,0 +1,7 @@ +--- +- name: Uninstall + ansible.builtin.include_tasks: commands/uninstall.yml + +- name: Install + ansible.builtin.include_tasks: commands/install.yml + diff --git a/depin/services/roles/xai/tasks/commands/restart.yml b/depin/services/roles/xai/tasks/commands/restart.yml new file mode 100644 index 00000000..8705cfba --- /dev/null +++ b/depin/services/roles/xai/tasks/commands/restart.yml @@ -0,0 +1,7 @@ +--- +## stop and start service +- name: Stop + ansible.builtin.include_tasks: commands/stop.yml + +- name: Start + ansible.builtin.include_tasks: commands/start.yml diff --git a/depin/services/roles/xai/tasks/commands/start.yml b/depin/services/roles/xai/tasks/commands/start.yml new file mode 100644 index 00000000..f5b797f2 --- /dev/null +++ b/depin/services/roles/xai/tasks/commands/start.yml @@ -0,0 +1,2 @@ +--- + # Run the XAI Sentry Node CLI diff --git a/depin/services/roles/xai/tasks/commands/stop.yml b/depin/services/roles/xai/tasks/commands/stop.yml new file mode 100644 index 00000000..a4b8d07f --- /dev/null +++ b/depin/services/roles/xai/tasks/commands/stop.yml @@ -0,0 +1,2 @@ +--- +# Stop XAI Sentry Node service diff --git a/depin/services/roles/xai/tasks/commands/uninstall.yml b/depin/services/roles/xai/tasks/commands/uninstall.yml new file mode 100644 index 00000000..e5a622e4 --- /dev/null +++ b/depin/services/roles/xai/tasks/commands/uninstall.yml @@ -0,0 +1,16 @@ +--- +# Stop the service before uninstalling +- name: Disable systemd service + ansible.builtin.include_tasks: commands/stop.yml + +# Remove the binary file for XAI Sentry Node +- name: Remove XAI Sentry Node work directory + file: + path: /opt/xai + state: absent + +- name: Remove XAI Sentry Node binary + file: + path: /usr/local/bin/xai + state: absent + diff --git a/depin/services/roles/xai/tasks/main.yml b/depin/services/roles/xai/tasks/main.yml new file mode 100644 index 00000000..473d9c2f --- /dev/null +++ b/depin/services/roles/xai/tasks/main.yml @@ -0,0 +1,6 @@ +- name: XAI {{ xai_cmd }} + vars: + cmd_file: "{{ role_path }}/tasks/commands/{{ xai_cmd }}.yml" + when: cmd_file is file + ansible.builtin.include_tasks: + file: "{{ cmd_file }}" \ No newline at end of file