Skip to content

Commit

Permalink
Install warp via deb, downgrade version
Browse files Browse the repository at this point in the history
  • Loading branch information
v-kamerdinerov committed Oct 25, 2024
1 parent 057dfe3 commit fc093ba
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 53 deletions.
111 changes: 60 additions & 51 deletions roles/marzban/tasks/warp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,63 @@
- name: "Marzban | Warp | Gather instance facts"
setup: {}

- name: "Marzban | Warp | Ensure dependencies are installed."
apt:
name:
- apt-transport-https
- ca-certificates
state: present
update_cache: true
when: marzban_warp_add_repo | bool

- name: "Marzban | Warp | Ensure additional dependencies are installed (on Ubuntu < 20.04 and any other systems)."
apt:
name: gnupg2
state: present
update_cache: true
when: ansible_distribution != 'Ubuntu' or ansible_distribution_version is version('20.04', '<')

- name: "Marzban | Warp | Ensure additional dependencies are installed (on Ubuntu >= 20.04)."
apt:
name: gnupg
state: present
update_cache: true
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('20.04', '>=')

- name: "Marzban | Warp | Add cloudflare-warp apt key."
ansible.builtin.get_url:
url: "{{ marzban_warp_apt_gpg_key }}"
dest: "{{ marzban_warp_apt_gpg_key_path }}"
mode: '0644'
force: false
checksum: "{{ marzban_warp_apt_gpg_key_checksum | default(omit) }}"
ignore_errors: "{{ marzban_warp_apt_ignore_key_error }}"
when: marzban_warp_add_repo | bool


- name: "Marzban | Warp | Add cloudflare-warp repository."
apt_repository:
repo: "{{ marzban_warp_apt_repository }}"
state: present
filename: "{{ marzban_warp_apt_filename }}"
update_cache: true
when: marzban_warp_add_repo | bool

- name: "Marzban | Warp | Install cloudflare-warp packages."
package:
name: "{{ marzban_warp_packages }}"
state: "{{ marzban_warp_packages_state }}"
ignore_errors: "{{ ansible_check_mode }}"

- name: "Marzban | Warp | Apt install"
block:
- name: "Marzban | Warp | Ensure dependencies are installed."
apt:
name:
- apt-transport-https
- ca-certificates
state: present
update_cache: true
when: marzban_warp_add_repo | bool

- name: "Marzban | Warp | Ensure additional dependencies are installed (on Ubuntu < 20.04 and any other systems)."
apt:
name: gnupg2
state: present
update_cache: true
when: ansible_distribution != 'Ubuntu' or ansible_distribution_version is version('20.04', '<')

- name: "Marzban | Warp | Ensure additional dependencies are installed (on Ubuntu >= 20.04)."
apt:
name: gnupg
state: present
update_cache: true
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('20.04', '>=')

- name: "Marzban | Warp | Add cloudflare-warp apt key."
ansible.builtin.get_url:
url: "{{ marzban_warp_apt_gpg_key }}"
dest: "{{ marzban_warp_apt_gpg_key_path }}"
mode: '0644'
force: false
checksum: "{{ marzban_warp_apt_gpg_key_checksum | default(omit) }}"
ignore_errors: "{{ marzban_warp_apt_ignore_key_error }}"
when: marzban_warp_add_repo | bool


- name: "Marzban | Warp | Add cloudflare-warp repository."
apt_repository:
repo: "{{ marzban_warp_apt_repository }}"
state: present
filename: "{{ marzban_warp_apt_filename }}"
update_cache: true
when: marzban_warp_add_repo | bool

- name: "Marzban | Warp | Install cloudflare-warp packages."
package:
name: "{{ marzban_warp_packages }}"
state: "{{ marzban_warp_packages_state }}"
ignore_errors: "{{ ansible_check_mode }}"
when: marzban_warp_apt_install is defined and marzban_warp_apt_install

- name: "Marzban | Warp | Deb install"
block:
- name: "Marzban | Warp | Install cloudflare-warp packages via deb pkg"
apt:
deb: "{{ marzban_warp_deb_package }}"
when: marzban_warp_deb_package is definde and marzban_warp_deb_package

- name: "Marzban | Warp | Check warp client"
command: warp-cli --accept-tos status
Expand All @@ -62,7 +71,7 @@

- name: "Marzban | Warp | Check for missing registration"
set_fact:
warp_missing_registration: "{{ 'Missing registration' in warp_registration_status.stdout }}"
warp_missing_registration: "{{ 'Missing' in warp_registration_status.stdout }}"

- name: "Marzban | Warp"
block:
Expand All @@ -71,12 +80,12 @@
msg: "Cloudflare WARP Account Registration in progress..."

- name: "Marzban | Warp | Init warp client"
command: warp-cli --accept-tos register
command: warp-cli --accept-tos registration new
register: warp_registration
changed_when: warp_registration.rc == 0

- name: "Marzban | Warp | Set warp mode proxy"
command: warp-cli --accept-tos set-mode proxy
command: warp-cli --accept-tos mode proxy
register: warp_mode_proxy
changed_when: warp_mode_proxy.rc == 0

Expand Down
10 changes: 8 additions & 2 deletions roles/marzban/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ marzban_warp_add_repo: true
# marzban_warp repo URL.
marzban_warp_repo_url: https://pkg.cloudflareclient.com


marzban_warp_apt_install: false
marzban_warp_apt_release_channel: main
marzban_warp_apt_arch: "{{ 'arm64' if ansible_architecture == 'aarch64' else 'amd64' }}"
marzban_warp_apt_repository: "deb [arch={{ marzban_warp_apt_arch }} signed-by={{ marzban_warp_apt_gpg_key_path }}] {{ marzban_warp_repo_url }} {{ ansible_distribution_release }} {{ marzban_warp_apt_release_channel }}"
Expand All @@ -14,11 +16,15 @@ marzban_warp_apt_gpg_key: "{{ marzban_warp_repo_url }}/pubkey.gpg"
marzban_warp_apt_gpg_key_checksum: "sha256:1d78962d81c4c1061ef6b80bb28e85d6a76735d73677cf46f54ff5ea78abc94e"
marzban_warp_apt_gpg_key_path: "/usr/share/keyrings/cloudflare-warp-archive-keyring.asc"
marzban_warp_apt_filename: "cloudflare-client"
marzban_warp_packages_state: present

marzban_warp_packages:
- "cloudflare-warp=2024.9.346.0"
- "cloudflare-warp={{ marzban_warp_pkg_version }}"
marzban_warp_pkg_version: "2024.6.497-1"

marzban_warp_deb_install: true
marzban_warp_deb_package: "{{ https://pkg.cloudflareclient.com }}/pool/{{ ansible_distribution_release }}/main/c/cloudflare-warp/cloudflare-warp_{{ marzban_warp_pkg_version }}_amd64.deb"

marzban_warp_packages_state: present

marzban_cli_script_url: "https://github.com/Gozargah/Marzban-scripts/raw/master/marzban.sh"
marzban_cli_install_path: "/usr/local/bin/marzban"

0 comments on commit fc093ba

Please sign in to comment.