aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2019-09-19 10:11:08 +0800
committerAaron LI <aly@aaronly.me>2019-09-19 10:11:08 +0800
commit976bbccc5c22cd8e22563a902e24c489e3431b92 (patch)
tree5737b92665c0a049d25e27bd0d9ddd8ff78adc65
parent428df584a5de76dde72e4cd44d51b565a986378e (diff)
downloadansible-dfly-vps-976bbccc5c22cd8e22563a902e24c489e3431b92.tar.bz2
bootstrap.sh: Do not generate SSH key if exists
Allow to bootstrap host again after reinstallation (for example).
-rwxr-xr-xbootstrap.sh28
1 files changed, 13 insertions, 15 deletions
diff --git a/bootstrap.sh b/bootstrap.sh
index 242f184..18404f0 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -13,23 +13,21 @@ echo "Playbook: ${PLAYBOOK}"
SSHDIR="${ROOTDIR}/private/ssh"
SSHKEY="${SSHDIR}/ansible.key"
-if [ -f "${SSHKEY}" ]; then
- echo "ERROR: SSH key already exists: ${SSHKEY}"
- echo "Target machine already been bootstrapped?"
-else
+if [ ! -f "${SSHKEY}" ]; then
[ ! -d "${SSHDIR}" ] && mkdir -v "${SSHDIR}"
echo "Generating SSH key ..."
ssh-keygen -t ed25519 -C "ansible" -f "${SSHKEY}"
echo "Generated SSH key: ${SSHKEY}"
- echo "Bootstrap target by installing Python ..."
- ansible vultr -u root \
- -m raw -a "pkg update; pkg install -y python3"
- ansible-playbook \
- --verbose --diff \
- --ask-pass --ask-become-pass \
- "${PLAYBOOK}"
- echo "Bootstrapped the target machine!"
- ansible vultr -u ansible -m ping
- ansible vultr -u ansible -m command -a whoami
- ansible vultr -u ansible -m command -a whoami -b
fi
+
+echo "Bootstrap target by installing Python ..."
+ansible vultr -u root \
+ -m raw -a "pkg update; pkg install -y python3"
+ansible-playbook \
+ --verbose --diff \
+ --ask-pass --ask-become-pass \
+ "${PLAYBOOK}"
+echo "Bootstrapped the target machine!"
+ansible vultr -u ansible -m ping
+ansible vultr -u ansible -m command -a whoami
+ansible vultr -u ansible -m command -a whoami --become