summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2019-04-04 16:38:39 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2019-04-04 16:38:39 +0200
commit6fa6e953424d090626c02f0aeeb204580dc407dc (patch)
treec161acc1a39936723007fda027be438cdf9dbf66
parent8233bf7e9a1903fe6c35c2f45b5f48c223a34ead (diff)
ansible: gsm-tester: Install osmo-gsm-tester_netns_setup.sh
-rwxr-xr-xansible/roles/gsm-tester/files/osmo-gsm-tester_netns_setup.sh22
-rw-r--r--ansible/roles/gsm-tester/tasks/main.yml13
2 files changed, 35 insertions, 0 deletions
diff --git a/ansible/roles/gsm-tester/files/osmo-gsm-tester_netns_setup.sh b/ansible/roles/gsm-tester/files/osmo-gsm-tester_netns_setup.sh
new file mode 100755
index 0000000..1600c44
--- /dev/null
+++ b/ansible/roles/gsm-tester/files/osmo-gsm-tester_netns_setup.sh
@@ -0,0 +1,22 @@
+#!/bin/bash -e
+
+ifname="$1"
+netns="$2"
+shift
+shift
+
+
+
+if [ -f "/var/run/netns/${netns}" ]; then
+ echo "netns $netns already exists"
+else
+ echo "Creating netns $netns"
+ ip netns add "$netns"
+fi
+
+if [ -d "/sys/class/net/${ifname}" ]; then
+ echo "Moving iface $ifname to netns $netns"
+ ip link set $ifname netns $netns
+else
+ ip netns exec $netns ls "/sys/class/net/${ifname}" >/dev/null && echo "iface $ifname already in netns $netns"
+fi
diff --git a/ansible/roles/gsm-tester/tasks/main.yml b/ansible/roles/gsm-tester/tasks/main.yml
index c9b7429..34846a5 100644
--- a/ansible/roles/gsm-tester/tasks/main.yml
+++ b/ansible/roles/gsm-tester/tasks/main.yml
@@ -254,6 +254,19 @@
dest: /etc/sudoers.d/osmo-gsm-tester_netns_exec
mode: 0440
+- name: create a wrapper script to move modem net iface into its own netns
+ copy:
+ src: osmo-gsm-tester_netns_setup.sh
+ dest: /usr/local/bin/osmo-gsm-tester_netns_setup.sh
+ mode: 755
+
+- name: allow osmo-gsm-tester sudo osmo-gsm-tester_netns_setup.sh
+ copy:
+ content: |
+ %osmo-gsm-tester ALL=(root) NOPASSWD: /usr/local/bin/osmo-gsm-tester_netns_setup.sh
+ dest: /etc/sudoers.d/osmo-gsm-tester_netns_setup
+ mode: 0440
+
- name: logrotate limit filesizes to 10M
copy:
content: "maxsize 10M"