docker-pdns/ansible-playbook-pgsql.yml
Peter Schiffer 950b86265f
Update Fedora and Alpine base images
PDNS Recursor is now at version 5.0 and PDNS Alpine version at 4.9.
PDNS Fedora version stays at 4.8 for now.
2024-06-04 00:28:32 +02:00

235 lines
6.4 KiB
YAML

---
- name: PDNS pgsql
hosts: localhost
vars:
pdns_master_ip: 172.7.0.20
pdns_slave_ip: 172.7.0.21
wipe: false
c_state: '{{ "absent" if wipe | bool else "started" }}'
i_state: present
alpine: false
tasks:
- name: Create docker network
community.docker.docker_network:
name: pdns-net-pgsql
state: present
ipam_config:
- subnet: '172.7.0.0/16'
gateway: '172.7.0.1'
tags:
- pdns
- pdns-admin
- pdns-recursor
- name: Build pdns recursor
community.docker.docker_image:
name: pschiffe/pdns-recursor
state: '{{ i_state }}'
source: build
force_source: true
build:
pull: true
path: ./pdns-recursor
tags:
- pdns-recursor
- name: Build pdns recursor alpine version
community.docker.docker_image:
name: pschiffe/pdns-recursor
tag: alpine
state: '{{ i_state }}'
source: build
force_source: true
build:
pull: true
path: ./pdns-recursor
dockerfile: Dockerfile.alpine
tags:
- pdns-recursor
- name: PDNS recursor
community.docker.docker_container:
name: pdns-recursor-pgsql
image: pschiffe/pdns-recursor:{{ "alpine" if alpine | bool else "latest" }}
state: '{{ c_state }}'
networks:
- name: pdns-net-pgsql
volumes:
- /etc/localtime:/etc/localtime:ro
ulimits:
- 'nofile:5000:5000'
tags:
- pdns-recursor
- name: DB
community.docker.docker_container:
name: pdns-postgres
image: postgres:16-alpine
pull: true
state: '{{ c_state }}'
networks:
- name: pdns-net-pgsql
aliases:
- db
- pgsql
volumes:
- /etc/localtime:/etc/localtime:ro
- pdns-postgres-volume:/var/lib/postgresql/data:Z
env:
POSTGRES_PASSWORD: 'my-secret-pw'
healthcheck:
test: ['CMD', 'pg_isready', '-U', 'postgres']
timeout: 10s
retries: 5
tags:
- db
- name: Adminer
community.docker.docker_container:
name: pdns-adminer
image: adminer
pull: true
state: '{{ c_state }}'
networks:
- name: pdns-net-pgsql
published_ports:
- '7888:8080'
volumes:
- /etc/localtime:/etc/localtime:ro
tags:
- db
- name: Build pdns pgsql
community.docker.docker_image:
name: pschiffe/pdns-pgsql
state: '{{ i_state }}'
source: build
force_source: true
build:
pull: true
path: ./pdns-pgsql
tags:
- pdns
- name: Build pdns pgsql alpine version
community.docker.docker_image:
name: pschiffe/pdns-pgsql
tag: alpine
state: '{{ i_state }}'
source: build
force_source: true
build:
pull: true
path: ./pdns-pgsql
dockerfile: Dockerfile.alpine
tags:
- pdns
- name: PDNS pgsql master
community.docker.docker_container:
name: pdns-pgsql
image: pschiffe/pdns-pgsql:{{ "alpine" if alpine | bool else "latest" }}
state: '{{ c_state }}'
hostname: ns1.example.com
networks:
- name: pdns-net-pgsql
ipv4_address: '{{ pdns_master_ip }}'
aliases:
- pdns
etc_hosts:
ns1.example.com: '{{ pdns_master_ip }}'
ns2.example.com: '{{ pdns_slave_ip }}'
volumes:
- /etc/localtime:/etc/localtime:ro
env:
PDNS_gpgsql_password: 'my-secret-pw'
PDNS_primary: 'yes'
PDNS_api: 'yes'
PDNS_api_key: 'secret'
PDNS_webserver: 'yes'
PDNS_webserver_address: '0.0.0.0'
PDNS_webserver_allow_from: '172.7.0.0/16'
PDNS_version_string: 'anonymous'
PDNS_default_ttl: '1500'
PDNS_allow_axfr_ips: '{{ pdns_slave_ip }}'
PDNS_only_notify: '{{ pdns_slave_ip }}'
tags:
- pdns
- name: PDNS pgsql slave
community.docker.docker_container:
name: pdns-pgsql-slave
image: pschiffe/pdns-pgsql:{{ "alpine" if alpine | bool else "latest" }}
state: '{{ c_state }}'
hostname: ns2.example.com
networks:
- name: pdns-net-pgsql
ipv4_address: '{{ pdns_slave_ip }}'
etc_hosts:
ns1.example.com: '{{ pdns_master_ip }}'
ns2.example.com: '{{ pdns_slave_ip }}'
volumes:
- /etc/localtime:/etc/localtime:ro
env:
PDNS_gpgsql_dbname: 'powerdnsslave'
PDNS_gpgsql_password: 'my-secret-pw'
PDNS_secondary: 'yes'
PDNS_autosecondary: 'yes'
PDNS_webserver: 'yes'
PDNS_webserver_address: '0.0.0.0'
PDNS_webserver_allow_from: '172.7.0.0/16'
PDNS_version_string: 'anonymous'
PDNS_disable_axfr: 'yes'
PDNS_allow_notify_from: '{{ pdns_master_ip }}'
SUPERMASTER_IPS: '{{ pdns_master_ip }}'
tags:
- pdns
- name: Build pdns-admin
community.docker.docker_image:
name: pschiffe/pdns-admin
tag: latest
state: '{{ i_state }}'
source: build
force_source: true
build:
pull: true
path: ./pdns-admin
tags:
- pdns-admin
- name: PDNS-admin pgsql
community.docker.docker_container:
name: pdns-admin-pgsql
image: pschiffe/pdns-admin
state: '{{ c_state }}'
networks:
- name: pdns-net-pgsql
aliases:
- pdns-admin
published_ports:
- '7889:8080'
volumes:
- /etc/localtime:/etc/localtime:ro
env:
PDNS_ADMIN_SQLA_DB_TYPE: 'postgres'
PDNS_ADMIN_SQLA_DB_HOST: 'pgsql'
PDNS_ADMIN_SQLA_DB_PORT: '5432'
PDNS_ADMIN_SQLA_DB_USER: 'postgres'
PDNS_ADMIN_SQLA_DB_PASSWORD: 'my-secret-pw'
PDNS_VERSION: '4.8'
PDNS_API_KEY: 'secret'
tags:
- pdns-admin
- name: Remove docker volume
community.docker.docker_volume:
name: pdns-postgres-volume
state: absent
when: wipe | bool
- name: Remove network
community.docker.docker_network:
name: pdns-net-pgsql
state: absent
when: wipe | bool