Files
fedora-infra_ansible/roles/apache/tasks/main.yml
2026-01-26 11:22:52 +00:00

121 lines
3.2 KiB
YAML

---
# install apache(httpd)
- name: Install apache (package)
ansible.builtin.package:
state: present
name:
- httpd
- httpd-tools
tags:
- packages
- apache
when: ansible_cmdline.ostree is not defined
- name: Install mod_http2 on rhel8 hosts
ansible.builtin.package:
state: present
name:
- mod_http2
tags:
- packages
- apache
when: ansible_distribution_major_version|int >= 8 and ansible_distribution == 'RedHat'
- name: Set apache running/enabled
service: name=httpd enabled=yes
ignore_errors: true
notify:
- Reload apache
tags:
- service
- apache
# install hash randomization hotfix
- name: Hotfix - copy over new httpd init script
ansible.builtin.copy: src="{{ files }}/hotfix/httpd/httpd.init" dest=/etc/init.d/httpd
owner=root group=root mode=0755
when: ansible_distribution_major_version|int < 30 and ansible_distribution == 'Fedora'
notify:
- Reload apache
tags:
- config
- hotfix
- apache
# install hash randomization hotfix
- name: Hotfix - copy over new httpd init script
ansible.builtin.copy: src="{{ files }}/hotfix/httpd/httpd.init" dest=/etc/init.d/httpd
owner=root group=root mode=0755
when: ansible_distribution_major_version|int <= 8 and ansible_distribution == 'RedHat'
notify:
- Reload apache
tags:
- config
- hotfix
- apache
- name: Add appserver headers.conf
ansible.builtin.template: src="{{ files }}/httpd/headers.conf.j2" dest=/etc/httpd/conf.d/headers.conf
notify:
- Reload apache
tags:
- config
- apache
- apache/headers
- name: Add appserver h2.conf
ansible.builtin.template: src="{{ files }}/httpd/h2.conf.j2" dest=/etc/httpd/conf.d/h2.conf
when: ansible_distribution == 'Fedora'
notify:
- Reload apache
tags:
- config
- apache
- h2
- name: Add apache_status location for collectd
ansible.builtin.template: src="{{ files }}/httpd/apachestatus.conf" dest=/etc/httpd/conf.d/apachestatus.conf
notify:
- Reload apache
tags:
- config
- apache
- apachestatus
- name: Setup logrotate to our needs
ansible.builtin.template: src="{{ files }}/httpd/httpd.logrotate.j2" dest=/etc/logrotate.d/httpd
tags:
- config
- apache
# HTTPd monitoring for Fedora Zabbix
- name: Zabbix API Block
vars:
ansible_zabbix_auth_key: "{{ zabbix_auth_key }}"
ansible_network_os: "{{ zabbix_network_os }}"
ansible_connection: "{{ zabbix_connection }}"
ansible_httpapi_port: "{{ zabbix_httpapi_port }}"
ansible_httpapi_use_ssl: "{{ zabbix_httpapi_use_ssl }}"
ansible_httpapi_validate_certs: "{{ zabbix_httpapi_validate_certs }}"
ansible_host: "{{ zabbix_server }}"
ansible_zabbix_url_path: "{{ zabbix_url_path }}"
tags:
- apache
- zabbix_api
block:
- name: Import HTTPd template file
community.zabbix.zabbix_template:
template_yaml: "{{ lookup('file', 'zabbix/apache-template.yml') }}"
state: present
- name: Ensure HTTPd hostgroup is present
community.zabbix.zabbix_group:
host_groups:
- HTTPd servers
state: present
- name: Add self to HTTPd in Zabbix
community.zabbix.zabbix_host:
host_name: "{{ inventory_hostname }}"
host_groups: HTTPd servers
link_templates: HTTPd Status Monitoring
force: false