Execution
Date 18 Dec 2025 12:00:43 +0000
Duration 00:00:03.51
Controller ssh-gw-4.layershift.com
User root
Versions
Ansible 2.16.11
ara 1.7.3 / 1.7.3
Python 3.10.10
Summary
1 Hosts
3 Tasks
3 Results
1 Plays
1 Files
0 Records

File: /home/ssh-gateway/ansible/kuly/zz-compare-sysctl.yaml

---
- name: Check sysctl values against /proc/sys
  hosts: all
  gather_facts: false
  vars:
    required:
      vm.dirty_ratio: 30
      vm.dirty_background_ratio: 10
      vm.swappiness: 1
      vm.force_cgroup_v2_swappiness: 1
      net.core.somaxconn: 4096
      net.ipv6.ip_nonlocal_bind: 1

  tasks:
    - name: Slurp current value from /proc/sys
      ansible.builtin.slurp:
        src: "/proc/sys/{{ item.key | replace('.', '/') }}"
      register: proc_vals
      loop: "{{ required | dict2items }}"

    - name: Build dictionary of live values
      ansible.builtin.set_fact:
        live: "{{ live | default({}) | combine({item.item.key: (item.content | b64decode).strip()}) }}"
      loop: "{{ proc_vals.results }}"

    - name: Show ONLY the parameters that differ
      ansible.builtin.debug:
        msg: "MISMATCH: {{ item.key }}  live={{ live[item.key] }}  required={{ item.value }}"
      loop: "{{ required | dict2items }}"
      changed_when: live[item.key] != item.value | string
      when: live[item.key] != item.value | string