diff --git a/files/info.php.j2 b/files/info.php.j2 index fc5863b..147cebc 100644 --- a/files/info.php.j2 +++ b/files/info.php.j2 @@ -1 +1 @@ - + diff --git a/files/userdir.conf.j2 b/files/userdir.conf.j2 new file mode 100644 index 0000000..26bc2f4 --- /dev/null +++ b/files/userdir.conf.j2 @@ -0,0 +1,17 @@ + + UserDir public_html + UserDir disabled root + + + AllowOverride All + Options MultiViews Indexes SymLinksIfOwnerMatch + + Order allow,deny + Allow from all + + + Order deny,allow + Deny from all + + + diff --git a/localhost.yml b/localhost.yml index e69de29..09017d2 100644 --- a/localhost.yml +++ b/localhost.yml @@ -0,0 +1,20 @@ +--- +- hosts: all + become: true + vars_files: + - vars/default.yml + + tasks: + - include: tasks/lamp.yml + - include: tasks/userdir.yml + + handlers: + - name: Reload Apache + service: + name: apache2 + state: reloaded + + - name: Restart Apache + service: + name: apache2 + state: restarted diff --git a/tasks/lamp.yml b/tasks/lamp.yml index 6fdf9f1..64d36b0 100644 --- a/tasks/lamp.yml +++ b/tasks/lamp.yml @@ -12,18 +12,18 @@ file: path: "/var/www/{{ http_host }}" state: directory - owner: "{{ app_user }}" + owner: "{{ web_user }}" mode: '0755' - # - name: Set up Apache virtualhost - # template: - # src: "files/apache.conf.j2" - # dest: "/etc/apache2/sites-available/{{ http_conf }}" - # notify: Reload Apache +- name: Set up Apache virtualhost + template: + src: "files/apache.conf.j2" + dest: "/etc/apache2/sites-available/{{ http_conf }}" + notify: Reload Apache - # - name: Enable new site - # shell: /usr/sbin/a2ensite {{ http_conf }} - # notify: Reload Apache +- name: Enable new site + shell: /usr/sbin/a2ensite {{ http_conf }} + notify: Reload Apache - name: Disable default Apache site shell: /usr/sbin/a2dissite 000-default.conf diff --git a/tasks/userdir.yml b/tasks/userdir.yml new file mode 100644 index 0000000..a52eaca --- /dev/null +++ b/tasks/userdir.yml @@ -0,0 +1,11 @@ +--- +- name: Enable userdir + shell: /usr/sbin/a2mod userdir + notify: Reload Apache + +- name: Set up userdir virtualhost + template: + src: "files/userdir.conf.j2" + dest: "/etc/apache2/mods-enabled/userdir.conf" + notify: Reload Apache + diff --git a/vars/default.yml b/vars/default.yml new file mode 100644 index 0000000..ea05d20 --- /dev/null +++ b/vars/default.yml @@ -0,0 +1,7 @@ +--- +mysql_root_password: "mysql_root_password" +web_user: "www-data" +http_host: "" +http_conf: "root.conf" +http_port: "80" +disable_default: true