---
- hosts: centos8_init
user: ioniere
become: yes
vars:
root_db_pass: secret
pdns_db_pass: secretpdns
tasks:
- name: epel-release 설치
yum:
name: epel-release
state: latest
- name: pdns 설치
yum:
name: ['pdns', 'pdns-backend-mysql']
state: latest
- name: pdns.conf 다운로드
get_url:
url: http://data.yeonghoon.kim/centos8_pdns/source/pdns.conf
dest: /etc/pdns/pdns.conf
force: yes
- name: pdns 기본 디비 구성 파일 다운로드
get_url:
url: http://data.yeonghoon.kim/centos8_pdns/source/pdns_db_setup.sql
dest: /tmp/pdns_db_setup.sql
force: yes
- name: pdns.conf 디비 사용자 패스워드 입력
blockinfile:
path: /etc/pdns/pdns.conf
insertafter: EOF
block: |
gmysql-password={{ pdns_db_pass }}
- name: mysql 루트 패스워드 설정
lineinfile:
path: /tmp/pdns_db_setup.sql
regexp: '^GRANT'
line: "GRANT ALL PRIVILEGES ON pdns.* TO pdns@localhost IDENTIFIED BY '{{ pdns_db_pass }}';"
- name: pdns 디비 구성
shell: "mysql -uroot -p{{ root_db_pass }} < /tmp/pdns_db_setup.sql"
- name: pdns_db_setup 삭제
file:
path: /tmp/pdns_db_setup.sql
state: absent
- name: pdns 구동 및 부팅 시 구동되도록 설정
service:
name: pdns
state: started
enabled: yes
host, user, root_db_passwd, pdns_db_passwd는 상황에 맞게 수정
로컬에 mysql 설치가 되어 있어야 하며, root 계정으로 디비 제어가 가능해야 함.
root_db_passwd는 해당 서버의 디비 루트 패스워드
pdns_db_passwd는 원하는 패스워드
방화벽 설정은 별도로 진행(53)