This guide installs octoDNS in a Python virtual environment for DNS-as-code workflows.
/opt/octodns workspaceoctodns via pip in virtualenv- name: Install octoDNS on Debian family
hosts: octodns_debian
become: true
vars:
octodns_home: /opt/octodns
octodns_user: octodns
tasks:
- name: Install dependencies
ansible.builtin.apt:
update_cache: true
name:
- python3
- python3-venv
- python3-pip
- git
state: present
- name: Ensure octoDNS user exists
ansible.builtin.user:
name: "{{ octodns_user }}"
system: true
shell: /usr/sbin/nologin
create_home: false
- name: Ensure workspace exists
ansible.builtin.file:
path: "{{ octodns_home }}"
state: directory
owner: "{{ octodns_user }}"
group: "{{ octodns_user }}"
mode: "0755"
- name: Create virtual environment
ansible.builtin.command: python3 -m venv {{ octodns_home }}/venv
args:
creates: "{{ octodns_home }}/venv/bin/activate"
- name: Install octoDNS
ansible.builtin.pip:
name: octodns
virtualenv: "{{ octodns_home }}/venv"
- name: Create config directories
ansible.builtin.file:
path: "{{ octodns_home }}/{{ item }}"
state: directory
owner: "{{ octodns_user }}"
group: "{{ octodns_user }}"
mode: "0755"
loop:
- config
- zones
- name: Write baseline octoDNS config
ansible.builtin.copy:
dest: "{{ octodns_home }}/config/config.yaml"
owner: "{{ octodns_user }}"
group: "{{ octodns_user }}"
mode: "0640"
content: |
providers:
config:
class: octodns.provider.yaml.YamlProvider
directory: {{ octodns_home }}/zones
default_ttl: 3600
enforce_order: true
dump:
class: octodns.provider.yaml.YamlProvider
directory: {{ octodns_home }}/zones
default_ttl: 3600
enforce_order: true
zones: {}
- name: Verify octoDNS installation
ansible.builtin.command: "{{ octodns_home }}/venv/bin/octodns-sync --help"
changed_when: false
- name: Install octoDNS on RHEL family
hosts: octodns_rhel
become: true
vars:
octodns_home: /opt/octodns
octodns_user: octodns
tasks:
- name: Install dependencies
ansible.builtin.dnf:
name:
- python3
- python3-pip
- python3-virtualenv
- git
state: present
- name: Ensure octoDNS user exists
ansible.builtin.user:
name: "{{ octodns_user }}"
system: true
shell: /sbin/nologin
create_home: false
- name: Ensure workspace exists
ansible.builtin.file:
path: "{{ octodns_home }}"
state: directory
owner: "{{ octodns_user }}"
group: "{{ octodns_user }}"
mode: "0755"
- name: Create virtual environment
ansible.builtin.command: python3 -m venv {{ octodns_home }}/venv
args:
creates: "{{ octodns_home }}/venv/bin/activate"
- name: Install octoDNS
ansible.builtin.pip:
name: octodns
virtualenv: "{{ octodns_home }}/venv"
- name: Create config directories
ansible.builtin.file:
path: "{{ octodns_home }}/{{ item }}"
state: directory
owner: "{{ octodns_user }}"
group: "{{ octodns_user }}"
mode: "0755"
loop:
- config
- zones
- name: Write baseline octoDNS config
ansible.builtin.copy:
dest: "{{ octodns_home }}/config/config.yaml"
owner: "{{ octodns_user }}"
group: "{{ octodns_user }}"
mode: "0640"
content: |
providers:
config:
class: octodns.provider.yaml.YamlProvider
directory: {{ octodns_home }}/zones
default_ttl: 3600
enforce_order: true
dump:
class: octodns.provider.yaml.YamlProvider
directory: {{ octodns_home }}/zones
default_ttl: 3600
enforce_order: true
zones: {}
- name: Verify octoDNS installation
ansible.builtin.command: "{{ octodns_home }}/venv/bin/octodns-sync --help"
changed_when: false
register: octodns_verify
- name: Show octoDNS version
ansible.builtin.debug:
var: octodns_verify.stdout_lines
ansible-playbook -i inventory.ini octodns-install.yml
octodns_debian.Need help automating multi-provider DNS management? We provide consulting for octoDNS deployments, custom provider plugins, and CI/CD integration for automated DNS workflows. Contact office@linux-server-admin.com or visit our contact page.