Skip to content

Commit

Permalink
Merge pull request #88 from Duke-GCB/webhook-proxy
Browse files Browse the repository at this point in the history
Add webhook-proxy role
  • Loading branch information
johnbradley authored May 24, 2021
2 parents 3b6390c + feb2e65 commit b0a8752
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 0 deletions.
10 changes: 10 additions & 0 deletions webhook-proxy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# webhook-proxy

Ansible role for deploying nginx/letsencrypt as a webhook proxy for Openshift.

## Requirements

The following variables need to be defined before running this role:
- `domain`: proxy website url
- `sysadmin_email`: support email address for letsencrypt
- `openshift_url`: url of openshift
48 changes: 48 additions & 0 deletions webhook-proxy/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
- name: Install NGINX
apt:
name: nginx
state: latest
update_cache: yes

- name: "create www directory"
file:
path: /var/www/{{ domain }}
state: directory
mode: '0775'
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"

- name: copy index.html
template:
src: index.html.j2
dest: /var/www/{{ domain }}/index.html
owner: root
group: root
mode: '0644'

- name: delete default nginx site
file:
path: /etc/nginx/sites-enabled/default
state: absent

- name: copy nginx site.conf
template:
src: site.conf.j2
dest: /etc/nginx/sites-enabled/{{ domain }}
owner: root
group: root
mode: '0644'

- name: Install Let's Encrypt (certbot)
apt:
pkg:
- certbot
- python3-certbot-nginx

- name: Configure certbot
command: certbot --nginx -d {{ domain }} --non-interactive --agree-tos -m {{ sysadmin_email }} --redirect

- name: restart nginx
service:
name: nginx
state: restarted
16 changes: 16 additions & 0 deletions webhook-proxy/templates/index.html.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>Webhook Proxy</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Webhook Proxy Server</h1>
</body>
</html>
12 changes: 12 additions & 0 deletions webhook-proxy/templates/site.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
server {
listen 80;
listen [::]:80;
server_name {{ domain }} www.{{ domain }};
root /var/www/{{ domain }};
location / {
try_files $uri $uri/ =404;
}
location /openshift/ {
proxy_pass {{ openshift_url }};
}
}

0 comments on commit b0a8752

Please sign in to comment.