Install ssh and apache userdirectory using salt

This is Thursday’s Assigment

Refer this for inital setup

https://omarbenchbana.com/en/salt-with-nginx-php-fpm-and-ufw/

First configure your salt to include the sshd_config

sudoedit /srv/salt/ssh/init.sls

https://raw.githubusercontent.com/obb12/apache-server/master/ssh.sls
then change your port in the config

sudoedit /srv/salts/ssh/sshd_config

https://raw.githubusercontent.com/obb12/apache-server/master/sshd_config

Next configure apache

sudoedit /srv/salt/apache/init.sls

apache2:
 pkg.installed

/var/www/html/index.html:
 file.managed:
   - source: salt://apache/default-index.html

/etc/apache2/mods-enabled/userdir.conf:
 file.symlink:
   - target: ../mods-available/userdir.conf

/etc/apache2/mods-enabled/userdir.load:
 file.symlink:
   - target: ../mods-available/userdir.load

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


Next enable cgi-bin scripts



install_apache:
   pkg.installed:
     - pkgs:
       - apache2
       - php-fpm
       - composer
/etc/apache2/mods-enabled/userdir.conf:
 file.symlink:
   - target: ../mods-available/userdir.conf
/usr/lib/cgi-bin/test.pl:
 file.managed:
   - source: salt://apache/test.pl
/etc/apache2/mods-enabled/userdir.load:
 file.symlink:
   - target: ../mods-available/userdir.load
/etc/apache2/mods-enabled/userdir.conf:
 file.symlink:
   - target: ../mods-available/userdir.conf

/etc/apache2/mods-enabled/cgid.load:
 file.symlink:
   - target: ../mods-available/cgid.load
/etc/apache2/mods-enabled/cgid.conf:
 file.symlink:
   - target: ../mods-available/cgid.conf

apache2service:
 service.running:
   - name: apache2
   - watch:
     - file: /etc/apache2/mods-enabled/userdir.conf
     - file: /etc/apache2/mods-enabled/userdir.load
     - file: /etc/apache2/mods-enabled/cgid.load
     - file: /etc/apache2/mods-enabled/cgid.conf

Write your Cgi script


 /srv/salt/apache/test.pl

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello, World.";


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.