mirror of
https://github.com/jimeh/ansible-adguardhome.git
synced 2026-02-19 07:06:38 +00:00
feat: Add support for installing latest version
This works by looking up the latest GitHub release, and using the git tag of that release as the version.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
---
|
||||
adguardhome_version: '0.100.8'
|
||||
adguardhome_version: 'latest'
|
||||
adguardhome_user: root
|
||||
adguardhome_system_user: yes
|
||||
adguardhome_group: "{{ adguardhome_user }}"
|
||||
@@ -11,7 +11,7 @@ adguardhome_data_dir: "/opt/{{ adguardhome_service_name }}"
|
||||
adguardhome_tmp_dir: /tmp
|
||||
|
||||
adguardhome_bin_name: AdGuardHome
|
||||
adguardhome_config_name: config.yml
|
||||
adguardhome_config_name: AdGuardHome.yml
|
||||
|
||||
adguardhome_bin_file: "{{ adguardhome_bin_dir }}/{{ adguardhome_bin_name }}"
|
||||
adguardhome_config_file: "{{ adguardhome_config_dir }}/{{ adguardhome_config_name }}"
|
||||
@@ -19,4 +19,4 @@ adguardhome_unpack_dir: "{{ adguardhome_tmp_dir }}/AdGuardHome-{{ adguardhome_ve
|
||||
|
||||
adguardhome_arch: "{% if ansible_architecture == 'x86_64' %}amd64{% elif ansible_architecture == 'aarch64' %}arm64{% else %}arm{% endif %}"
|
||||
adguardhome_archive: "AdGuardHome_linux_{{ adguardhome_arch }}.tar.gz"
|
||||
adguardhome_download_url: "https://github.com/AdguardTeam/AdGuardHome/releases/download/v{{ adguardhome_version }}/{{ adguardhome_archive }}"
|
||||
adguardhome_download_url_base: "https://github.com/AdguardTeam/AdGuardHome/releases/download"
|
||||
|
||||
@@ -8,16 +8,19 @@ FROM {{ item.image }}
|
||||
|
||||
RUN if [ $(command -v apt-get) ]; then \
|
||||
apt-get update && \
|
||||
apt-get install -y python sudo bash ca-certificates net-tools && \
|
||||
apt-get install -y python python-pip sudo bash ca-certificates \
|
||||
net-tools && \
|
||||
apt-get clean; \
|
||||
elif [ $(command -v dnf) ]; then \
|
||||
dnf makecache && \
|
||||
dnf --assumeyes install \
|
||||
sudo python3 *python-devel python*-dnf bash net-tools && \
|
||||
sudo python3 python3-pip *python-devel python*-dnf bash \
|
||||
net-tools && \
|
||||
dnf clean all; \
|
||||
elif [ $(command -v yum) ]; then \
|
||||
yum makecache fast && \
|
||||
yum install -y python3 sudo yum-plugin-ovl bash net-tools && \
|
||||
yum install -y python3 python3-pip sudo yum-plugin-ovl bash \
|
||||
net-tools && \
|
||||
sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && \
|
||||
yum clean all; \
|
||||
elif [ $(command -v zypper) ]; then \
|
||||
|
||||
33
tasks/install.yml
Normal file
33
tasks/install.yml
Normal file
@@ -0,0 +1,33 @@
|
||||
---
|
||||
- name: Ensure bin directory exists
|
||||
file:
|
||||
dest: "{{ adguardhome_bin_dir }}"
|
||||
recurse: yes
|
||||
state: directory
|
||||
|
||||
- name: Create temporary directory
|
||||
file:
|
||||
dest: "{{ adguardhome_unpack_dir }}"
|
||||
recurse: yes
|
||||
state: directory
|
||||
|
||||
- name: "Download and extract archive (v{{ adguardhome_version }} / {{ adguardhome_arch }})"
|
||||
unarchive:
|
||||
src: "{{ adguardhome_download_url_base }}/v{{ adguardhome_version }}/{{ adguardhome_archive }}"
|
||||
dest: "{{ adguardhome_unpack_dir }}"
|
||||
remote_src: yes
|
||||
extra_opts:
|
||||
- "--strip-components=1"
|
||||
|
||||
- name: "Copy binary to {{ adguardhome_bin_dir }}/"
|
||||
copy:
|
||||
src: "{{ adguardhome_unpack_dir }}/{{ adguardhome_bin_name }}"
|
||||
dest: "{{ adguardhome_bin_file }}"
|
||||
mode: "755"
|
||||
remote_src: yes
|
||||
notify: restart adguardhome
|
||||
|
||||
- name: Remove temporary directory
|
||||
file:
|
||||
path: "{{ adguardhome_unpack_dir }}"
|
||||
state: absent
|
||||
12
tasks/latest_version.yml
Normal file
12
tasks/latest_version.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
- name: Lookup latest release
|
||||
github_release:
|
||||
action: latest_release
|
||||
user: AdguardTeam
|
||||
repo: Adguardhome
|
||||
register: adguardhome_latest_release
|
||||
|
||||
- name: Set desired version to version of latest release
|
||||
set_fact:
|
||||
adguardhome_version: "{{ adguardhome_latest_release.tag | regex_replace('^v', '') }}"
|
||||
when: adguardhome_latest_release.tag is defined
|
||||
@@ -1,15 +1,15 @@
|
||||
---
|
||||
- include_tasks: setup_debian.yml
|
||||
- name: Setup Debian
|
||||
include_tasks: setup_debian.yml
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- include_tasks: setup_redhat.yml
|
||||
- name: Setup RedHat
|
||||
include_tasks: setup_redhat.yml
|
||||
when: ansible_os_family == 'RedHat'
|
||||
|
||||
- name: Ensure user exists
|
||||
user:
|
||||
name: "{{ adguardhome_user }}"
|
||||
create_home: no
|
||||
system: "{{ adguardhome_system_user }}"
|
||||
- name: Install python dependencies
|
||||
pip:
|
||||
name: github3.py
|
||||
state: present
|
||||
|
||||
- name: Check if binary is installed
|
||||
@@ -17,6 +17,10 @@
|
||||
path: "{{ adguardhome_bin_file }}"
|
||||
register: adguardhome_binary_check
|
||||
|
||||
- name: Check latest released version
|
||||
include_tasks: latest_version.yml
|
||||
when: adguardhome_version == 'latest'
|
||||
|
||||
- name: Check version of installed binary
|
||||
shell: >-
|
||||
set -o pipefail
|
||||
@@ -33,39 +37,19 @@
|
||||
when: >-
|
||||
adguardhome_binary_check.stat.exists
|
||||
|
||||
- name: Install binary
|
||||
block:
|
||||
- name: Ensure bin directory exists
|
||||
file:
|
||||
dest: "{{ adguardhome_bin_dir }}"
|
||||
recurse: yes
|
||||
state: directory
|
||||
- name: Create temporary directory
|
||||
file:
|
||||
dest: "{{ adguardhome_unpack_dir }}"
|
||||
recurse: yes
|
||||
state: directory
|
||||
- name: "Download and extract {{ adguardhome_arch }} archive"
|
||||
unarchive:
|
||||
src: "{{ adguardhome_download_url }}"
|
||||
dest: "{{ adguardhome_unpack_dir }}"
|
||||
remote_src: yes
|
||||
extra_opts:
|
||||
- "--strip-components=1"
|
||||
- name: "Copy binary to {{ adguardhome_bin_dir }}/"
|
||||
copy:
|
||||
src: "{{ adguardhome_unpack_dir }}/{{ adguardhome_bin_name }}"
|
||||
dest: "{{ adguardhome_bin_file }}"
|
||||
mode: "755"
|
||||
remote_src: yes
|
||||
- name: Remove temporary directory
|
||||
file:
|
||||
path: "{{ adguardhome_unpack_dir }}"
|
||||
state: absent
|
||||
- name: "Install binary (v{{ adguardhome_version }} / {{ adguardhome_arch }})"
|
||||
include_tasks: install.yml
|
||||
when: >-
|
||||
adguardhome_version_check.changed
|
||||
or (not adguardhome_binary_check.stat.exists)
|
||||
|
||||
- name: Ensure user exists
|
||||
user:
|
||||
name: "{{ adguardhome_user }}"
|
||||
create_home: no
|
||||
system: "{{ adguardhome_system_user }}"
|
||||
state: present
|
||||
|
||||
- name: Ensure data directory exists and has correct permissions
|
||||
file:
|
||||
path: "{{ adguardhome_data_dir }}"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
- name: Install dependencies
|
||||
- name: Install system dependencies
|
||||
package:
|
||||
name: libcap2-bin
|
||||
name:
|
||||
- libcap2-bin
|
||||
state: present
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[Unit]
|
||||
Description=AdGuard Home
|
||||
ConditionFileIsExecutable="{{ adguardhome_bin_file }}"
|
||||
ConditionFileIsExecutable={{ adguardhome_bin_file }}
|
||||
After=syslog.target
|
||||
After=network-online.target
|
||||
|
||||
|
||||
Reference in New Issue
Block a user