Skip to content

Instantly share code, notes, and snippets.

@pwaldhauer
Created September 15, 2015 21:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pwaldhauer/e0f9b8efad2f167a9d47 to your computer and use it in GitHub Desktop.
Save pwaldhauer/e0f9b8efad2f167a9d47 to your computer and use it in GitHub Desktop.
Simple Ansible Playbook
---
- hosts: all
gather_facts: false
remote_user: ubuntu
sudo: yes
vars:
http_port: 80
api_root: /var/www/ansibletest.com/
tasks:
- name: update apt
apt: update_cache=yes upgrade=full
- name: install tools
apt: name={{item}} state=present
with_items:
- vim
- wget
- curl
- python-setuptools
- screen
- name: install nginx
apt: name=nginx state=present
- name: install php5 and modules
apt: name={{item}} state=present
with_items:
- php5-fpm
- php5-cli
- php5-mcrypt
- php5-curl
- php5-mysql
- php5-json
- php5-readline
- name: enable php5 modules
shell: php5enmod mcrypt curl mysql json readline
- name: install mysql
apt: name=mysql-server state=present
- name: delete default config
file: path=/etc/nginx/sites-available/default state=absent
notify:
- restart webserver
- name: copy nginx config for api
notify:
- restart webserver
template: src=templates/nginx-site.j2 dest=/etc/nginx/sites-available/ansibletest.conf
- name: activate config
file: src=/etc/nginx/sites-available/ansibletest.conf dest=/etc/nginx/sites-enabled/ansibletest.conf state=link
notify:
- restart webserver
- name: ensure nginx is running
service: name=nginx state=started enabled=yes
- name: ensure php5-fpm is running
service: name=php5-fpm state=started enabled=yes
handlers:
- name: restart webserver
service: name=nginx state=restarted
service: name=php5-fpm state=restarted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment