Installing and configuring systemd with Salt


SaltMaster: DigitalOcean, 1gig, 1cpu, Ubuntu 18.04
SaltMinion: DigitalOcean, 1gig, 1cpu, Ubuntu 18.04


We are using Pkg-File-Service philosphy where you first install the package you need, test it. Then you move the preconfigured config file to your slave and test it and as last step you make sure the service will keep running.


Fast recap from last weeks blog. For detailed explanation check here.

sudo apt update
sudo apt -y install salt-master
sudo apt -y install salt-minion
sudoedit /etc/salt/minion
sudo systemctl restart salt-minion.service
sudo salt-key -A

Lets first make the folder tree for our apache on our master

sudo mkdir -p /srv/salt/apache

sudoedit /srv/salt/apache/init.sls

Add this into init.sls

sudo salt '*' state.highstate

Test it


Add an index.html in your masters apache folder write inside “Hello world”

sudoedit /srv/salt/apache/index.html

Then add more text on init.sls

sudoedit /srv/salt/apache/init.sls

Add this under the apache2:…

    - source: salt://apache/index.html

And test it. It should over write the default apache page

Allowing user to create websites

We need to activate the setting in apache that allows normal users to have folders in public web. It is done with

sudoedit /srv/salt/apache/init.sls

Adding this to the bottom of the file.

   - target: ../mods-available/userdir.conf

   - target: ../mods-available/userdir.load


We need to make sure that Apache keeps running and restarts itself only when absolutely needed. Meaning when the user edits its website. This we can do with service.running and watch.

sudoedit /srv/salt/apache/init.sls

And adding this as the last thing to the file.

   - name: apache2
   - watch:
     - file: /etc/apache2/mods-enabled/userdir.conf
     - file: /etc/apache2/mods-enabled/userdir.load

The end result should look like this

Test it last time.

Licence GPl v2 2018

Leave a Replay