vagrant & ansible scripts added inc docs in README

This commit is contained in:
Eddie Abou-Jaoude
2015-08-15 12:21:01 +01:00
parent 5df676e75c
commit 8f70b11652
18 changed files with 284 additions and 0 deletions

2
ansible/inventories/dev Executable file
View File

@@ -0,0 +1,2 @@
[phansible-web]
192.168.11.2

11
ansible/playbook.yml Executable file
View File

@@ -0,0 +1,11 @@
---
- hosts: all
sudo: true
vars_files:
- vars/all.yml
roles:
- server
- vagrant_local
- php
- xdebug
- app

View File

@@ -0,0 +1,5 @@
---
# application tasks to be customized and to run after the main provision
- name: update file db
sudo: yes
shell: updatedb

View File

@@ -0,0 +1,3 @@
---
- name: restart php5-fpm
service: name=php5-fpm enabled=yes state=restarted

View File

@@ -0,0 +1,9 @@
---
#- stat: path=/etc/php5/fpm/php.ini
# register: phpfpm
- stat: path=/etc/php5/cli/php.ini
register: phpcli
- include: php-cli.yml
when: phpcli.stat.exists

View File

@@ -0,0 +1,25 @@
---
- name: Add ppa Repository
sudo: yes
apt_repository: repo=ppa:ondrej/{{ php.ppa }}
- name: Update apt
sudo: yes
apt: update_cache=yes
- name: Install php5
sudo: yes
apt: pkg=php5 state=latest
- name: Install PHP Packages
sudo: yes
apt: pkg={{ item }} state=latest
with_items: php.packages
when: php.packages is defined
- name: Install pear
sudo: yes
apt: pkg=php-pear state=latest
- include: configure.yml
- include: pecl.yml

View File

@@ -0,0 +1,26 @@
- name: Install
apt: pkg="php5-dev" state=present
when: php.pecl_packages is defined
- name: Install Package
shell: echo "\n\n\n\n\n\n\n\n\n" | pecl install {{ item }}
register: pecl_result
changed_when: "'already installed' not in pecl_result.stdout"
failed_when: "pecl_result.stderr or ('ERROR' in pecl_result.stdout)"
with_items: php.pecl_packages
when: php.pecl_packages is defined
- name: Create extension .ini file
template: >
src="extension.tpl"
dest="/etc/php5/mods-available/{{ item }}.ini"
owner="root"
group="root"
mode=0644
with_items: php.pecl_packages
when: php.pecl_packages is defined
- name: Enable extension
shell: php5enmod {{ item }}
with_items: php.pecl_packages
when: php.pecl_packages is defined

View File

@@ -0,0 +1,10 @@
---
- name: ensure timezone is set in cli php.ini
lineinfile: dest=/etc/php5/cli/php.ini
regexp='date.timezone ='
line='date.timezone = {{ server.timezone }}'
- name: enabling opcache cli
lineinfile: dest=/etc/php5/cli/php.ini
regexp=';opcache.enable_cli=0'
line='opcache.enable_cli=1'

View File

@@ -0,0 +1,2 @@
; Configuration for php PECL {{ item }} extension
extension={{ item }}.so

View File

@@ -0,0 +1,31 @@
---
- name: Update apt
sudo: yes
apt: update_cache=yes
- name: Install System Packages
sudo: yes
apt: pkg={{ item }} state=latest
with_items:
- curl
- wget
- python-software-properties
- name: Install Extra Packages
sudo: yes
apt: pkg={{ item }} state=latest
with_items: server.packages
when: server.packages is defined
- name: Configure the timezone
sudo: yes
template: src=timezone.tpl dest=/etc/timezone
- name: More Configure the timezone
sudo: yes
file: src=/usr/share/zoneinfo/{{server.timezone}} dest=/etc/localtime state=link force=yes backup=yes
- name: Set default system language pack
shell: locale-gen {{server.locale}}
sudo: yes

View File

@@ -0,0 +1 @@
{{server.timezone}}

View File

@@ -0,0 +1,11 @@
---
- name: Set the hostname in /etc/hostname
shell: echo {{ vagrant_local.vm.hostname }} > /etc/hostname
when: vagrant_local.vm.hostname is defined
- name: Set the hostname
shell: hostname {{ vagrant_local.vm.hostname }}
when: vagrant_local.vm.hostname is defined
- name: Update /etc/hosts
lineinfile: dest=/etc/hosts regexp='^127\.0\.0\.1' line='127.0.0.1 localhost {{ vagrant_local.vm.hostname }}' owner=root group=root mode=0644

View File

@@ -0,0 +1,7 @@
---
xdebug:
settings:
- xdebug.remote_enable=1
- xdebug.idekey=PHPSTORM
- xdebug.remote_connect_back=1
- xdebug.remote_port=9000

View File

@@ -0,0 +1,4 @@
---
- name: Install xDebug
sudo: yes
apt: pkg=php5-xdebug state=latest

15
ansible/vars/all.yml Executable file
View File

@@ -0,0 +1,15 @@
---
server:
install: '1'
packages: [vim, htop, iotop, bwm-ng]
timezone: UTC
locale: en_US.UTF-8
vagrant_local:
install: '1'
vm: { base_box: trusty64, hostname: design-patterns, ip: 192.168.11.2, sharedfolder: ./, enableWindows: '1', useVagrantCloud: '1', syncType: nfs }
php:
install: '1'
ppa: php5-5.6
packages: [php5-cli, php5-intl, php5-mcrypt, php5-mysql, php5-curl, php5-json]
xdebug:
install: '1'

31
ansible/windows.sh Executable file
View File

@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# Update Repositories
sudo apt-get update
# Determine Ubuntu Version
. /etc/lsb-release
# Decide on package to install for `add-apt-repository` command
#
# USE_COMMON=1 when using a distribution over 12.04
# USE_COMMON=0 when using a distribution at 12.04 or older
USE_COMMON=$(echo "$DISTRIB_RELEASE > 12.04" | bc)
if [ "$USE_COMMON" -eq "1" ];
then
sudo apt-get install -y software-properties-common
else
sudo apt-get install -y python-software-properties
fi
# Add Ansible Repository & Install Ansible
sudo add-apt-repository -y ppa:ansible/ansible
sudo apt-get update
sudo apt-get install -y ansible
# Setup Ansible for Local Use and Run
cp /vagrant/ansible/inventories/dev /etc/ansible/hosts -f
chmod 666 /etc/ansible/hosts
cat /vagrant/ansible/files/authorized_keys >> /home/vagrant/.ssh/authorized_keys
sudo ansible-playbook /vagrant/ansible/playbook.yml -e hostname=$1 --connection=local