Browse Source

Set the ip tool path for each OS

The ip tool on different operating systems is in different paths. This
PR creates a hash with each distro family which is used to set the path
correctly across each distro.

Change-Id: I0f691865b569d7e8b72a15d45cd8547dea45d5d5
Signed-off-by: Kevin Carter <kevin@cloudnull.com>
Kevin Carter 2 months ago
parent
commit
d21a7d5d9f
1 changed files with 10 additions and 5 deletions
  1. 10
    5
      test-prepare-host.yml

+ 10
- 5
test-prepare-host.yml View File

@@ -107,9 +107,14 @@
107 107
   # such, we use a local connection and become.
108 108
   connection: local
109 109
   become: yes
110
+  vars:
111
+    iptool_path:
112
+      debian: "/sbin/ip"
113
+      gentoo: "/bin/ip"
114
+      redhat: "/usr/sbin/ip"
115
+      suse: "/bin/ip"
110 116
   vars_files:
111 117
     - test-vars.yml
112
-
113 118
   tasks:
114 119
     - name: Run the systemd-networkd role
115 120
       include_role:
@@ -176,15 +181,15 @@
176 181
               {% set veths = ['-/sbin/ethtool -K ' + (bootstrap_host_public_interface | default(ansible_default_ipv4['alias'])) + ' gso off sg off tso off tx off'] %}
177 182
               {% for interface in (bridges | default([])) %}
178 183
               {%   if interface is string %}
179
-              {%     set _ = veths.append('-/usr/sbin/ip link set ' + interface + ' up') %}
184
+              {%     set _ = veths.append('-' + iptool_path[ansible_os_family | lower] + ' link set ' + interface + ' up') %}
180 185
               {%     set _ = veths.append('-/sbin/ethtool -K ' + interface + ' gso off sg off tso off tx off') %}
181 186
               {%   else %}
182 187
               {%     set interface_name = (interface.name | default('br-mgmt')) %}
183
-              {%     set _ = veths.append('-/usr/sbin/ip link set ' + interface_name + ' up') %}
188
+              {%     set _ = veths.append('-' + iptool_path[ansible_os_family | lower] + ' link set ' + interface_name + ' up') %}
184 189
               {%     set _ = veths.append('-/sbin/ethtool -K ' + interface_name + ' gso off sg off tso off tx off') %}
185 190
               {%     if interface.veth_peer is defined %}
186
-              {%       set _ = veths.append('-/usr/sbin/ip link set ' + interface_name + '-veth up') %}
187
-              {%       set _ = veths.append('-/usr/sbin/ip link set ' + interface.veth_peer + ' up') %}
191
+              {%       set _ = veths.append('-' + iptool_path[ansible_os_family | lower] + ' link set ' + interface_name + '-veth up') %}
192
+              {%       set _ = veths.append('-' + iptool_path[ansible_os_family | lower] + ' link set ' + interface.veth_peer + ' up') %}
188 193
               {%       set _ = veths.append('-/sbin/ethtool -K ' + interface.veth_peer + ' gso off sg off tso off tx off') %}
189 194
               {%     endif %}
190 195
               {%   endif %}

Loading…
Cancel
Save