summaryrefslogtreecommitdiffstats
path: root/ansible/roles/gsm-tester
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2020-02-11 16:05:29 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2020-02-11 19:12:46 +0100
commit9562073194fdc838825b5d960fb1ba256ec4c493 (patch)
treeb0135670f953199100223c8ced685483cc82bc9d /ansible/roles/gsm-tester
parenta264f9fcddeff25626cf6ef5b59317751ae5f763 (diff)
gsm-tester: Install helper scripts and sudoers.d files from git repo
Let's avoid duplicating and having to add manually the files here every time a new helper is required by osmo-gsm-tester. Change-Id: Ibbdd291f4c3f7aecdd5118cc2b3b35edaddf7c09
Diffstat (limited to 'ansible/roles/gsm-tester')
-rwxr-xr-xansible/roles/gsm-tester/files/osmo-gsm-tester_netns_exec.sh5
-rwxr-xr-xansible/roles/gsm-tester/files/osmo-gsm-tester_netns_setup.sh22
-rw-r--r--ansible/roles/gsm-tester/files/osmo-gsm-tester_setcap_net_admin.sh2
-rwxr-xr-xansible/roles/gsm-tester/files/osmo-gsm-tester_setcap_net_raw.sh3
-rw-r--r--ansible/roles/gsm-tester/tasks/main.yml74
5 files changed, 25 insertions, 81 deletions
diff --git a/ansible/roles/gsm-tester/files/osmo-gsm-tester_netns_exec.sh b/ansible/roles/gsm-tester/files/osmo-gsm-tester_netns_exec.sh
deleted file mode 100755
index 336b746..0000000
--- a/ansible/roles/gsm-tester/files/osmo-gsm-tester_netns_exec.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-netns="$1"
-shift
-#TODO: Later on I may want to call myself with specific ENV and calling sudo in order to run inside the netns but with dropped privileges
-ip netns exec $netns "$@"
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
deleted file mode 100755
index 1600c44..0000000
--- a/ansible/roles/gsm-tester/files/osmo-gsm-tester_netns_setup.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/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/files/osmo-gsm-tester_setcap_net_admin.sh b/ansible/roles/gsm-tester/files/osmo-gsm-tester_setcap_net_admin.sh
deleted file mode 100644
index 60e527a..0000000
--- a/ansible/roles/gsm-tester/files/osmo-gsm-tester_setcap_net_admin.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-/sbin/setcap cap_net_admin+ep "$1"
diff --git a/ansible/roles/gsm-tester/files/osmo-gsm-tester_setcap_net_raw.sh b/ansible/roles/gsm-tester/files/osmo-gsm-tester_setcap_net_raw.sh
deleted file mode 100755
index 1f3a727..0000000
--- a/ansible/roles/gsm-tester/files/osmo-gsm-tester_setcap_net_raw.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-/sbin/setcap cap_net_raw+ep "$1"
diff --git a/ansible/roles/gsm-tester/tasks/main.yml b/ansible/roles/gsm-tester/tasks/main.yml
index 0a5a838..309c187 100644
--- a/ansible/roles/gsm-tester/tasks/main.yml
+++ b/ansible/roles/gsm-tester/tasks/main.yml
@@ -262,57 +262,33 @@
content: "@osmo-gsm-tester - rtprio 99"
dest: /etc/security/limits.d/osmo-gsm-tester_rtprio.conf
-- name: create a wrapper script to add CAP_NET_RAW
- copy:
- src: osmo-gsm-tester_setcap_net_raw.sh
- dest: /usr/local/bin/osmo-gsm-tester_setcap_net_raw.sh
- mode: 0755
-
-- name: allow osmo-gsm-tester sudo osmo-gsm-tester_setcap_net_raw.sh
- copy:
- content: |
- %osmo-gsm-tester ALL=(root) NOPASSWD: /usr/local/bin/osmo-gsm-tester_setcap_net_raw.sh
- dest: /etc/sudoers.d/osmo-gsm-tester_setcap_net_raw
- mode: 0440
-
-- name: create a wrapper script to add CAP_NET_ADMIN
- copy:
- src: osmo-gsm-tester_setcap_net_admin.sh
- dest: /usr/local/bin/osmo-gsm-tester_setcap_net_admin.sh
- mode: 0755
-
-- name: allow osmo-gsm-tester sudo osmo-gsm-tester_setcap_net_admin.sh
- copy:
- content: |
- %osmo-gsm-tester ALL=(root) NOPASSWD: /usr/local/bin/osmo-gsm-tester_setcap_net_admin.sh
- dest: /etc/sudoers.d/osmo-gsm-tester_setcap_net_admin
- mode: 0440
-
-- name: create a wrapper script to run processes on modem netns
- copy:
- src: osmo-gsm-tester_netns_exec.sh
- dest: /usr/local/bin/osmo-gsm-tester_netns_exec.sh
- mode: 0755
-
-- name: allow osmo-gsm-tester sudo osmo-gsm-tester_netns_exec.sh
- copy:
- content: |
- %osmo-gsm-tester ALL=(root) NOPASSWD: /usr/local/bin/osmo-gsm-tester_netns_exec.sh
- dest: /etc/sudoers.d/osmo-gsm-tester_netns_exec
- mode: 0440
+- name: setup osmo-gsm-tester repository
+ git:
+ repo: 'git://git.osmocom.org/osmo-gsm-tester'
+ dest: /root/osmo-gsm-tester
+ version: master
+ clone: yes
+ update: no
+ tags:
+ - osmo-gsm-tester
-- 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: 0755
+- name: Install osmo-gsm-tester script helpers to /usr/local/bin (PATH)
+ shell: |
+ mkdir -p /usr/local/bin/ && \
+ cp utils/bin/*.sh /usr/local/bin/
+ args:
+ chdir: /root/osmo-gsm-tester
+ tags:
+ - osmo-gsm-tester
-- 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: Install osmo-gsm-tester sudoers.d files to /etc/sudoers.d/ (PATH)
+ shell: |
+ mkdir -p /etc/sudoers.d/ && \
+ cp utils/sudoers.d/* /etc/sudoers.d/
+ args:
+ chdir: /root/osmo-gsm-tester
+ tags:
+ - osmo-gsm-tester
- name: logrotate limit filesizes to 10M
copy: