Skip to content
Snippets Groups Projects
Commit 23f9b654 authored by Eino Tuominen's avatar Eino Tuominen
Browse files

initial commit

parents
No related branches found
No related tags found
No related merge requests found
---
language: python
python: "2.7"
# Use the new container infrastructure
sudo: false
# Install ansible
addons:
apt:
packages:
- python-pip
install:
# Install ansible
- pip install ansible
# Check ansible version
- ansible --version
# Create ansible.cfg with correct roles_path
- printf '[defaults]\nroles_path=../' >ansible.cfg
script:
# Basic role syntax check
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
\ No newline at end of file
nginx-site role
\ No newline at end of file
---
site_server_name: "{{ ansible_fqdn }}"
site_ssl_enabled: False
site_listen: "{% if site_ssl_enabled %}443 ssl{% else %}80{% endif %}"
site_proxy_ip: 127.0.0.1
dependencies:
- role: 'nginx-server'
---
- name: include distribution specific tasks
include: main_{{ ansible_distribution }}.yml
- name: install nginx site
template: src={{ site_template }}-site.j2 dest=/etc/nginx/conf.d/{{ site_name }}.conf owner=root group=root mode=0644
notify: restart nginx
when: site_template is defined
- name: install nginx custom config
copy: content={{ site_content }} dest=/etc/nginx/conf.d/{{ site_name }} owner=root group=root mode=0644
notify: restart nginx
when: site_content is defined
#- name: install nginx site
# template: src={{ site_name }}-site.j2 dest=/etc/nginx/sites-available/{{ site_name }} owner=root group=root mode=0644
# notify: restart nginx
- name: install nginx site
copy: content={{ site_content }} dest=/etc/nginx/sites-available/{{ site_name }} owner=root group=root mode=0644
notify: restart nginx
- name: enable nginx site
file: src=/etc/nginx/sites-available/{{ site_name }} dest=/etc/nginx/sites-enabled/{{ site_name }} state=link
notify: restart nginx
# {{ ansible_managed }}
server {
listen {{ site_listen }};
server_name {{ site_server_name }};
{% if site_ssl_enabled %}
ssl_certificate {{ site_server_name }}.crt;
ssl_certificate_key {{ site_server_name }}.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
{% endif %}
proxy_set_header X-Forwarded-For $remote_addr;
location / {
proxy_pass http://{{ site_proxy_ip }}:{{ site_proxy_port }};
access_log /var/log/nginx/{{ site_name }}.access.log;
error_log /var/log/nginx/{{ site_name }}.error.log;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment