Refactor apache2.yml for consistency and clarity in task definitions

This commit is contained in:
2026-03-27 14:56:14 +01:00
parent a7ae583c20
commit b201a21105

View File

@@ -1,5 +1,4 @@
--- ---
# --- # ---
# Apache2 Server # Apache2 Server
# --- # ---
@@ -7,31 +6,29 @@
- name: Populate service facts - name: Populate service facts
ansible.builtin.service_facts: ansible.builtin.service_facts:
#- name: Print service facts # - name: Print service facts
# ansible.builtin.debug: # ansible.builtin.debug:
# var: ansible_facts.services # var: ansible_facts.services
# when: # when:
# - ansible_facts['services']['apache2.service']['name'] | default('not-found') != 'not-found' # - ansible_facts['services']['apache2.service']['name'] | default('not-found') != 'not-found'
- name: (apache2.yml) Ensure directory '/etc/systemd/system/apache2.service.d' is present - name: (apache2.yml) Ensure directory '/etc/systemd/system/apache2.service.d' is present
file: ansible.builtin.file:
path: /etc/systemd/system/apache2.service.d path: /etc/systemd/system/apache2.service.d
state: directory state: directory
owner: root owner: root
group: root group: root
mode: '0755' mode: "0755"
when: when:
- ansible_facts['services']['apache2.service']['name'] | default('not-found') != 'not-found' - ansible_facts['services']['apache2.service']['name'] | default('not-found') != 'not-found'
- name: (apache2.yml) Ensure file '/etc/systemd/system/apache2.service.d/limits.conf' exists - name: (apache2.yml) Ensure file '/etc/systemd/system/apache2.service.d/limits.conf' exists
copy: ansible.builtin.copy:
src: 'etc/systemd/system/apache2.service.d/limits.conf' src: "etc/systemd/system/apache2.service.d/limits.conf"
dest: '/etc/systemd/system/apache2.service.d/limits.conf' dest: "/etc/systemd/system/apache2.service.d/limits.conf"
owner: root owner: root
group: root group: root
mode: '0644' mode: "0644"
notify: "Restart apache2" notify: "Restart apache2"
when: when:
- ansible_facts['services']['apache2.service']['name'] | default('not-found') != 'not-found' - ansible_facts['services']['apache2.service']['name'] | default('not-found') != 'not-found'