Virtual Hosts for Apache Using SaltState
If you have build a LAMP stack with Salt, you will most likely want to actually deploy some websites to it! It only stands to reason. This is very simple and just requires that we make some Virtual Host configuration files.
A Virtual Host file can be this simple /srv/salt/lamp_server1/files/test.conf:
<VirtualHost *:80> DocumentRoot "/var/www/html/test" ServerName test.mydomain.com ErrorLog "/var/log/httpd/test_error_log" CustomLog "/var/log/httpd/test_access_log" common </VirtualHost>
Then we just need a state file to use this. We will want something specific to a server or cluster:
/etc/httpd/conf.d/test.conf: file.managed: - source: - salt://lamp_server1/files/test.conf - user: root - group: root - mode: 644
That's it. A very simple file. You can repeat these patterns for many websites on one server. For each site you can make an individual configuration file. Then add each configuration file into the init.sls state file.