-
Notifications
You must be signed in to change notification settings - Fork 0
/
stage2-fedora.sh
executable file
·49 lines (45 loc) · 1.12 KB
/
stage2-fedora.sh
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
for i in "$@"
do
case $i in
id=*)
LINODE_ID="${i#*=}"
;;
git_repo=*)
GIT_REPO="${i#*=}"
;;
git_branch=*)
GIT_BRANCH="${i#*=}"
;;
*)
: # unknown option
;;
esac
done
# stash parameters as Ansible facts
mkdir -p /etc/ansible/facts.d
cat > /etc/ansible/facts.d/bootstrap.fact << EOF
{
"LINODE_ID": "$LINODE_ID",
"ANSIBLE_GIT_REPO" : "$GIT_REPO",
"ANSIBLE_GIT_BRANCH" : "$GIT_BRANCH"
}
EOF
# install ansible (note: ansible 2.5+ supports python 3.5+)
yum install -y libselinux-python
pip3 install --upgrade pip
/usr/local/bin/pip3 install ansible==2.5.10 # full pip3 path needed after upgrade
# run ansible bootstrap playbook
mkdir /var/lib/ansible/local
if [ -r /root/.vault_pass ]; then
ansible-pull --vault-password-file=/root/.vault_pass \
--checkout=${GIT_BRANCH} \
-d /var/lib/ansible/local \
-i localhost, \
-U $GIT_REPO
else
ansible-pull --checkout=${GIT_BRANCH} \
-d /var/lib/ansible/local \
-i localhost, \
-U $GIT_REPO
fi