Installing LAMP stack using SALT stack (h6)

In this exercise I am going to install LAMP with a help of salt. My virtual ubuntu server at digital ocean will work as a master and give orders to guest os slave which is ubuntu server.
Master: Digital ocean droplet / Ubuntu server 18.04 /1GB memory / 25GB Disk
Slave: Guest OS Ubuntu server 18.04 on Windows 10 host PC

Beginning by cloning my git repository on guest ubuntu so I can use my shell script to make it a slave. After the script has run I accepted the key on my master. Now I have working master-slave architecture.

I wanted to install LAMP only by applying a highstate so everything would be fully automatized. To correctly do this without any bigger hassle on the ubuntu guest machine, I wanted to test every state before applying them so I manually tested every state first at another virtual machine.
Everything worked just fine except mysql.

Simple sls file to install apache2.
Work like a charm.
Php state was little bit more complex but it worked well.
Modified dir.conf to test out php on web.
Php and apache working, mysql to go.

I left mysql installation for last on purpose, because I remembered it might be a tricky one. I remembered there were something annoying with mysql passwords at the installation, and wondered what would be the easiest way to install it.
Fortunately I found article at which was very helpful:
The thing was preseeding, answering questions on installation beforehand.

So this was the state for installing mysql and answering the questions beforehand. In addition to mysql pkgs, debconf-utils pkg was required.

At first when I applied that state, it froze completely. I got no feedback from salt master whether the state were correctly applied or not. I checked with salt-run and saw that the job was still running but nothing happened. I am not sure what was going on there, but I had to quit for that day so I shut everything down.
Few days after that, I came back and changed the password on the sls file and tried to apply it again. It didn’t freeze this time, but I still got some errors.

Apparently the preseeding part succeeded, but mysql installation had some problems. That problem might be caused by faulty installation. So I removed the broken installation.
I navigated to updates directory and removed everything and after that ran apt-get update. After this, I applied the mysql state again at master, and now it fully succeeded! I could log in on mysql by using the password I had been set up before on the sls file.

Time for highstate.

First error occured. Fixed by changing names of the ID’s.
After fixing the previous error and 54 seconds LAMP was successfully installed on guest ubuntu minion.
Apache working on ubuntu minion.
Php working as well. I forgot to create a info.php test file on php.sls, so I had to manually add it to the state afterwards.
Mysql works too. No struggle with the password, I just typed in the password I had previously set on the mysql state. Now I have fully functioning LAMP installation which I may apply on any slave and have fully functioning webserver just in 54 seconds.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s