diff options
author | Aaron LI <aly@aaronly.me> | 2018-02-14 00:18:24 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2018-02-14 00:20:47 +0800 |
commit | 7a63ffd9493b0a8b636de26b8f0954cf08a2b9d9 (patch) | |
tree | ba9e2c9005f630814681b3a10bfc9a00a2e3bac4 /bootstrap.sh | |
download | ansible-dfly-vps-7a63ffd9493b0a8b636de26b8f0954cf08a2b9d9.tar.bz2 |
Init ansible playbook for DFly VPS bootstrap
Diffstat (limited to 'bootstrap.sh')
-rwxr-xr-x | bootstrap.sh | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100755 index 0000000..cc0a6a3 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# +# Copyright (c) 2018 Aaron LI +# MIT License +# +# 2018-01-25 +# + +ROOTDIR="${0%/*}" +PLAYBOOK="${ROOTDIR}/bootstrap.yml" +echo "Playbook directory: ${ROOTDIR}" +echo "Playbook: ${PLAYBOOK}" + +SSHDIR="${ROOTDIR}/ssh" +SSHKEY="${SSHDIR}/ansible.key" +if [ -f "${SSHKEY}" ]; then + echo "ERROR: SSH key already exists: ${SSHKEY}" + echo "Target machine already been bootstrapped?" +else + [ ! -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 Python2.7 ..." + ansible vultr -u root \ + -m raw -a "pkg install -y python27" + 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 |