From 70f98dc19880bf35b24f8fab8b02d544a8587a75 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 24 Jul 2015 23:59:28 +0300 Subject: Check account on server has sudo --- yarns/100-willikins.yarn | 2 ++ yarns/900-implements.yarn | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'yarns') diff --git a/yarns/100-willikins.yarn b/yarns/100-willikins.yarn index 1ea8f24..3004019 100644 --- a/yarns/100-willikins.yarn +++ b/yarns/100-willikins.yarn @@ -5,5 +5,7 @@ backups. It is only ever accessed over ssh (including sftp). SCENARIO willikins backup server GIVEN server name is willikins + AND server has account ansible THEN server responds to ping AND server hostname is as expected + AND server account has sudo diff --git a/yarns/900-implements.yarn b/yarns/900-implements.yarn index 2ffee04..7c40885 100644 --- a/yarns/900-implements.yarn +++ b/yarns/900-implements.yarn @@ -8,6 +8,11 @@ repeated for every step. IMPLEMENTS GIVEN server name is (.+) echo "SERVER=$MATCH_1" >> "$DATADIR/config.sh" +Set account name to use on server. + + IMPLEMENTS GIVEN server has account (.+) + echo "ACCOUNT=$MATCH_1" >> "$DATADIR/config.sh" + ## Ping Does the server respond to a ping? @@ -22,7 +27,17 @@ Does the server's hostname match its domain name? IMPLEMENTS THEN server hostname is as expected . "$DATADIR/config.sh" - ssh "$SERVER" hostname | grep -Fx "$SERVER" + ssh "$ACCOUNT@$SERVER" hostname | grep -Fx "$SERVER" + +## Ansible account + +Does the server have an account `ansible` that has passwordless sudo +access to root? + + IMPLEMENTS THEN server account has sudo + . "$DATADIR/config.sh" + ssh "$ACCOUNT@$SERVER" sudo -n id -u > "$DATADIR/id.out" + grep -F 0 "$DATADIR/id.out" ## Running command over ssh -- cgit v1.2.1