A first try at an httpd/redirect role
This commit is contained in:
parent
b512d452f7
commit
731f38d7b5
3 changed files with 38 additions and 0 deletions
35
roles/httpd/redirect/tasks/main.yml
Normal file
35
roles/httpd/redirect/tasks/main.yml
Normal file
|
@ -0,0 +1,35 @@
|
|||
# This is a generic role for specifying redirects. When I ported this over from
|
||||
# puppet, I looked first at trying to combine all of our redirects into one
|
||||
# perhaps easier to manage master redirects file. The trouble I hit was that
|
||||
# certain redirects need to apply in the context of certain VirtualHost entries
|
||||
# while not in others. Consequently, we use this template to stuff the redirect
|
||||
# role only into the {{website}}/ folder for each site.
|
||||
|
||||
# Just do some sanity checking first
|
||||
- fail: msg="Bailing out. 'name' must be passed to this role."
|
||||
when: name is not defined
|
||||
- fail: msg="Bailing out. 'website' must be passed to this role."
|
||||
when: website is not defined
|
||||
- fail: msg="Bailing out. 'target' must be passed to this role."
|
||||
when: target is not defined
|
||||
|
||||
# These two should never fail. We have defaults for them defined in
|
||||
# roles/httpd/redirect/vars/main.yml -- They are checked here for completeness.
|
||||
- fail: msg="Bailing out. 'path' must be passed to this role."
|
||||
when: path is not defined
|
||||
- fail: msg="Bailing out. 'status' must be passed to this role."
|
||||
when: status is not defined
|
||||
|
||||
# This is the only real work we do.
|
||||
- name: Copy over httpd redirect file.
|
||||
template: >
|
||||
src=redirect.conf
|
||||
dest=/etc/httpd/conf.d/{{website}}/{{name}}-redirect.conf
|
||||
mode=0644
|
||||
owner=root
|
||||
group=root
|
||||
notify:
|
||||
- restart httpd
|
||||
tags:
|
||||
- httpd
|
||||
- httpd/redirects
|
1
roles/httpd/redirect/templates/redirect.conf
Normal file
1
roles/httpd/redirect/templates/redirect.conf
Normal file
|
@ -0,0 +1 @@
|
|||
Redirect {{ status }} {{ path }} {{ target }}
|
2
roles/httpd/redirect/vars/main.yml
Normal file
2
roles/httpd/redirect/vars/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
status: 301
|
||||
path: /
|
Loading…
Add table
Add a link
Reference in a new issue