From 60561244474b26a677ab716bda53838daa4f8ff1 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Thu, 31 Jan 2019 11:20:48 -0600 Subject: [PATCH] Add path variable for different distros This change removes the assumption that ip and iptables are always in the same location on any distro by setting the specific tool path per OS package manager type. This adapts the pattern set here: https://github.com/openstack/openstack-ansible/blob/fc9a2d03dc176eaa6ed1e314202583b0a8191302/tests/roles/bootstrap-host/defaults/main.yml#L106-L118 Change-Id: Ie627a5b5ec3984ea6883e184f55a2fb2034e2d92 Signed-off-by: Kevin Carter --- tests/test-nspawn-host-setup.yml | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/tests/test-nspawn-host-setup.yml b/tests/test-nspawn-host-setup.yml index 70cf0bb..3764976 100644 --- a/tests/test-nspawn-host-setup.yml +++ b/tests/test-nspawn-host-setup.yml @@ -17,6 +17,21 @@ hosts: localhost connection: local become: true + vars: + nspawn_network_utils: + apt: + iptables: /sbin/iptables + ethtool: /sbin/ethtool + yum: + iptables: /usr/sbin/iptables + ethtool: /usr/sbin/ethtool + zypper: + iptables: /usr/sbin/iptables + ethtool: /sbin/ethtool + emerge: + iptables: /usr/sbin/iptables + ethtool: /usr/sbin/ethtool + pre_tasks: - name: Gather facts setup: @@ -125,12 +140,12 @@ RemainAfterExit: yes service_type: oneshot execstarts: - - "-/sbin/iptables -A POSTROUTING -t mangle -p tcp --dport 22 -j CHECKSUM --checksum-fill" - - "-/sbin/iptables -t nat -A POSTROUTING -o {{ ansible_default_ipv4.interface }} -j MASQUERADE" - - "-/sbin/ethtool -K br-mgmt gso off sg off tso off tx off" + - "-{{ nspawn_network_utils[ansible_pkg_mgr]['iptables'] }} -A POSTROUTING -t mangle -p tcp --dport 22 -j CHECKSUM --checksum-fill" + - "-{{ nspawn_network_utils[ansible_pkg_mgr]['iptables'] }} -t nat -A POSTROUTING -o {{ ansible_default_ipv4.interface }} -j MASQUERADE" + - "-{{ nspawn_network_utils[ansible_pkg_mgr]['ethtool'] }} -K br-mgmt gso off sg off tso off tx off" execstops: - - "/sbin/iptables -D POSTROUTING -t mangle -p tcp --dport 22 -j CHECKSUM --checksum-fill" - - "/sbin/iptables -t nat -D POSTROUTING -o {{ ansible_default_ipv4.interface }} -j MASQUERADE" + - "{{ nspawn_network_utils[ansible_pkg_mgr]['iptables'] }} -D POSTROUTING -t mangle -p tcp --dport 22 -j CHECKSUM --checksum-fill" + - "{{ nspawn_network_utils[ansible_pkg_mgr]['iptables'] }} -t nat -D POSTROUTING -o {{ ansible_default_ipv4.interface }} -j MASQUERADE" enabled: yes state: started systemd_tempd_prefix: openstack