Skip to content

Instantly share code, notes, and snippets.

@bbatsche
Created May 6, 2014 20:49
Show Gist options
  • Save bbatsche/f5f76ff49383772747c5 to your computer and use it in GitHub Desktop.
Save bbatsche/f5f76ff49383772747c5 to your computer and use it in GitHub Desktop.
Badlands Config Suppliment
---
- name: Site Create
vars:
hostname: default
www_home: /vagrant/sites
laravel_env: local
hosts: default
user: vagrant
sudo: true
tasks:
- name: Create site directory
file: path={{ www_home }}/{{ domain }} state=directory owner=www-data group=www-data mode=0755
- name: Ensure directory permissions persit
command: chmod -R g+rws {{ www_home }}/{{ domain }}
- name: Deploy nginx site config
template: src=templates/nginx-site.conf.j2 dest=/etc/nginx/sites-available/{{ domain }} owner={{ ansible_ssh_user }}
sudo: yes
notify:
- restart nginx
- name: Activate nginx site
file: src=/etc/nginx/sites-available/{{ domain }} dest=/etc/nginx/sites-enabled/{{ domain }} state=link owner={{ ansible_ssh_user }}
sudo: yes
notify:
- restart nginx
- name: Deploy php-fpm pool config
template: src=templates/php-fpm-pool.conf.j2 dest=/etc/php5/fpm/pool.d/{{ domain }}.conf owner={{ ansible_ssh_user }}
sudo: yes
notify:
- restart php-fpm
handlers:
- include: handlers.yml
---
- name: Server initialization
vars:
www_home: /vagrant/sites
php_error_reporting: "E_ALL"
php_error_display: "On"
laravel_env: local
hosts: default
user: vagrant
sudo: true
tasks:
- include: tasks/timezone.yml
- include: tasks/sysctl.yml
- include: tasks/system_updates.yml
- include: tasks/system_utilities.yml
- include: tasks/mysql.yml
- include: tasks/nginx.yml
- include: tasks/php.yml
- include: tasks/php_composer.yml
- include: tasks/bash_profile.yml
handlers:
- include: handlers.yml
---
- name: Install php
apt: package={{ item }} state=present
with_items:
- php5
- php5-cli
- php5-json
- php5-mysql
- php5-curl
- php5-mcrypt
- php5-gd
- php5-imagick
- php5-fpm
# Ubuntu 13.10+ has a bug in where the mcrypt ini file is placed.
# Work around those by copying the file to the proper location and enabling mcrypt.
- name: Copy mcrypt ini to proper location and enable
shell: php5enmod mcrypt creates=/etc/php5/fpm/conf.d/20-mcrypt.ini
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '13.10'
notify:
- restart php-fpm
- name: Remove default php-fpm pool
file: path=/etc/php5/fpm/pool.d/www.conf state=absent
notify:
- restart php-fpm
- name: Create php-fpm log directory
file: path=/var/log/php-fpm state=directory owner=www-data
- name: Create php log directory
file: path=/var/log/php state=directory owner=www-data
- name: Create php upload directory
file: path=/var/lib/php/upload state=directory owner=www-data
- name: Create php session directory
file: path=/var/lib/php/session state=directory owner=www-data
- name: Modify php.ini settings
template: src=templates/php.ini.j2 dest=/etc/php5/fpm/php.ini
notify:
- restart php-fpm
[{{ domain }}]
user = www-data
group = www-data
request_slowlog_timeout = 5s
slowlog = /var/log/php-fpm/slowlog-{{ domain }}.log
listen = /var/run/php5-fpm-{{ domain }}.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0666
listen.backlog = -1
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.max_requests = 500
request_terminate_timeout = 120s
rlimit_files = 131072
rlimit_core = unlimited
catch_workers_output = yes
env[HOSTNAME] = $HOSTNAME
env[TMP] = /tmp/php/{{ domain }}
env[TMPDIR] = /tmp/php/{{ domain }}
env[TEMP] = /tmp/php/{{ domain }}
{% if laravel_env is defined -%}
env[LARAVEL_ENV] = {{ laravel_env }}
{%- endif %}
php_admin_value[open_basedir] = /var/log/php:/var/lib/php:{{ www_home }}/{{ domain }}:/tmp
php_admin_value[upload_tmp_dir] = /tmp
[defaults]
hostfile = .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory
private_key_file = ~/.vagrant.d/insecure_private_key
host_key_checking = False
# -*- mode: ruby -*-
# vi: set ft=ruby :
#############################
# Codeup Server Setup
#############################
box = 'chef/ubuntu-14.04'
hostname = 'codeup-trusty'
domain = 'codeup.dev'
ip = '192.168.77.77'
ram = '512'
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = box
config.vm.hostname = hostname
config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.network :private_network, ip: ip
config.vbguest.auto_update = false if Vagrant.has_plugin? "vagrant-vbguest"
config.vm.provider :virtualbox do |vb|
vb.name = hostname
vb.memory = ram
vb.cpus = 1
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["setextradata", :id, "--VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
vb.customize ["guestproperty", "set", :id, "--timesync-threshold", 10000]
end
config.vm.provision "ansible" do |ansible|
ansible.playbook = "ansible/local-server-init.yml"
ansible.extra_vars = {
hostname: hostname
}
end
config.vm.provision "ansible" do |ansible|
ansible.playbook = "ansible/local-site-create.yml"
ansible.extra_vars = {
domain: domain
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment