Skip to content
This repository has been archived by the owner on Jan 18, 2018. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vdvm committed Feb 1, 2015
0 parents commit b2de7a6
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Ansible Role: Nginx

Installs Nginx

## Supported platforms

```
CentOS 6 & 7
Ubuntu 14.04
```

## Requirements

None

## Role Variables

Nginx version:

```
nginx_mainline: true
```

## Dependencies

None

## Example Playbook

```
- hosts: servers
roles:
- { role: pcextreme.nginx }
```

## License

MIT / BSD

## Author Information

Created by [Attila van der Velde](https://github.com/vdvm)
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
nginx_mainline: true
6 changes: 6 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: reload nginx
service: name=nginx state=reloaded

- name: restart nginx
service: name=nginx state=restarted
20 changes: 20 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
galaxy_info:
author: "Attila van der Velde"
description: "Installs Nginx"
company: "PCextreme B.V."
license: "license (MIT, BSD)"
min_ansible_version: 1.8
platforms:
- name: EL
versions:
- 6
- 7
- name: Ubuntu
versions:
- trusty
categories:
- system
- web

dependencies: []
15 changes: 15 additions & 0 deletions tasks/centos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
- name: Add repo file
template: src=nginx_centos.repo.j2 dest=/etc/yum.repos.d/nginx.repo owner=root group=root mode=0644

- name: Add repo key
get_url: url=http://nginx.org/keys/nginx_signing.key dest=/etc/pki/rpm-gpg/RPM-GPG-KEY-nginx sha256sum=dcc2ed613d67b277a7e7c87b12907485652286e199c1061fb4b3af91f201be39 force=yes

- name: Add repo key
file: path=/etc/pki/rpm-gpg/RPM-GPG-KEY-nginx owner=root group=root mode=0644

- name: Add repo key
rpm_key: state=present key=/etc/pki/rpm-gpg/RPM-GPG-KEY-nginx

- name: Install Nginx
yum: name=nginx enablerepo=nginx state=present
9 changes: 9 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- include: centos.yml
when: ansible_distribution == 'CentOS' and ansible_distribution_major_version|int >= 6

- include: ubuntu.yml
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '14.04'

- name: Start and enable service
service: name=nginx state=started enabled=yes
21 changes: 21 additions & 0 deletions tasks/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
- name: Add repo file
template: src=nginx_ubuntu.list.j2 dest=/etc/apt/sources.list.d/nginx.list owner=root group=root mode=0644
register: nginx_list

- name: Add repo key
get_url: url=http://nginx.org/keys/nginx_signing.key dest=/etc/apt/nginx.key sha256sum=dcc2ed613d67b277a7e7c87b12907485652286e199c1061fb4b3af91f201be39 force=yes

- name: Add repo key
file: path=/etc/apt/nginx.key owner=root group=root mode=0644

- name: Add repo key
apt_key: id=7BD9BF62 file=/etc/apt/nginx.key state=present
register: nginx_key

- name: Update apt cache
apt: update_cache=yes
when: nginx_list.changed == True or nginx_key.changed == True

- name: Install Nginx
apt: pkg=nginx state=present
5 changes: 5 additions & 0 deletions templates/nginx_centos.repo.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[nginx]
name=nginx
baseurl=http://nginx.org/packages/{% if nginx_mainline %}mainline/{% endif %}centos/{{ ansible_distribution_major_version }}/x86_64/
gpgcheck=1
enabled=1
2 changes: 2 additions & 0 deletions templates/nginx_ubuntu.list.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
deb http://nginx.org/packages/{% if nginx_mainline %}mainline/{% endif %}ubuntu/ {{ ansible_distribution_release | lower }} nginx
deb-src http://nginx.org/packages/{% if nginx_mainline %}mainline/{% endif %}ubuntu/ {{ ansible_distribution_release | lower }} nginx

0 comments on commit b2de7a6

Please sign in to comment.