Skip to content

Instantly share code, notes, and snippets.

@ianjuma
Created February 12, 2016 11:59
Show Gist options
  • Select an option

  • Save ianjuma/054eb73790981a6775aa to your computer and use it in GitHub Desktop.

Select an option

Save ianjuma/054eb73790981a6775aa to your computer and use it in GitHub Desktop.
---
- hosts: autobay
vars_files:
- vars/main.yml
remote_user: root
tasks:
- name: Add Nginx repository
apt_repository: repo='ppa:nginx/stable' state=present
register: ppastable
- name: Install Nginx
apt: pkg=nginx state=installed update_cache=true
when: ppastable|success
register: nginxinstalled
notify:
- Start Nginx
- name: Ensure nginx is at the latest version
apt: pkg=nginx state=latest update_cache=true
- name: Write Nginx conf
template: src=templates/nginx.j2 dest=/etc/nginx/nginx.conf
notify:
- Restart nginx
- name: Ensure nginx is running
service: name=nginx state=started
handlers:
- name: Restart nginx
service: name=nginx state=restarted
- name: Start Nginx
service: name=nginx state=started
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment