- name: Create directories for HTML documents
file: state=directory path={{ item }} group=www-data owner={{ main_user_name }}
with_items: "{{ virtual_domains | json_query('[*].doc_root') | unique }}"
- name: Create directory for well-known configs
file: state=directory path=/var/www/well-known group=www-data owner=www-data
- name: Create the Apache well-known config
template:
src=etc_apache2_conf-available_well-known.j2
dest=/etc/apache2/conf-available/well-known.conf
owner=root
group=root
notify: restart apache
- name: Enable the Apache well-known config
command: a2enconf well-known.conf creates=/etc/apache2/conf-enabled/well-known.conf.conf
notify: restart apache
- name: Setup PHP config
template:
src=etc_php_7.0_apache2_php.ini.j2
dest=/etc/php/7.0/apache2/php.ini
owner=root
group=root
notify: restart apache
when: ansible_distribution_version == '9'
- name: Setup PHP config
template:
src=etc_php_7.3_apache2_php.ini.j2
dest=/etc/php/7.3/apache2/php.ini
owner=root
group=root
notify: restart apache
when: ansible_distribution_version == '10'
- name: Setup PHP config
template:
src=etc_php_7.4_apache2_php.ini.j2
dest=/etc/php/7.4/apache2/php.ini
owner=root
group=root
notify: restart apache
when: ansible_distribution_version == '11'
- name: Add custom postgres user
postgresql_user:
login_host=localhost
login_user={{ db_admin_username }}
login_password="{{ db_admin_password }}"
name={{ custom_db_username }}
password="{{ custom_db_password }}"
encrypted=yes
state=present
- name: Create custom database
postgresql_db:
login_host=localhost
login_user={{ db_admin_username }}
login_password="{{ db_admin_password }}"
name={{ custom_db_database }}
state=present
owner={{ custom_db_username }}
- name: Create an example blog index page
template:
src=var_www_blog_index.j2
dest={{ item.doc_root }}/index.html
owner=www-data
group=www-data
force=no
with_items: "{{ virtual_domains }}"
- name: Create an example blog 404 error page
template:
src=var_www_blog_404.j2
dest={{ item.doc_root }}/404.html
owner=www-data
group=www-data
force=no
with_items: "{{ virtual_domains }}"
- name: Create the Apache blog sites config files
template:
src=etc_apache2_sites-available_blog.j2
dest=/etc/apache2/sites-available/{{ item.name }}.conf
owner=root
group=root
notify: restart apache
with_items: "{{ virtual_domains }}"
- name: Enable Apache blog sites (creates new sites-enabled symlinks)
command: a2ensite {{ item }}.conf creates=/etc/apache2/sites-enabled/{{ item }}.conf
notify: restart apache
with_items: "{{ virtual_domains | json_query('[*].name') }}"