From 224e6acb3ab4a8b0507349d7498d57e713fda197 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Thu, 9 Feb 2017 17:28:44 +0900 Subject: [PATCH 1/2] use ansible sysctl module for config ip forwarding --- roles/kubernetes/preinstall/tasks/main.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/roles/kubernetes/preinstall/tasks/main.yml b/roles/kubernetes/preinstall/tasks/main.yml index e7955ac76..4737801d9 100644 --- a/roles/kubernetes/preinstall/tasks/main.yml +++ b/roles/kubernetes/preinstall/tasks/main.yml @@ -140,14 +140,10 @@ tags: bootstrap-os - name: Enable ip forwarding - lineinfile: - dest: /etc/sysctl.d/99-sysctl.conf - regexp: '^net.ipv4.ip_forward=' - line: 'net.ipv4.ip_forward=1' + sysctl: + name: net.ipv4.ip_forward + value: 1 state: present - create: yes - backup: yes - validate: 'sysctl -f %s' tags: bootstrap-os - name: Write openstack cloud-config From 331957c9a8b9fc30662381921796a0a0f210e797 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Thu, 9 Feb 2017 18:16:52 +0900 Subject: [PATCH 2/2] follow sysctl.conf file symlink if linked --- roles/kubernetes/preinstall/tasks/main.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/roles/kubernetes/preinstall/tasks/main.yml b/roles/kubernetes/preinstall/tasks/main.yml index 4737801d9..41a90e29f 100644 --- a/roles/kubernetes/preinstall/tasks/main.yml +++ b/roles/kubernetes/preinstall/tasks/main.yml @@ -139,8 +139,25 @@ when: disable_ipv6_dns and not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"] tags: bootstrap-os +- name: set default sysctl file path + set_fact: + sysctl_file_path: "/etc/sysctl.d/99-sysctl.conf" + tags: bootstrap-os + +- name: Stat sysctl file configuration + stat: path={{sysctl_file_path}} + register: sysctl_file_stat + tags: bootstrap-os + +- name: Change sysctl file path to link source if linked + set_fact: + sysctl_file_path: "{{sysctl_file_stat.stat.lnk_source}}" + when: sysctl_file_stat.stat.islnk is defined and sysctl_file_stat.stat.islnk + tags: bootstrap-os + - name: Enable ip forwarding sysctl: + sysctl_file: "{{sysctl_file_path}}" name: net.ipv4.ip_forward value: 1 state: present