openstack-ansible-os_adjutant/tasks/adjutant_apache.yml
2019-11-22 14:09:44 +01:00

91 lines
2.3 KiB
YAML

---
# Copyright 2018, Elastx AB.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Drop apache2 virtual host and ports file
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: "root"
group: "root"
with_items: "{{ adjutant_apache_config }}"
notify:
- Restart Apache
- name: Disable default apache site
file:
path: "{{ item }}"
state: "absent"
with_items: "{{ adjutant_apache_default_sites }}"
notify:
- Restart Apache
- name: Enabled adjutant vhost
file:
src: "{{ adjutant_apache_site_available }}"
dest: "{{ adjutant_apache_site_enabled }}"
state: "link"
when:
- adjutant_apache_site_available is defined
- adjutant_apache_site_enabled is defined
notify:
- Restart Apache
- name: Ensure Apache ServerName
lineinfile:
dest: "{{ adjutant_apache_conf }}"
line: "ServerName {{ inventory_hostname }}"
notify:
- Restart Apache
- name: Ensure Apache ServerTokens
lineinfile:
dest: "{{ adjutant_apache_security_conf }}"
regexp: '^ServerTokens'
line: "ServerTokens {{ adjutant_apache_servertokens }}"
notify:
- Restart Apache
- name: Ensure Apache ServerSignature
lineinfile:
dest: "{{ adjutant_apache_security_conf }}"
regexp: '^ServerSignature'
line: "ServerSignature {{ adjutant_apache_serversignature }}"
notify:
- Restart Apache
- name: Remove Listen from Apache config
lineinfile:
dest: "{{ adjutant_apache_security_conf }}"
regexp: '^(Listen.*)'
backrefs: yes
line: '#\1'
notify:
- Restart Apache
- name: Enable/disable mods for apache2
apache2_module:
name: "{{ item.name }}"
state: "{{ item.state }}"
when:
- ansible_pkg_mgr == 'apt'
with_items:
- name: ssl
state: "{{ adjutant_ssl | bool | ternary('present', 'absent') }}"
- name: rewrite
state: present
notify:
- Restart Apache