diff --git a/ansible/roles/host_setup/tasks/disable_icmp_redirect.yml b/ansible/roles/host_setup/tasks/disable_icmp_redirect.yml new file mode 100644 index 000000000..1a0e89987 --- /dev/null +++ b/ansible/roles/host_setup/tasks/disable_icmp_redirect.yml @@ -0,0 +1,58 @@ +--- +# Copyright 2024, Rackspace Technology, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Set net.ipv4.conf.all.accept_redirects to 0 + ansible.posix.sysctl: + name: net.ipv4.conf.all.accept_redirects + value: 0 + sysctl_set: true + become: true + +- name: Set net.ipv4.conf.default.accept_redirects to 0 + ansible.posix.sysctl: + name: net.ipv4.conf.default.accept_redirects + value: 0 + sysctl_set: true + become: true + +- name: Set net.ipv4.conf.all.secure_redirects to 0 + ansible.posix.sysctl: + name: net.ipv4.conf.all.secure_redirects + value: 0 + sysctl_set: true + become: true + +- name: Set net.ipv4.conf.default.secure_redirects to 0 + ansible.posix.sysctl: + name: net.ipv4.conf.default.secure_redirects + value: 0 + sysctl_set: true + become: true + +- name: Update /etc/sysctl.conf + ansible.builtin.lineinfile: + path: /etc/sysctl.conf + regexp: "{{ item.regexp }}" + line: "{{ item.line }}" + state: present + with_items: + - {regexp: '^net.ipv4.conf.all.accept_redirects', line: 'net.ipv4.conf.all.accept_redirects = 0'} + - {regexp: '^net.ipv4.conf.default.accept_redirects', line: 'net.ipv4.conf.default.accept_redirects = 0'} + - {regexp: '^net.ipv4.conf.all.secure_redirects', line: 'net.ipv4.conf.all.secure_redirects = 0'} + - {regexp: '^net.ipv4.conf.default.secure_redirects', line: 'net.ipv4.conf.default.secure_redirects = 0'} + +- name: Apply changes to /etc/sysctl.conf + ansible.builtin.command: sysctl -p /etc/sysctl.conf + become: true diff --git a/ansible/roles/host_setup/tasks/main.yml b/ansible/roles/host_setup/tasks/main.yml index 544c07c3c..0c17d9988 100644 --- a/ansible/roles/host_setup/tasks/main.yml +++ b/ansible/roles/host_setup/tasks/main.yml @@ -170,3 +170,6 @@ - name: Install RAID controller CLI tools ansible.builtin.include_tasks: raid_cli_tools.yml + +- name: Disable ICMP Redirects + ansible.builtin.include_tasks: disable_icmp_redirect.yml