考虑一下:
我有一个禁用 ipv6 的 RHEL8 服务器。我正在运行一些用于安全合规性的 ansible 脚本。
Ansible 检查如下所示:
- name: "SCORED | 3.1.1 | PATCH | Ensure IP forwarding is disabled"
block:
- name: "SCORED | 3.1.1 | PATCH | Ensure IP forwarding is disabled | Disable IPv4 forwarding"
sysctl:
name: '{{ item.name }}'
value: '{{ item.value }}'
state: present
reload: yes
ignoreerrors: yes
with_items:
- { name: net.ipv4.ip_forward, value: 0 }
- { name: net.ipv4.route.flush, value: 1}
notify:
- sysctl flush ipv4 route table
- name: "SCORED | 3.1.1 | PATCH | Ensure IP forwarding is disabled | Disable IPv6 forwarding"
sysctl:
name: '{{ item.name }}'
value: '{{ item.value }}'
state: present
reload: yes
ignoreerrors: yes
with_items:
- { name: net.ipv6.conf.all.forwarding, value: 0 }
- { name: net.ipv6.route.flush, value: 1}
when:
- rhel8cis_ipv6_required
notify:
- sysctl flush ipv6 route table
when:
- not rhel8cis_is_router
- rhel8cis_rule_3_1_1
tags:
- level1
- sysctl
- patch
- rule_3.1.1
多变的
rhel8cis_ipv6_required 设置为 false。
被调用的处理程序如下所示:
- name: sysctl flush ipv4 route table
become: yes
sysctl:
name: net.ipv4.route.flush
value: 1
sysctl_set: yes
when: ansible_virtualization_type != "docker"
- name: sysctl flush ipv6 route table
become: yes
sysctl:
name: net.ipv6.route.flush
value: 1
sysctl_set: yes
when: ansible_virtualization_type != "docker"
playbook 的输出如下所示:
任务 [RHEL8_CIS:得分 | 3.1.1 | 补丁 | 确保禁用 IP 转发 | 禁用 IPv4 转发] ************************************************ ****************************************************** ****************************************** 好的:[alrha001.acc.vlkintern.nl] = > (item={'name': 'net.ipv4.ip_forward', 'value': 0}) 更改:[alrha001.acc.vlkintern.nl] => (item={'name': 'net.ipv4. route.flush','值':1})
任务 [RHEL8_CIS:得分 | 3.1.1 | 补丁 | 确保禁用 IP 转发 | 禁用 IPv6 转发] ********************************************** ****************************************************** ****************************************** 跳过:[alrha001.acc.vlkintern.nl] = > (item={'name': 'net.ipv6.conf.all.forwarding', 'value': 0}) 跳过:[alrha001.acc.vlkintern.nl] => (item={'name':' net.ipv6.route.flush','值':1})
RUNNING HANDLER [RHEL8_CIS : sysctl flush ipv4 route table] *************************************** ****************************************************** ****************************************************** ****************************************** [警告]:值 1(类型 int)字符串字段被转换为“1”(字符串类型)。如果这看起来不像您所期望的,请引用整个值以确保它不会改变。
致命:[alrha001.acc.vlkintern.nl]:失败!=> {"changed": false, "msg": "重新加载 sysctl 失败:fs.suid_dumpable = 0\nkernel.randomize_va_space = 2\nnet.ipv4.conf.all.forwarding = 0\nnet.ipv4.conf.all .send_redirects = 0\nnet.ipv4.conf.default.send_redirects = 0\nnet.ipv4.conf.all.accept_source_route = 0\nnet.ipv4.conf.default.accept_source_route = 0\nnet.ipv4.conf.all.accept_redirects = 0\nnet.ipv4.conf.default.accept_redirects = 0\nnet.ipv4.conf.all.secure_redirects = 0\nnet.ipv4.conf.default.secure_redirects = 0\nnet.ipv4.conf.all.log_martians = 1 \nnet.ipv4.conf.default.log_martians = 1\nnet.ipv4.icmp_echo_ignore_broadcasts = 1\nnet.ipv4.icmp_ignore_bogus_error_responses = 1\nnet.ipv4.conf.all.rp_filter = 1\nnet.ipv4.conf.default.rp_filter = 1\nnet.ipv4.tcp_syncookies = 1\nnet.ipv4.route.flush = 1\nnet.ipv4。
这就是我完全困惑的地方。如您所见,执行了 ipv4 的处理程序。致命输出中显示的所有变量都与 ipv4 相关。然而,最后,处理程序抱怨它找不到 ipv6 文件。这是正确的,因为在此服务器上未启用 ipv6。
这里有什么问题?