diff --git a/CHANGELOG.md b/CHANGELOG.md index 9796ceab6..30ef987eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Breaking Changes +* **playbook:apache_solr**: The playbook runs the kernel_settings role and sets `vm.swappiness` to 1, as the Solr Reference Guide recommends, so the kernel no longer swaps out the Java heap while memory is still available. On hosts that do not run kernel_settings yet, this also installs TuneD and applies its sysctl hardening baseline. Set `apache_solr__skip_kernel_settings: true` to leave the kernel settings alone. * **role:mariadb_server**: MariaDB may open at least 65536 files instead of 32768 (`mariadb_server__service_limit_nofile`), enough for 16 table cache instances, and a lower value no longer takes effect; a higher limit that the MariaDB package or systemd set is kept. The next run restarts MariaDB. * **role:fail2ban**: On hosts with Apache logs below `/var/log/httpd`, the role enables the Apache jails fail2ban ships (`apache-auth`, `apache-fakegooglebot`, `apache-modsecurity`, `apache-nohome`, `apache-noscript`, `apache-overflows`, `php-url-fopen`), unless `apache_httpd__mod_remoteip_internal_proxy` lists a proxy. On a host behind a reverse proxy that Apache logs as the client, such as LibreNMS behind a proxy, set `fail2ban__jails_apache_enabled: false`, otherwise the jails ban the proxy. * **role:fail2ban**: The sshd jail also bans clients that connect without trying to log in, such as scanners (filter mode `aggressive`). Set `fail2ban__jail_sshd_mode: 'normal'` to keep the previous behaviour. diff --git a/extensions/molecule/apache_solr/install/verify.yml b/extensions/molecule/apache_solr/install/verify.yml index 89066a050..0cf231c4e 100644 --- a/extensions/molecule/apache_solr/install/verify.yml +++ b/extensions/molecule/apache_solr/install/verify.yml @@ -157,3 +157,20 @@ {{ __molecule__apache_solr_logs_result["files"] | map(attribute="path") | zip(__molecule__apache_solr_logs_result["files"] | map(attribute="mode")) | map("join", " ") | join(", ") }} + + # The playbook hands vm.swappiness to the kernel_settings role, as the Solr + # Reference Guide recommends, so that the kernel keeps the Java heap in RAM. + - name: 'cat /proc/sys/vm/swappiness' + ansible.builtin.slurp: + src: '/proc/sys/vm/swappiness' + register: '__molecule__apache_solr_swappiness_result' + + - name: 'Assert vm.swappiness is 1' + ansible.builtin.assert: + that: + - '__molecule__apache_solr_swappiness == "1"' + fail_msg: 'vm.swappiness is {{ __molecule__apache_solr_swappiness }}' + vars: + __molecule__apache_solr_swappiness: '{{ + __molecule__apache_solr_swappiness_result["content"] | b64decode | trim + }}' diff --git a/playbooks/README.md b/playbooks/README.md index d1b76a636..8f3d5fc23 100644 --- a/playbooks/README.md +++ b/playbooks/README.md @@ -59,6 +59,7 @@ Calls the following roles (in order): Calls the following roles (in order): +* [kernel_settings](https://github.com/Linuxfabrik/lfops/tree/main/roles/kernel_settings): `apache_solr__skip_kernel_settings` * [apps](https://github.com/Linuxfabrik/lfops/tree/main/roles/apps) * [apache_solr](https://github.com/Linuxfabrik/lfops/tree/main/roles/apache_solr) diff --git a/playbooks/apache_solr.yml b/playbooks/apache_solr.yml index 0532094b0..e4176b523 100644 --- a/playbooks/apache_solr.yml +++ b/playbooks/apache_solr.yml @@ -19,6 +19,11 @@ roles: + - role: 'linuxfabrik.lfops.kernel_settings' + kernel_settings__sysctl__dependent_var: '{{ apache_solr__kernel_settings__sysctl__dependent_var | d([]) }}' + when: + - 'not apache_solr__skip_kernel_settings | d(false)' + - role: 'linuxfabrik.lfops.apps' apps__apps__dependent_var: '{{ apache_solr__apps__apps__dependent_var diff --git a/roles/apache_solr/README.md b/roles/apache_solr/README.md index e1c01422f..565661d0a 100644 --- a/roles/apache_solr/README.md +++ b/roles/apache_solr/README.md @@ -41,6 +41,7 @@ Solr 8 is EOL and only covered where existing installations still run it. Any [LFOps playbook](https://github.com/Linuxfabrik/lfops/blob/main/playbooks/README.md) that installs this role runs these for you. Optional ones can be disabled via the playbook's skip variables. * The tools that Solr's start script and the role need, such as `lsof` and `tar`, must be installed (role: [linuxfabrik.lfops.apps](https://github.com/Linuxfabrik/lfops/tree/main/roles/apps)). +* `vm.swappiness` must be set to 1, so that the kernel keeps the Java heap in RAM, as the [Solr Reference Guide](https://solr.apache.org/guide/solr/latest/deployment-guide/taking-solr-to-production.html#avoid-swapping-nix-operating-systems) recommends (role: [linuxfabrik.lfops.kernel_settings](https://github.com/Linuxfabrik/lfops/tree/main/roles/kernel_settings)). ## Tags diff --git a/roles/apache_solr/defaults/main.yml b/roles/apache_solr/defaults/main.yml index fa0b542c4..a2731d256 100644 --- a/roles/apache_solr/defaults/main.yml +++ b/roles/apache_solr/defaults/main.yml @@ -46,3 +46,10 @@ apache_solr__apps__apps__dependent_var: - name: 'bc' - name: 'lsof' - name: 'tar' + +# https://solr.apache.org/guide/solr/latest/deployment-guide/taking-solr-to-production.html#avoid-swapping-nix-operating-systems +# the kernel honours vm.swappiness continuously, so solr.service needs no +# z00-after-tuned.conf (see "systemd Drop-ins and Service Ordering" in CONTRIBUTING.md) +apache_solr__kernel_settings__sysctl__dependent_var: + - name: 'vm.swappiness' + value: 1