3
TESTER_UNIT=${2:-hardening-apache-tests/0}
4
TARGET_IP=`juju-deployer -f ${UNIT_TO_TEST%/*}`
5
juju scp $TESTER_UNIT:/home/ubuntu/.ssh/id_rsa.pub /tmp/id_rsa.pub
6
juju scp /tmp/id_rsa.pub $UNIT_TO_TEST:/tmp/
7
juju run --unit $UNIT_TO_TEST "\
8
useradd -m -s /bin/bash -d /home/hiotest hiotest; \
9
install -m 700 -o hiotest -d /home/hiotest/.ssh; \
10
install -m 640 -o hiotest /tmp/id_rsa.pub /home/hiotest/.ssh/authorized_keys; \
11
echo 'hiotest ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/90-hiotest-user; \
12
sudo chmod 440 /etc/sudoers.d/90-hiotest-user;"
15
juju action do hardening-apache-tests/0 run-test test-name=serverspec:default target-ip=$TARGET_IP