aboutsummaryrefslogtreecommitdiffstats
path: root/roles/website
diff options
context:
space:
mode:
Diffstat (limited to 'roles/website')
-rw-r--r--roles/website/meta/main.yml8
-rw-r--r--roles/website/tasks/main.yml24
-rw-r--r--roles/website/templates/httpd.conf.j219
3 files changed, 51 insertions, 0 deletions
diff --git a/roles/website/meta/main.yml b/roles/website/meta/main.yml
new file mode 100644
index 0000000..f5af423
--- /dev/null
+++ b/roles/website/meta/main.yml
@@ -0,0 +1,8 @@
+
+# website ~~ roles/website/meta/main.yml
+# Meta parameters
+
+---
+
+dependencies:
+ - { role: httpd_pre, tags: "dependency" }
diff --git a/roles/website/tasks/main.yml b/roles/website/tasks/main.yml
new file mode 100644
index 0000000..7ac5d65
--- /dev/null
+++ b/roles/website/tasks/main.yml
@@ -0,0 +1,24 @@
+
+# website ~~ roles/website/tasks/main.yml
+# website setup
+
+---
+
+- name: ensure website dir exists
+ file:
+ path: "/var/www/htdocs/{{ global.domain_name }}"
+ owner: www
+ group: www
+ mode: 0550
+ state: directory
+
+- name: generate website configuration
+ template:
+ src: httpd.conf.j2
+ dest: "/etc/httpd.d/{{ global.domain_name }}.conf"
+ owner: "{{ user_root }}"
+ group: "{{ group_root }}"
+ mode: 0644
+
+- name: ensure httpd is restarted
+ service: name=httpd state=restarted enabled=true
diff --git a/roles/website/templates/httpd.conf.j2 b/roles/website/templates/httpd.conf.j2
new file mode 100644
index 0000000..b1ce966
--- /dev/null
+++ b/roles/website/templates/httpd.conf.j2
@@ -0,0 +1,19 @@
+
+# httpd ~~ /etc/httpd.conf
+# managed by Ansible
+
+server "{{ global.domain_name }}" {
+ listen on * port 80
+ root "/htdocs/{{ global.domain_name }}"
+
+ location "/public/*" {
+ directory auto index
+ }
+
+}
+
+server "www.{{ global.domain_name }}" {
+ listen on * port 80
+ block return 301 "$REQUEST_SCHEME://{{ global.domain_name }}$REQUEST_URI"
+}
+
remember that computers suck.