Skip to content

Commit

Permalink
Merge pull request #3 from unboxed/nginx_configure_ppa
Browse files Browse the repository at this point in the history
Nginx configure ppa
  • Loading branch information
nickjj committed Feb 18, 2015
2 parents ae418f1 + b3004ed commit ce54b5a
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 6 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ before_install:
- "sudo apt-get update -qq"

install:
- "pip install ansible==1.6.2"
- "printf '[defaults]\nroles_path = ../' > ansible.cfg"
- "pip install ansible==1.8.3"
- "echo '[defaults]' > ansible.cfg"
- "echo 'roles_path = ../' >> ansible.cfg"

before_script:
- "cd tests && node server &"
Expand All @@ -35,4 +36,4 @@ script:
curl -k -s -o /dev/null -w "%{http_code}" https://localhost:8081
| grep -q '200'
&& (echo 'HTTPs test: pass' && exit 0)
|| (echo 'HTTPs test: fail' && exit 1)
|| (echo 'HTTPs test: fail' && exit 1)
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,19 @@ nginx_ssl_key_name: sslkey.key
# The amount in seconds to cache apt-update.
apt_cache_valid_time: 86400
# Should we install the Custom PPA for nginx?
# Disable this if you are not using Ubuntu. If you set nginx_configure_ppa to false,
# you will probably need to set 'nginx_spdy_enabled: false' too, since only the PPA version
# includes spdy. nginx_names_hash_bucket_size will also need to be set to 64 in most cases
nginx_configure_ppa: true
# Should the SPDY extension be enabled?
nginx_spdy_enabled: true
# Configure server_names_hash_bucket_size
nginx_names_hash_bucket_size: 32
```

## Example playbook without ssl
Expand Down
4 changes: 4 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
---
nginx_listen: 80

nginx_configure_ppa: true
nginx_spdy_enabled: true
nginx_names_hash_bucket_size: 32

nginx_base_domain: "{{ ansible_fqdn }}"
nginx_server_name: "{{ nginx_base_domain }}"
nginx_base_redirect_to_www: false
Expand Down
4 changes: 3 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
---
- name: ensure ansible's apt_repository dependency is installed
apt: pkg=python-apt state=latest update_cache=true cache_valid_time={{ apt_cache_valid_time }}
when: nginx_configure_ppa

- name: ensure nginx apt repository is up to date
apt_repository: repo='ppa:nginx/stable'
when: nginx_configure_ppa

- name: ensure nginx latest stable is installed
apt: pkg=nginx state=latest update_cache=true cache_valid_time={{ apt_cache_valid_time }}
Expand Down Expand Up @@ -47,4 +49,4 @@
- restart nginx

- name: ensure nginx starts on a fresh reboot
service: name=nginx state=started enabled=yes
service: name=nginx state=started enabled=yes
2 changes: 2 additions & 0 deletions templates/nginx_conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ http {
# Basic Settings
##

server_names_hash_bucket_size {{ nginx_names_hash_bucket_size }};

sendfile on;
tcp_nopush on;
tcp_nodelay on;
Expand Down
4 changes: 2 additions & 2 deletions templates/nginx_sites-available.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ server {
server {
listen {{ nginx_listen }};
{% if nginx_ssl %}
listen {{ nginx_listen_ssl }} ssl spdy;
listen {{ nginx_listen_ssl }} ssl{{ ' spdy' if nginx_spdy_enabled else ''}};
{% endif %}
server_name {{ nginx_server_name }};
root {{ nginx_root_path }};
Expand Down Expand Up @@ -63,7 +63,7 @@ server {
{% if nginx_assets_enabled %}
location {{ nginx_assets_regex }} {
gzip_static on;

expires 1y;
add_header Cache-Control public;
add_header Last-Modified "";
Expand Down

0 comments on commit ce54b5a

Please sign in to comment.