roles.webcluster/webcluster-worker/tasks/main.yml
2025-04-11 20:08:08 +02:00

107 lines
2.6 KiB
YAML

---
- name: Install software
ansible.builtin.package:
name: "{{ worker_packages }}"
state: latest
update_cache: true
cache_valid_time: 7200
- name: Apache2 enable modules
community.general.apache2_module:
name: "{{ item }}"
state: present
with_items: "{{ worker_a2mods }}"
notify: Restart Apache2
- name: Apache2 disable sites
ansible.builtin.file:
path: "/etc/apache2/sites-enabled/{{ item }}"
state: absent
with_items: "{{ worker_a2dissites }}"
notify: Restart Apache2
- name: Apache2 create vhosts
ansible.builtin.template:
dest: "/etc/apache2/sites-available/{{ item }}"
src: "etc/apache2/sites-available/{{ item }}.j2"
mode: "0644"
backup: true
with_items: "{{ worker_a2ensites }}"
notify: Restart Apache2
- name: Apache2 enable sites
ansible.builtin.file:
path: "/etc/apache2/sites-enabled/{{ item }}"
src: "/etc/apache2/sites-available/{{ item }}"
state: link
force: true
with_items: "{{ worker_a2ensites }}"
notify: Restart Apache2
- name: Apache2 create DocRoots
ansible.builtin.file:
path: "/{{ item }}"
state: directory
owner: root
group: root
mode: "0755"
with_items: "{{ worker_a2docroots }}"
notify: Restart Apache2
- name: PHP Install pools
ansible.builtin.template:
dest: "/etc/php/{{ worker_phpversion }}/fpm/pool.d/{{ item }}"
src: "etc/php-fpm-pool.d/{{ item }}.j2"
mode: "0644"
owner: root
group: root
backup: true
with_items: "{{ worker_phpfpmpools }}"
notify: Restart PHP-FPM
- name: Disable worker in load balancers
community.general.haproxy:
socket: /var/lib/haproxy/admin.sock
backend: dynamic
host: "{{ inventory_hostname }}"
state: disabled
delegate_to: "{{ item }}"
with_items: "{{ groups.lb }}"
- name: Apache2 copy websites
ansible.builtin.copy:
dest: "/{{ item }}/"
src: "{{ item }}/"
owner: root
group: root
mode: "0644"
backup: true
with_items: "{{ worker_a2docroots }}"
- name: Apache2 template dummy index.html
ansible.builtin.template:
dest: "/{{ item }}/index.html"
src: "{{ item }}/index.html.j2"
owner: root
group: root
mode: "0644"
backup: true
with_items: "{{ worker_a2docroots }}"
- name: Flush handers
ansible.builtin.meta: flush_handlers
- name: Sleep 30 seconds...
ansible.builtin.pause:
seconds: 30
- name: Enable worker in load balancers
community.general.haproxy:
socket: /var/lib/haproxy/admin.sock
backend: dynamic
host: "{{ inventory_hostname }}"
state: enabled
delegate_to: "{{ item }}"
with_items: "{{ groups.lb }}"