Skip to content

Commit 9b65ea4

Browse files
committed
add manual steps to vm bootstrap script
1 parent 29a85e4 commit 9b65ea4

File tree

2 files changed

+22
-45
lines changed

2 files changed

+22
-45
lines changed

operational/vm-bootstrap.md

-20
This file was deleted.

operational/vm-bootstrap.sh

+22-25
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
#!/usr/bin/env bash
2-
set -ex
2+
set -e
33

44
if [[ $# -ne 2 ]]; then
5-
echo "Usage: $0 <gateway_name> <gcp_project>"
6-
exit 1
5+
echo "Usage: $0 <gateway_name> <gcp_project>"
6+
exit 1
77
fi
88

9-
if [[ ! -f "/root/sa.json" ]]; then
10-
echo "You need to place appropriate sa json at /root/sa.json before running this script."
11-
fi
12-
13-
mkdir -p /var/log/naisdevice
14-
chmod 755 /var/log/naisdevice
15-
169
name="$1"
1710
project="$2"
18-
proxy=""
1911
proxy_yaml=""
2012
role="gateways"
13+
# onprem settings
2114
if [[ $(hostname) =~ a30drvl ]]; then
22-
# onprem settings
23-
role="onprem_gateways"
24-
proxy="http://webproxy-internett.nav.no:8088"
25-
proxy_yaml="proxy_env:
26-
https_proxy: $proxy"
15+
if [[ ! -f "/root/sa.json" ]]; then
16+
echo "You need to place appropriate sa json at /root/sa.json before running this script."
17+
exit 1
18+
fi
19+
20+
role="onprem_gateways"
21+
proxy_yaml="proxy_env:
22+
https_proxy: http://webproxy-internett.nav.no:8088"
23+
export HTTPS_PROXY="http://webproxy-internett.nav.no:8088"
2724
fi
2825

29-
# Install Ansible
26+
apt-get install --yes ca-certificates curl apt-transport-https gnupg
27+
28+
curl -L https://europe-north1-apt.pkg.dev/doc/repo-signing-key.gpg | gpg --dearmor >/etc/apt/trusted.gpg.d/nais-ppa-google-artifact-registry.gpg
29+
echo 'deb [arch=amd64] https://europe-north1-apt.pkg.dev/projects/naisdevice controlplane main' >/etc/apt/sources.list.d/europe_north1_apt_pkg_dev_projects_naisdevice.list
30+
3031
apt update --yes
31-
apt install ansible --yes
32+
apt install ansible gateway-agent --yes
3233

33-
# Configure ansible inventory
34-
cat <<EOF > /root/ansible-inventory.yaml
34+
cat <<EOF >/root/ansible-inventory.yaml
3535
all:
3636
vars:
3737
name: $name
@@ -43,8 +43,5 @@ all:
4343
$(hostname):
4444
EOF
4545

46-
# Set up cron for Ansible
47-
if ! crontab -l 2>/dev/null | grep "ansible-pull"; then
48-
( crontab -l 2>/dev/null; echo "*/5 * * * * [ \$(pgrep ansible-pull -c) -eq 0 ] && HTTPS_PROXY=$proxy /usr/bin/ansible-pull --only-if-changed -U https://github.com/nais/device ansible/site.yml -i /root/ansible-inventory.yaml >> /var/log/naisdevice/ansible.log") | crontab -
49-
fi
50-
46+
echo "add the following line to crontab:"
47+
echo "*/5 * * * * [ \$(pgrep ansible-pull -c) -eq 0 ] && HTTPS_PROXY=$HTTPS_PROXY /usr/bin/ansible-pull --only-if-changed -U https://github.com/nais/device ansible/site.yml -i /root/ansible-inventory.yaml >> /var/log/naisdevice/ansible.log"

0 commit comments

Comments
 (0)