67 lines
1.5 KiB
YAML
67 lines
1.5 KiB
YAML
---
|
|
- name: install apache
|
|
package:
|
|
name: "{{ item }}"
|
|
state: installed
|
|
with_items:
|
|
- httpd
|
|
- mod_ssl
|
|
|
|
- name: disable plain http and default included configs
|
|
lineinfile:
|
|
path: /etc/httpd/conf/httpd.conf
|
|
line: "#{{ item }}"
|
|
regexp: "^#?{{ item|replace('*', '\\*') }}"
|
|
with_items:
|
|
- "Listen 80"
|
|
- "IncludeOptional conf.d/*.conf"
|
|
notify: restart apache
|
|
|
|
- name: include local configs
|
|
lineinfile:
|
|
path: /etc/httpd/conf/httpd.conf
|
|
line: "IncludeOptional conf.local.d/*.conf"
|
|
notify: restart apache
|
|
|
|
- name: fix selinux contexts from data directory
|
|
sefcontext:
|
|
path: /srv/web(/.*)?
|
|
setype: httpd_sys_content_t
|
|
when: ansible_selinux_python_present == true
|
|
- name: create data and config directories
|
|
file:
|
|
state: directory
|
|
path: "{{ item }}"
|
|
mode: 0755
|
|
owner: root
|
|
group: "{{ ansible_wheel }}"
|
|
seuser: _default
|
|
setype: _default
|
|
with_items:
|
|
- /srv/web
|
|
- "/srv/web/{{ inventory_hostname }}"
|
|
- "/etc/httpd/conf.local.d"
|
|
|
|
- name: create ssl config
|
|
copy:
|
|
src: ssl.conf
|
|
dest: /etc/httpd/conf.local.d/ssl.conf
|
|
mode: 0644
|
|
owner: root
|
|
group: "{{ ansible_wheel }}"
|
|
notify: restart apache
|
|
|
|
- name: create site config
|
|
template:
|
|
src: site.conf.j2
|
|
dest: "/etc/httpd/conf.local.d/{{ inventory_hostname }}.conf"
|
|
mode: 0644
|
|
owner: root
|
|
group: "{{ ansible_wheel }}"
|
|
notify: restart apache
|
|
|
|
- name: enable apache
|
|
service:
|
|
name: httpd
|
|
state: started
|
|
enabled: true
|