# Like any other piece of software, install-dqcache.yml comes with NO WARRANTY. # # install-dqcache.yml # # Author: Toby Betts # # An Ansible playbook to download and install the dqcache DNS resolver # and freedt, a suite of service management utilities that function # similarly to daemontools. # # This playbook is a quick and dirty way to put a recursive DNS resolver # on a machine. # # To run: # $ ansible-playbook install-dqcache.yml # # Caveats: # - This playbook will not download any software until you have read # and followed the directions. # # - Many options for dqcache are ignored or hard-coded in the interest # of saving time and space and keeping the entire playbook as a # single file. # # - Starting dqcache requires you to run svscan on the service # directory. To do this, as root run "svscan /path/to/service", # where the service directory is found in the home directory of the # local ansible user. # # - This playbook has a vars section with OpenBSD-specific settings. # Uncomment or edit these as needed. # # - By default, this only installs onto the localhost. It can easily # be edited to be run against multiple hosts as you have defined in # an inventory file. # # - This playbook does NOT alter your /etc/resolv.conf file. As needed # on your operating system, backup and replace your /etc/resolv.conf # with the line "nameserver 127.0.0.1" if you want to make dqcache # the default DNS resolver. Be aware that many modern OSes rewrite # /etc/resolv.conf dynamically, so you may need to use chattr(1) or # chflags(1) to make /etc/resolv.conf immutable and keep it from # getting overwritten. # # Links: # dqcache - # freedt - # # This is version 2021-03-12 of install-dqcache.yml --- - hosts: localhost vars: ansible_python_interpreter: /usr/bin/python3 # OpenBSD-specific settings # ansible_python_interpreter: /usr/local/bin/python3 # ansible_become_method: doas dq_dir: dq-20181021 dq_file: "{{dq_dir}}.tar.gz" dq_url: https://github.com/janmojzis/dq/archive/20181021.tar.gz dq_checksum: sha256:b1797538dd7dfe8e6d9c2964eee0b569589b448c8a2e636bbee4cf2a19bc7ea4 dq_group: _dq dq_user: _dq dq_userlog: _dqlog service_dir: "{{ansible_user_dir}}/service" dq_service_dir: "{{service_dir}}/dqcache" freedt_dir: freedt-23 freedt_file: "{{freedt_dir}}.tar.gz" freedt_url: https://offog.org/files/{{freedt_file}} freedt_checksum: sha256:b0176d6f3c290f3d281804b61906b91f332801109ec8c991689c4113a028e42c tasks: - name: make service directory tree file: path: "{{item.p}}" mode: "{{item.m}}" state: "{{item.s}}" loop: - { m: "03755", s: directory, p: "{{service_dir}}" } - { m: "02755", s: directory, p: "{{dq_service_dir}}" } - { m: "02755", s: directory, p: "{{dq_service_dir}}/log" } - { m: "02755", s: directory, p: "{{dq_service_dir}}/env" } - { m: "02755", s: directory, p: "{{dq_service_dir}}/root/ip4" } - { m: "02755", s: directory, p: "{{dq_service_dir}}/root/servers" } - { m: "0644", s: touch, p: "{{dq_service_dir}}/root/ip4/127" } - name: create env/IP copy: dest: "{{dq_service_dir}}/env/IP" mode: "0644" content: 127.0.0.1 - name: create env/ROOT copy: dest: "{{dq_service_dir}}/env/ROOT" mode: "0644" content: "{{dq_service_dir}}/root" - name: create root/servers/@ copy: dest: "{{dq_service_dir}}/root/servers/@" mode: "0644" content: | 198.41.0.4 199.9.14.201 192.33.4.12 199.7.91.13 192.203.230.10 192.5.5.241 192.112.36.4 198.97.190.53 192.36.148.17 192.58.128.30 193.0.14.129 199.7.83.42 202.12.27.33 - name: create dqcache service run copy: dest: "{{dq_service_dir}}/run" mode: "0755" content: | #!/bin/sh exec 2>&1 envdir ./env envuidgid _dq softlimit -o 250 -d 12000000 dqcache - name: create dqcache service log run copy: dest: "{{dq_service_dir}}/log/run" mode: "0755" content: | #!/bin/sh exec 2>&1 setuidgid {{dq_userlog}} dumblog -c ./main/current # create users - name: make dqcache group become: yes group: name: "{{dq_group}}" - name: make dqcache users become: yes user: name: "{{item}}" group: "{{dq_group}}" home: /dev/null shell: /dev/null system: yes createhome: no loop: - "{{dq_user}}" - "{{dq_userlog}}" - name: create log/main dir become: yes file: path: "{{item.p}}" owner: "{{item.o}}" group: "{{item.g}}" mode: "{{item.m}}" state: "{{item.s}}" loop: - { m: "0755", o: "{{dq_userlog}}", g: "{{dq_group}}", s: directory, p: "{{dq_service_dir}}/log/main" } - fail: msg: To download and install dqcache and freedt, remove this task - name: download get_url: dest: "{{ansible_user_dir}}" url: "{{item.u}}" checksum: "{{item.c}}" loop: - { u: "{{dq_url}}", c: "{{dq_checksum}}" } - { u: "{{freedt_url}}", c: "{{freedt_checksum}}" } - name: extract shell: tar xzf {{item}} args: chdir: "{{ansible_user_dir}}" warn: no loop: - "{{freedt_file}}" - "{{dq_file}}" - name: configure shell: ./configure args: chdir: "{{ansible_user_dir}}/{{freedt_dir}}" - name: compile shell: make args: chdir: "{{item}}" loop: - "{{ansible_user_dir}}/{{dq_dir}}" - "{{ansible_user_dir}}/{{freedt_dir}}" - name: make install become: yes shell: make install args: chdir: "{{item}}" loop: - "{{ansible_user_dir}}/{{dq_dir}}" - "{{ansible_user_dir}}/{{freedt_dir}}" # END