ansible-role-httpd/tasks/httpd_post_install.yml
Dmitriy Rabotyagov 8500ca5861 Auto-fix yaml rules
In order to reduce divergance with ansible-lint rules, we apply
auto-fixing of violations.

In current patch we replace all kind of truthy variables with
`true` or `false` values to align with recommendations along with
alignment of used quotes.

With ansible-lint update it seems to be resolving symlink to absolute
path, which causes our linter check to search for the wrong
role name. Some more details were posted to ansible forum[1]

So we apply change here to resolve failing CI.

[1] https://forum.ansible.com/t/ansible-lint-resolving-symlinks-to-their-destinations/40388

Change-Id: Icdbe2bb4ad139254266d456cebba0c3f0c82496e
2025-02-20 13:03:37 +01:00

83 lines
2.4 KiB
YAML

---
# Copyright 2024, Cleura 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: Ensure apache2 MPM for Debian/Ubuntu
community.general.apache2_module:
name: "{{ item.name }}"
state: "{{ item.state }}"
ignore_configcheck: true
warn_mpm_absent: false
with_items: "{{ httpd_mpms | sort(attribute='state') }}"
when:
- ansible_facts['pkg_mgr'] == 'apt'
notify: Restart web server
- name: Ensure apache2 MPM for EL
ansible.builtin.copy:
content: |
LoadModule mpm_{{ httpd_mpm_backend }}_module modules/mod_mpm_{{ httpd_mpm_backend }}.so
dest: "{{ httpd_conf_dir }}/conf.modules.d/00-mpm.conf"
mode: "0644"
when:
- ansible_facts['pkg_mgr'] == 'dnf'
notify: Restart web server
- name: Enable apache2 modules
community.general.apache2_module:
name: "{{ item.name }}"
state: "{{ item.state }}"
ignore_configcheck: true
with_items: "{{ httpd_modules }}"
when:
- ansible_facts['pkg_mgr'] == 'apt'
notify: Restart web server
- name: Disable default apache site
ansible.builtin.file:
path: "{{ item }}"
state: "absent"
with_items: "{{ httpd_default_sites }}"
notify: Restart web server
- name: Ensure Apache configuration
ansible.builtin.lineinfile:
dest: "{{ httpd_conf_file }}"
line: "{{ item }}"
regexp: "^{{ item | split() | first }}"
notify: Restart web server
with_items:
- "ServerName {{ httpd_server_name }}"
- "ErrorLog syslog:daemon"
- "LogLevel {{ httpd_log_level }}"
- name: Apply Apache extra configuration
ansible.builtin.template:
src: "{{ item['src'] }}"
dest: "{{ item['dest'] }}"
owner: "{{ item['owner'] }}"
group: "{{ item['group'] }}"
mode: "0644"
with_items: "{{ httpd_extra_conf_files }}"
notify: Restart web server
- name: Remove Listen from Apache config
ansible.builtin.lineinfile:
dest: "{{ httpd_security_conf }}"
regexp: "^(Listen.*)"
backrefs: true
line: "#\\1"
notify: Restart web server