blob: 718f42161da9a41a2096dc43d7ca6f6e472357e3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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}/private/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
|