Roman Krček e2a0d1f59b Add sysctl role
This new role will handle setting sysctl values.

It also handles cases when IPv6 setting is changed, but IPv6 is
not enabled on the system by skipping those settings.

This is an augmentation of previous patch:
Icccfc1c509179c3cfd59650b7917a637f9af9646

Related-bug: #1906306
Change-Id: I5d6cda3307b3d2f27c1b2995f28772523b203fe7
Signed-off-by: Roman Krček <roman.krcek@tietoevry.com>
2024-04-08 13:12:41 +02:00

21 lines
626 B
YAML

---
- name: Check IPv6 support
command: "{{ sysctl_path }} -n net.ipv6.conf.all.disable_ipv6"
register: ipv6_disabled
changed_when: false
- name: Setting sysctl values
become: true
vars:
should_set: "{{ item.value != 'KOLLA_UNSET' }}"
sysctl:
name: "{{ item.name }}"
state: "{{ should_set | ternary('present', 'absent') }}"
value: "{{ should_set | ternary(item.value, omit) }}"
sysctl_set: "{{ should_set }}"
sysctl_file: "{{ kolla_sysctl_conf_path }}"
with_items: "{{ settings }}"
when:
- item.value != 'KOLLA_SKIP'
- not ('ipv6' in item.name and ipv6_disabled.stdout | bool)