Managing servers: 2nd assignment

Making users’ homepages work with Apache

I have previously made a folder under Salt’s srv directory called ‘salt’. Now I created a folder called ‘apache’ and inside it a file called ‘init.sls’.

sudo mkdir apache

already in the /srv/salt directory:

cd apache
sudoedit init.sls

conffiedit1

I created a default homepage: sudoedit default-index.html

apache_code

Then I applied the state using: sudo salt ‘*’ sate.apply apache

apache_nowork

Oh no! It doesn’t work. Why is that. I went to check up on my file and noticed that I had forgotten a few lines of code. Fixed that…

conffiedit2_toimii

Applied the state again.

And now it works!

Trying to make PHP work on the users’ homepages

First I made a state called php.sls using code from Lauri Mattila as an example since he had gotten it to actually work.

php_state

So I made the state in order to test out whether it would work or not, since I’d had trouble with php when I tried installing it manually.

php_virhe

Got this error when I applied the state using: sudo salt ‘*’ state.apply apache/php
I realized I hadn’t edited the conf file, so I went and did that.

php_conf

Unfortunately the same error persisted after this, so I moved on to another task and decided to let this problem simmer for now and come back to it later.

Name based virtual hosting for Apache 

First I edited the hosts-file by adding this line: 127.0.0.1  test.com

Then I created a conf file for the virtual host.

virtual_host

Created an .sls -file which moves my new conf file to the right place and removes the default file.
Applied the state: sudo salt ‘*’ state.apply apache/virtualhost

And it works.

Automatically creating homepages for users

Created public_html.sls and index.html files under the srv/salt/apache directory.

/etc/skel/public_html/index.html:
file.managed:
– source: salt://apache/index.html
– makedirs: True

Applied the state.

 

Sources:

Course by Tero Karvinen

Apache user homepages automatically by Tero Karvinen

2nd assignment by Lauri Mattila

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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