This document provides information on the implementation of Tech stack installation automation script, which aids in clear understanding on how this script was made.Understanding the implementation of this scripts also helps in any future modifications and any future bugs related to version updates.
Here’s an overview of the repository structure:
Usage
TechStackInstallation.py
install.conf
Variables required for installation parameters such as installation paths, application versions, network interfaces
TechStackInstallation.py
(when project name is specified as command-line argument) to process the variables and declare them in run-time(this will be explained clearly in the later sections).configuration.conf:
Variables such as hostnames, ports to be allowed through firewall, configuration file changes, host file additions required for configuration of installed applications as per the project’s requirements are specified here in the same format as in the install.conf
This file is intended to be used by the ConfigureScript.py
when passed with the project name.
databases.conf
haproxy.conf
haproxyErrors.conf
monitoring.conf
TechStackInstallation.py
Each application that needs to be installed is defined as an individual function inside this script and involves inclusion and declaration of required variables such as versions, urls, hostname, file paths, required passwords. These variables are declared at runtime using exec() function by passing each line from the .conf files provided and as each line is declared as a <var> = <value> and when exec() function interprets it, it will be declared as a variable. The value is declared as a string by enclosing the value between double quotes while passing the line to exec()
funtion.
This script accepts project name and application names as command-line arguments for applications to be installed. The specified project name with suffix as COnfigurationFiles folder needs to be present in the directory where the script is being run. So, that it accepts the project specific parameters from the files provided. (Make sure to change the variables for the project’s requirements)
Example::
python3 TechStackInstallation.py eev haproxy tomcat mysql scylla
ConfigureScript.py
It follows the same structure as TechStackInstallation.py
while declaring the variables required to configure the installed Applications.
The variables from configuration.conf
will be read here and gets declared to use in the configuration script.
Variables with values such as .sql
file names, and other schema file names and basedata files. And usernames and passwords required to authenticate with mysql and cql shells.
Example:: python3 ConfigureScript.py eev confiration.conf
StartStopScript.py
This script is designed to help in starting and stopping installed tech stack in an order databases, messaging queues, tomcat server, haproxy load balancer.
This script accepts a single command-line argument which is of any action from start, stop, restart.
Example:
python3 StartStopScript.py start
MonitoringSetup.py
The script is coded just as TechStackInstallation.py which reads it’s parameter variables from ConfigurationFiles/monitoring.py
and it is defined with functions each installing exporters and grafana, prometheus.
This script accepts command-line arguments to install required exporters or tools based on provided arguments.
Example:
python3 MonitoringSetup.py monitoring.conf node_exporter mysql blackbox-exporter pushgateway grafana prometheus grafana-mimir haproxy-exporter
Service files for haproxy, tomcat are created before hand with variable substitutions inplace to provide for custom path configurations for installed binaries and environments.
Service files for several exporters(node_exporter, mysql_exporter, blackbox-exporter, mimir, prometheus, pushgateway) are also defined here to copy to the /etc/systemd/system
path for correct installation.
Base configuration files for prometheus, mimir in yaml format are pre-defined to be modified in the script while configuring them as per our requirements defined in the conf files for the applications or for data source: prometheus
The service files defined with variable subsituttions are then get called in the script files where every variables gets initialized from the conf files and the service files will then be substituted by the .format() function to place respective values in place.