- name: install unbound package
  package: name={{ item }} state=present
  with_items:
  - unbound

- name: install unbound config
  copy: src=unbound.conf dest=/etc/unbound/unbound.conf mode=644
  notify:
  - restart unbound

- name: setup SELinux dns 80
  command: touch /root/dns80 creates=/root/dns80
  notify:
  - semanage dns80

- name: setup SELinux dns 443
  command: touch /root/dns443 creates=/root/dns443
  notify:
  - semanage dns443

- name: setup SELinux dns 8953
  command: touch /root/dns8953 creates=/root/dns8953
  notify:
  - semanage dns8953

- name: copying unbound keys and certs
  copy: src="{{ private }}/files/unbound/unbound_{{ item }}" dest=/etc/unbound/unbound_{{ item }} owner=root group=unbound mode=640
  with_items:
  - control.key
  - control.pem
  - server.key
  - server.pem
  notify:
  - restart unbound
  tags:
  - config

- name: Enable and start unbound service
  service: state=started enabled=true name=unbound
  tags:
  - service
  - config
