Closed Dialgatrainer02 closed 4 months ago
I suppose I could make it a little clearer, but this role does not create the AdGuard Home systemd service by itself. I don't have the time to manage all the possible configurations for systemd units and believe that it is outside the scope of this role. However, here are some snippets from my personal infra repo to get you started.
requirements.yml
- src: bcook254.adguardhome
version: 107.50.0
- src: https://github.com/O1ahmad/ansible-role-systemd
scm: git
name: 0x0i.systemd
version: 22d2c4b
dns_playbook.yml
---
- name: Setup DNS Servers
hosts: dnsservers
order: shuffle
serial: 1
become: true
roles:
- role: 0x0i.systemd
- role: bcook254.adguardhome
group_vars\dnsservers.yml
---
adguardhome_user: adguardhome
adguardhome_group: adguardhome
adguardhome_daemon: adguardhome
adguardhome_home_dir: /var/lib/adguardhome
adguardhome_data_dir: "{{ adguardhome_home_dir }}"
adguardhome_bin_dir: /usr/local/bin
adguardhome_bin_file: "{{ adguardhome_bin_dir }}/AdGuardHome"
adguardhome_config_dir: /etc/adguardhome
adguardhome_config_file: "{{ adguardhome_config_dir }}/AdGuardHome.yaml"
adguardhome_dnshosts:
- "{{ ansible_default_ipv4.address }}"
- '127.0.0.1'
adguardhome_webhost: "{{ ansible_default_ipv4.address }}"
adguardhome_users:
- username: bcook254
hashed_password: "{{ vault_adguardhome_hashed_password }}"
adguardhome_upstream_mode: parallel
adguardhome_upstream_dns:
- '172.19.0.1'
- '172.19.0.2'
adguardhome_fallback_dns:
- '1.1.1.1'
- '1.0.0.1'
adguardhome_runtime_sources_rdns: 'false'
adguardhome_use_private_ptr_resolvers: 'false'
adguardhome_runtime_sources_dhcp: 'false'
adguardhome_ratelimit: 100
adguardhome_rewrites:
- domain: "{{ root_domain }}"
answer: "{{ hostvars['webserver1']['ansible_host'] }}"
- domain: "{{ root_domain }}"
answer: "{{ hostvars['webserver2']['ansible_host'] }}"
adguardhome_user_rules:
- '||_minecraft._tcp.vanilla.{{ root_domain }}^$dnsrewrite=NOERROR;SRV;0 0 25566 minecraft.{{ root_domain }}'
adguardhome_filters:
*OMITTED FOR BREVITY*
unit_config:
- name: "{{ adguardhome_daemon }}"
enabled: true
state: started
Unit:
Description: AdGuardHome DNS Server
ConditionFileIsExecutable: "{{ adguardhome_bin_file }}"
After: network.target
Service:
Type: simple
Restart: on-failure
RestartSec: 2s
TimeoutStopSec: 0
User: "{{ adguardhome_user }}"
Group: "{{ adguardhome_group }}"
WorkingDirectory: "{{ adguardhome_data_dir }}"
ExecStart: "{{ adguardhome_bin_file }} --config {{ adguardhome_config_file }} --work-dir {{ adguardhome_data_dir }}"
AmbientCapabilities: CAP_NET_BIND_SERVICE
Install:
WantedBy: multi-user.target
Thank you for opening this issue. Hopefully this helps point you in the right direction. Now that I know people are actually trying to use this role, maybe I should find some time to sit down and create some more documentation and examples...
Thank you in my.other projects I have using foo.service.j2 and copying it over this method for service files seems much better and thanks for the quick response
TASK [adguard : Stop AdGuardHome.] **** fatal: [adguard1]: FAILED! => {"changed": false, "msg": "Could not find the requested service adguardhome: host"}
the task to stop agh fails and i was trying to find where the service was made and i can find it anywhere i have no extra vars and havent changed the daemon name. im running on alma linux which uses systemd. it is a fresh vm with no changes to do with adguard on it