---
- include: common.yml
  when: httpd_common is not defined

- set_fact: httpd_common=True

- file: state=directory path={{ document_root }} setype=httpd_sys_content_t owner=root mode=755 group=root
  when: document_root is defined

- file:  path=/etc/httpd/conf.d/{{ website_url }}.conf.d/ state=directory
  when: website_url is defined

# needed for newer apache, who requires at least 1 file for include
- copy: dest=/etc/httpd/conf.d/{{ website_url }}.conf.d/placeholder.conf content="# Placeholder"
  when: website_url is defined

- htpasswd: path=/etc/httpd/{{ website_url }}.htpasswd name={{ website_user }} password={{ website_password }} owner=root group=apache mode=0640
  when: website_user is defined

- template: src=vhost.conf dest=/etc/httpd/conf.d/{{ website_url }}.conf owner=root group=apache mode=0644
  notify: restart httpd
  when: document_root is defined

- template: src=vhost_redirect.conf dest=/etc/httpd/conf.d/{{ website_url }}.conf owner=root group=apache mode=0644
  notify: restart httpd
  when: redirect is defined



---
- include: common.yml
  when: httpd_common is not defined

- set_fact: httpd_common=True

- file: state=directory path={{ document_root }} setype=httpd_sys_content_t owner=root mode=755 group=root
  when: document_root is defined

- file:  path=/etc/httpd/conf.d/{{ website_url }}.conf.d/ state=directory
  when: website_url is defined

# needed for newer apache, who requires at least 1 file for include
- copy: dest=/etc/httpd/conf.d/{{ website_url }}.conf.d/placeholder.conf content="# Placeholder"
  when: website_url is defined

- htpasswd: path=/etc/httpd/{{ website_url }}.htpasswd name={{ website_user }} password={{ website_password }} owner=root group=apache mode=0640
  when: website_user is defined

- template: src=vhost.conf dest=/etc/httpd/conf.d/{{ website_url }}.conf owner=root group=apache mode=0644
  notify: verify config and restart httpd
  when: document_root is defined

- template: src=vhost_redirect.conf dest=/etc/httpd/conf.d/{{ website_url }}.conf owner=root group=apache mode=0644
  notify: verify config and restart httpd
  when: redirect is defined

Migrate to the handler that verify configuration
Migrate to the handler that verify configuration
