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:
fc9a2d03dc/tests/roles/bootstrap-host/defaults/main.yml (L106-L118)

Change-Id: Ie627a5b5ec3984ea6883e184f55a2fb2034e2d92
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2019-01-31 11:20:48 -06:00
parent fe309dc0c9
commit 6056124447
1 changed files with 20 additions and 5 deletions

View File

@ -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