diff options
author | Lars Wirzenius <liw@liw.fi> | 2015-07-24 23:59:28 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2015-07-24 23:59:28 +0300 |
commit | 70f98dc19880bf35b24f8fab8b02d544a8587a75 (patch) | |
tree | bc6f2a0792b4e36462229308a03613bbdcff2402 | |
parent | cde6831504c83769199462126ed635bd5177d821 (diff) | |
download | ansibleness-70f98dc19880bf35b24f8fab8b02d544a8587a75.tar.gz |
Check account on server has sudo
-rw-r--r-- | yarns/100-willikins.yarn | 2 | ||||
-rw-r--r-- | yarns/900-implements.yarn | 17 |
2 files changed, 18 insertions, 1 deletions
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 |