Skip to content

Commit ccd2ccb

Browse files
Ryan FairclothAddon Factory template
andauthored
feat(deploy): auto install snapd if needed (#62)
Co-authored-by: Addon Factory template <[email protected]>
1 parent f786a3a commit ccd2ccb

File tree

2 files changed

+59
-6
lines changed

2 files changed

+59
-6
lines changed

deploy/deploy.sh

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,79 @@ realpath() {
2222
echo "$REALPATH"
2323
}
2424

25+
install_snapd_on_centos7() {
26+
yum -y install epel-release
27+
yum -y install snapd
28+
systemctl enable snapd
29+
systemctl start snapd
30+
sleep 10
31+
ln -s /var/lib/snapd/snap /snap
32+
}
33+
34+
install_snapd_on_centos8() {
35+
dnf -y install epel-release
36+
dnf -y install snapd
37+
systemctl enable snapd
38+
systemctl start snapd
39+
sleep 10
40+
ln -s /var/lib/snapd/snap /snap
41+
}
42+
43+
install_dependencies() {
44+
os_release=/etc/os-release
45+
if [ ! -f "$os_release" ] ; then
46+
echo "$os_release does not exist"
47+
exit 4
48+
fi
49+
50+
os_id=$(grep "^ID=" "$os_release" | sed -e "s/\"//g" | cut -d= -f2)
51+
os_version=$(grep "^VERSION_ID=" "$os_release" | sed -e "s/\"//g" | cut -d= -f2)
52+
if [ "$os_id" == "ubuntu" ] ; then
53+
echo 'Snap install not required'
54+
elif [ "$os_id" == "centos" ] && [[ "$os_version" = "7*" ]]; then
55+
install_snapd_on_centos7
56+
elif [ "$os_id" == "centos" ] && [[ "$os_version" = "8*" ]]; then
57+
install_snapd_on_centos8
58+
elif [ "$os_id" == "rhel" ] && [[ "$os_version" = "7*" ]]; then
59+
install_snapd_on_centos7
60+
elif [ "$os_id" == "rhel" ] && [[ "$os_version" = "8*" ]]; then
61+
install_snapd_on_centos8
62+
else
63+
echo "Unsupported operating system: $os_id $os_version"
64+
exit 4
65+
fi
66+
}
67+
2568
if [ "$USER" != "root" ];
2669
then
2770
echo "must be root try sudo"
2871
exit
2972
fi
3073

74+
3175
K8S=${K8S:-mk8s}
3276
if [ "$K8S" = "mk8s" ]; then
77+
78+
3379
if ! command -v snap &> /dev/null
3480
then
35-
echo "snap could not be found"
36-
exit
81+
install_dependencies
3782
fi
83+
3884
if ! command -v microk8s &> /dev/null
3985
then
40-
snap install microk8s --classic
86+
while ! snap install microk8s --classic &> /dev/null; do
87+
echo error installing mk8s using snap
88+
sleep 1
89+
done
90+
source ~/.bashrc
4191
microk8s status --wait-ready
4292
fi
4393
if command -v microk8s.helm3 &> /dev/null
4494
then
4595
microk8s enable helm3
4696
fi
47-
module_dns=$(sudo microk8s status -a dns)
97+
module_dns=$(microk8s status -a dns)
4898
if [ "$module_dns" = "disabled" ];
4999
then
50100
while [ ! -n "$RESOLVERIP" ]
@@ -58,7 +108,7 @@ if [ "$K8S" = "mk8s" ]; then
58108
fi
59109
fi
60110

61-
module_mlb=$(sudo microk8s status -a metallb)
111+
module_mlb=$(microk8s status -a metallb)
62112
if [ "$module_mlb" = "disabled" ];
63113
then
64114
while [ ! -n "$SHAREDIP" ]

docs/source/gettingstarted.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ Requirements (Splunk Enterprise/Enterprise Cloud)
2525
4. Verify the token using `curl <https://docs.splunk.com/Documentation/Splunk/8.1.3/Data/FormateventsforHTTPEventCollector>`_ Note: The endpoint must use a publicly trusted certificate authority.
2626
5. The SHARED IP address to be used for SNMP Traps. Note Simple and POC deployments will use the same IP as the host server if HA deployment will be used the IP must be in addition to the managment inteface of each cluster memember.
2727
6. Obtain the ip address of an internal DNS server able to resolve the Splunk Endpoint
28-
7. The "snap" command for your operating system
2928

3029

3130
Requirements (Splunk Infrastructure Monitoring)
@@ -58,6 +57,10 @@ Deploy SC4SNMP Interactive
5857
Deploy SC4SNMP non-interactive
5958
===================================================
6059

60+
This step will install SC4SNMP and its depdenencies including snapd, micrk8s and sck.
61+
This script has been tested with Centos 7, Centos 8, Redhat 8, and Ubuntu 20.04
62+
63+
6164
.. code-block:: bash
6265
6366
sudo \

0 commit comments

Comments
 (0)