diff --git a/.gitignore b/.gitignore index a6a9f9e..eef9ed3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ ministerial-data-cabinet-office +#OS Artifacts +.DS_STORE # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/server/.gitignore b/server/.gitignore new file mode 100644 index 0000000..23413eb --- /dev/null +++ b/server/.gitignore @@ -0,0 +1,2 @@ +.vagrant/ + diff --git a/server/LICENSE b/server/LICENSE new file mode 100644 index 0000000..d1a16ba --- /dev/null +++ b/server/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Eddie Abou-Jaoude + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/server/README.md b/server/README.md new file mode 100644 index 0000000..27fc976 --- /dev/null +++ b/server/README.md @@ -0,0 +1,57 @@ +# Vagrant Ansible Docker + +Vagrant with Ansible, Docker, Xdebug + +--- + +## Contains + +* PHP +* MySQL +* Apache +* Docker + * MySQL + * Elasticsearch + * Redis +* Npm + * Bower + * Grunt + * Express + * Socket.io +* Ruby +* Xdebug (debugging code) - not recommended to use with Blackfire + +## Dependencies + +* Vagrant + +--- + +## Usage + +1. Clone repo and add to root of your project +2. Vagrant up (use `--debug` for more verbose output from **vagrant**) +3. Access **web** on `http://192.168.33.90/` +4. Access **mysql** on `192.168.33.90:3306` +5. 4. Access **elasticsearch** on `192.168.33.90:9200` +6. etc... + +--- + +## Customisation + + +### System wide **apt** packages + +Edit `ansible/vars/all.yml` and add to collect on line 4, looks like `packages: [vim, htop, iotop]` + +*Or variables, mysql passwords etc* + +### What **ansible** installs (eg. nginx or apache) + +Edit `ansible/playbook.yml` *comment/uncomment* **roles** collection. + + +### What **docker** containers are installed + +Edit `ansible/roles/docker/tasks/main.yml` and add includes for extra containers. diff --git a/server/Vagrantfile b/server/Vagrantfile new file mode 100755 index 0000000..15781db --- /dev/null +++ b/server/Vagrantfile @@ -0,0 +1,58 @@ +################################################## +# Generated by phansible.com +################################################## + +#If your Vagrant version is lower than 1.5, you can still use this provisioning +#by commenting or removing the line below and providing the config.vm.box_url parameter, +#if it's not already defined in this Vagrantfile. Keep in mind that you won't be able +#to use the Vagrant Cloud and other newer Vagrant features. +Vagrant.require_version ">= 1.5" + +# Check to determine whether we're on a windows or linux/os-x host, +# later on we use this to launch ansible in the supported way +# source: https://stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby +def which(cmd) + exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] + ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| + exts.each { |ext| + exe = File.join(path, "#{cmd}#{ext}") + return exe if File.executable? exe + } + end + return nil +end +Vagrant.configure("2") do |config| + + config.vm.provider :virtualbox do |v| + v.name = "muti" + v.customize [ + "modifyvm", :id, + "--name", "muti", + "--memory", 1024, + "--natdnshostresolver1", "on", + "--cpus", 2, + ] + end + + config.vm.box = "ubuntu/trusty64" + + config.vm.network :private_network, ip: "192.168.33.90" + config.ssh.forward_agent = true + + ############################################################# + # Ansible provisioning (you need to have ansible installed) + ############################################################# + + if which('ansible-playbook') + config.vm.provision "ansible" do |ansible| + ansible.playbook = "./ansible/playbook.yml" + ansible.inventory_path = "./ansible/inventories/dev" + ansible.limit = 'all' + end + else + config.vm.provision :shell, path: "./ansible/windows.sh", args: ["default"] + end + + + config.vm.synced_folder "../", "/vagrant", type: "nfs" +end diff --git a/server/ansible/inventories/dev b/server/ansible/inventories/dev new file mode 100755 index 0000000..90d6dc9 --- /dev/null +++ b/server/ansible/inventories/dev @@ -0,0 +1,2 @@ +[phansible-web] +192.168.33.90 diff --git a/server/ansible/playbook.retry b/server/ansible/playbook.retry new file mode 100644 index 0000000..18d2ff3 --- /dev/null +++ b/server/ansible/playbook.retry @@ -0,0 +1 @@ +192.168.33.90 diff --git a/server/ansible/playbook.yml b/server/ansible/playbook.yml new file mode 100755 index 0000000..6fcc543 --- /dev/null +++ b/server/ansible/playbook.yml @@ -0,0 +1,15 @@ +--- +- hosts: all + sudo: true + vars_files: + - vars/all.yml + roles: + - server + - vagrant_local + - apache + - php + - xdebug + - docker + - npm + - ruby + - app diff --git a/server/ansible/roles/apache/handlers/main.yml b/server/ansible/roles/apache/handlers/main.yml new file mode 100755 index 0000000..aa60480 --- /dev/null +++ b/server/ansible/roles/apache/handlers/main.yml @@ -0,0 +1,3 @@ +--- +- name: restart apache + service: name=apache2 enabled=yes state=restarted diff --git a/server/ansible/roles/apache/tasks/main.yml b/server/ansible/roles/apache/tasks/main.yml new file mode 100755 index 0000000..91851a5 --- /dev/null +++ b/server/ansible/roles/apache/tasks/main.yml @@ -0,0 +1,29 @@ +--- +- name: Install Apache + sudo: yes + apt: pkg=apache2 state=latest + +- name: Install Apache Modules + apache2_module: state=present name={{ item }} + notify: restart apache + with_items: + - rewrite + - vhost_alias + - headers + - expires + - filter + +- shell: apache2 -v + register: apache_version + +- name: Change default apache2.4 site + sudo: yes + template: src=vhost24.conf.tpl dest=/etc/apache2/sites-available/000-default.conf + notify: restart apache + when: apache_version.stdout.find('Apache/2.4.') != -1 + +- name: Change default apache2.2 site + sudo: yes + template: src=vhost22.conf.tpl dest=/etc/apache2/sites-available/default + notify: restart apache + when: apache_version.stdout.find('Apache/2.2.') != -1 diff --git a/server/ansible/roles/apache/templates/vhost22.conf.tpl b/server/ansible/roles/apache/templates/vhost22.conf.tpl new file mode 100755 index 0000000..2d1f6fc --- /dev/null +++ b/server/ansible/roles/apache/templates/vhost22.conf.tpl @@ -0,0 +1,14 @@ +# Default Apache virtualhost template + + + ServerAdmin webmaster@localhost + DocumentRoot {{ apache.docroot }} + ServerName {{ apache.servername }} + + + AllowOverride All + Options -Indexes FollowSymLinks + Order allow,deny + Allow from all + + diff --git a/server/ansible/roles/apache/templates/vhost24.conf.tpl b/server/ansible/roles/apache/templates/vhost24.conf.tpl new file mode 100755 index 0000000..af3d936 --- /dev/null +++ b/server/ansible/roles/apache/templates/vhost24.conf.tpl @@ -0,0 +1,13 @@ +# Default Apache virtualhost template + + + ServerAdmin webmaster@localhost + DocumentRoot {{ apache.docroot }} + ServerName {{ apache.servername }} + + + AllowOverride All + Options -Indexes +FollowSymLinks + Require all granted + + diff --git a/server/ansible/roles/app/tasks/main.yml b/server/ansible/roles/app/tasks/main.yml new file mode 100755 index 0000000..c330e48 --- /dev/null +++ b/server/ansible/roles/app/tasks/main.yml @@ -0,0 +1,5 @@ +--- +# application tasks to be customized and to run after the main provision +- name: update file db + sudo: yes + shell: updatedb diff --git a/server/ansible/roles/docker/tasks/elasticsearch.yml b/server/ansible/roles/docker/tasks/elasticsearch.yml new file mode 100644 index 0000000..4771d39 --- /dev/null +++ b/server/ansible/roles/docker/tasks/elasticsearch.yml @@ -0,0 +1,7 @@ +- name: elasticsearch container + docker: + name: elasticsearch + image: elasticsearch + state: started + ports: + - "9200:9200" diff --git a/server/ansible/roles/docker/tasks/main.yml b/server/ansible/roles/docker/tasks/main.yml new file mode 100644 index 0000000..a224167 --- /dev/null +++ b/server/ansible/roles/docker/tasks/main.yml @@ -0,0 +1,13 @@ +- name: install pip + shell: curl https://bootstrap.pypa.io/get-pip.py | python - + +- name: install docker py + shell: pip install docker-py + +- name: install docker + shell: curl -sSL https://get.docker.com/ | sh && sudo usermod -aG docker vagrant + +- include: mysql.yml +- include: postgres.yml +- include: redis.yml +- include: elasticsearch.yml diff --git a/server/ansible/roles/docker/tasks/mysql.yml b/server/ansible/roles/docker/tasks/mysql.yml new file mode 100644 index 0000000..f316cb3 --- /dev/null +++ b/server/ansible/roles/docker/tasks/mysql.yml @@ -0,0 +1,8 @@ +- name: mysql container + docker: + name: mysql + image: mysql + state: started + env: "MYSQL_ROOT_PASSWORD={{ mysql.root_password }}" + ports: + - "3306:3306" diff --git a/server/ansible/roles/docker/tasks/postgres.yml b/server/ansible/roles/docker/tasks/postgres.yml new file mode 100644 index 0000000..57b1349 --- /dev/null +++ b/server/ansible/roles/docker/tasks/postgres.yml @@ -0,0 +1,7 @@ +- name: postgres container + docker: + name: postgres + image: postgres + state: started + ports: + - "5432:5432" diff --git a/server/ansible/roles/docker/tasks/redis.yml b/server/ansible/roles/docker/tasks/redis.yml new file mode 100644 index 0000000..081cc97 --- /dev/null +++ b/server/ansible/roles/docker/tasks/redis.yml @@ -0,0 +1,7 @@ +- name: redis container + docker: + name: redis + image: redis + state: started + ports: + - "6379:6379" diff --git a/server/ansible/roles/mysql/handlers/main.yml b/server/ansible/roles/mysql/handlers/main.yml new file mode 100644 index 0000000..a2b21d4 --- /dev/null +++ b/server/ansible/roles/mysql/handlers/main.yml @@ -0,0 +1,3 @@ +--- +- name: restart mysql + service: name=mysql enabled=yes state=restarted diff --git a/server/ansible/roles/mysql/tasks/main.yml b/server/ansible/roles/mysql/tasks/main.yml new file mode 100755 index 0000000..6fe46d7 --- /dev/null +++ b/server/ansible/roles/mysql/tasks/main.yml @@ -0,0 +1,43 @@ +--- +# Retrieve the current hostname, because {{ ansible_hostname }} still contains the old name +- shell: hostname + register: current_hostname + +- name: mysql | Install MySQL Packages + sudo: yes + apt: pkg={{ item }} state=latest + with_items: + - mysql-server + - mysql-client + - python-mysqldb + +- name: mysql | Update root password for all root accounts + mysql_user: name=root host={{ item }} check_implicit_admin=yes password={{ mysql.root_password }} login_user=root login_password={{ mysql.root_password }} + with_items: + - "{{ current_hostname.stdout | lower }}" + - 127.0.0.1 + - ::1 + - localhost + - 192.168.33.1 + +- name: mysql | Create databases + mysql_db: name={{ mysql.database }} state=present login_user=root login_password={{ mysql.root_password }} + +- name: mysql | Import dump + mysql_db: name={{ mysql.database }} state=import login_user=root login_password={{ mysql.root_password }} target=/vagrant/{{ mysql.dump }} + when: mysql.dump + +- name: mysql | Ensure anonymous users are not in the database + mysql_user: name='' host={{ item }} state=absent login_user=root login_password={{ mysql.root_password }} + with_items: + - localhost + - "{{ current_hostname.stdout | lower }}" + +- name: mysql | Create users + mysql_user: name={{ mysql.user }} password={{ mysql.password }} priv=*.*:ALL state=present login_user=root login_password={{ mysql.root_password }} + +- name: do not bind to localhost + lineinfile: dest=/etc/mysql/my.cnf + regexp='bind-address' + line='bind-address = 0.0.0.0' + notify: restart mysql diff --git a/server/ansible/roles/nginx/handlers/main.yml b/server/ansible/roles/nginx/handlers/main.yml new file mode 100755 index 0000000..d99a617 --- /dev/null +++ b/server/ansible/roles/nginx/handlers/main.yml @@ -0,0 +1,3 @@ +--- +- name: restart nginx + service: name=nginx enabled=yes state=restarted diff --git a/server/ansible/roles/nginx/tasks/main.yml b/server/ansible/roles/nginx/tasks/main.yml new file mode 100755 index 0000000..b0371df --- /dev/null +++ b/server/ansible/roles/nginx/tasks/main.yml @@ -0,0 +1,9 @@ +--- +- name: Install Nginx + sudo: yes + apt: pkg=nginx state=latest + +- name: Change default nginx site + sudo: yes + template: src=default.tpl dest=/etc/nginx/sites-available/default + notify: restart nginx diff --git a/server/ansible/roles/nginx/templates/default.tpl b/server/ansible/roles/nginx/templates/default.tpl new file mode 100755 index 0000000..e96f473 --- /dev/null +++ b/server/ansible/roles/nginx/templates/default.tpl @@ -0,0 +1,27 @@ +server { + listen 80; + + root {{ nginx.docroot }}; + index index.html index.php; + + server_name {{ nginx.servername }}; + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + error_page 404 /404.html; + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/www; + } + + location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass unix:/var/run/php5-fpm.sock; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } +} diff --git a/server/ansible/roles/npm/tasks/main.yml b/server/ansible/roles/npm/tasks/main.yml new file mode 100644 index 0000000..fd489cb --- /dev/null +++ b/server/ansible/roles/npm/tasks/main.yml @@ -0,0 +1,10 @@ +- name: install npm + apt: pkg=npm state=present + +- name: install global node packages + npm: name={{item}} global=yes + with_items: + - bower + - grunt-cli + - express + - socket.io diff --git a/server/ansible/roles/php/handlers/main.yml b/server/ansible/roles/php/handlers/main.yml new file mode 100755 index 0000000..915cc8a --- /dev/null +++ b/server/ansible/roles/php/handlers/main.yml @@ -0,0 +1,3 @@ +--- +- name: restart php5-fpm + service: name=php5-fpm enabled=yes state=restarted diff --git a/server/ansible/roles/php/tasks/configure.yml b/server/ansible/roles/php/tasks/configure.yml new file mode 100755 index 0000000..8683569 --- /dev/null +++ b/server/ansible/roles/php/tasks/configure.yml @@ -0,0 +1,19 @@ +--- +- stat: path=/etc/php5/apache2/php.ini + register: modphp + +- stat: path=/etc/php5/fpm/php.ini + register: phpfpm + +- stat: path=/etc/php5/cli/php.ini + register: phpcli + +- include: php-fpm.yml + when: phpfpm.stat.exists + +- include: php-cli.yml + when: phpcli.stat.exists + +- include: mod-php.yml + when: modphp.stat.exists + diff --git a/server/ansible/roles/php/tasks/main.yml b/server/ansible/roles/php/tasks/main.yml new file mode 100755 index 0000000..cd67e71 --- /dev/null +++ b/server/ansible/roles/php/tasks/main.yml @@ -0,0 +1,29 @@ +--- +- 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 php5-fpm + sudo: yes + apt: pkg=php5-fpm 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 diff --git a/server/ansible/roles/php/tasks/mod-php.yml b/server/ansible/roles/php/tasks/mod-php.yml new file mode 100755 index 0000000..747951c --- /dev/null +++ b/server/ansible/roles/php/tasks/mod-php.yml @@ -0,0 +1,10 @@ +--- +- name: ensure timezone is set in apache2 php.ini + lineinfile: dest=/etc/php5/apache2/php.ini + regexp='date.timezone =' + line='date.timezone = {{ server.timezone }}' + +- name: enabling opcache + lineinfile: dest=/etc/php5/apache2/php.ini + regexp=';opcache.enable=0' + line='opcache.enable=1' diff --git a/server/ansible/roles/php/tasks/pecl.yml b/server/ansible/roles/php/tasks/pecl.yml new file mode 100755 index 0000000..399219f --- /dev/null +++ b/server/ansible/roles/php/tasks/pecl.yml @@ -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 diff --git a/server/ansible/roles/php/tasks/php-cli.yml b/server/ansible/roles/php/tasks/php-cli.yml new file mode 100755 index 0000000..e1cfffa --- /dev/null +++ b/server/ansible/roles/php/tasks/php-cli.yml @@ -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' diff --git a/server/ansible/roles/php/tasks/php-fpm.yml b/server/ansible/roles/php/tasks/php-fpm.yml new file mode 100755 index 0000000..a829382 --- /dev/null +++ b/server/ansible/roles/php/tasks/php-fpm.yml @@ -0,0 +1,19 @@ +--- +- name: Set permissions on socket - owner + lineinfile: "dest=/etc/php5/fpm/pool.d/www.conf state=present regexp='^;?listen.owner' line='listen.owner = www-data'" + +- name: Set permissions on socket - group + lineinfile: "dest=/etc/php5/fpm/pool.d/www.conf state=present regexp='^;?listen.group' line='listen.group = www-data'" + +- name: Set permissions on socket - mode + lineinfile: "dest=/etc/php5/fpm/pool.d/www.conf state=present regexp='^;?listen.mode' line='listen.mode = 0660'" + notify: restart php5-fpm + +- name: ensure timezone is set in fpm php.ini + lineinfile: dest=/etc/php5/fpm/php.ini + regexp='date.timezone =' + line='date.timezone = {{ server.timezone }}' +- name: enabling opcache + lineinfile: dest=/etc/php5/fpm/php.ini + regexp=';opcache.enable=0' + line='opcache.enable=1' diff --git a/server/ansible/roles/php/templates/extension.tpl b/server/ansible/roles/php/templates/extension.tpl new file mode 100755 index 0000000..1b13534 --- /dev/null +++ b/server/ansible/roles/php/templates/extension.tpl @@ -0,0 +1,2 @@ +; Configuration for php PECL {{ item }} extension +extension={{ item }}.so diff --git a/server/ansible/roles/ruby/tasks/main.yml b/server/ansible/roles/ruby/tasks/main.yml new file mode 100644 index 0000000..a4aeba8 --- /dev/null +++ b/server/ansible/roles/ruby/tasks/main.yml @@ -0,0 +1,5 @@ +- name: Install ruby development headers + sudo: yes + apt: pkg={{ item }} state=latest + with_items: + - ruby-dev diff --git a/server/ansible/roles/server/tasks/main.yml b/server/ansible/roles/server/tasks/main.yml new file mode 100755 index 0000000..f1ffc08 --- /dev/null +++ b/server/ansible/roles/server/tasks/main.yml @@ -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 + diff --git a/server/ansible/roles/server/templates/timezone.tpl b/server/ansible/roles/server/templates/timezone.tpl new file mode 100755 index 0000000..cca2365 --- /dev/null +++ b/server/ansible/roles/server/templates/timezone.tpl @@ -0,0 +1 @@ +{{server.timezone}} diff --git a/server/ansible/roles/vagrant_local/tasks/main.yml b/server/ansible/roles/vagrant_local/tasks/main.yml new file mode 100755 index 0000000..cd53609 --- /dev/null +++ b/server/ansible/roles/vagrant_local/tasks/main.yml @@ -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 diff --git a/server/ansible/roles/xdebug/defaults/main.yml b/server/ansible/roles/xdebug/defaults/main.yml new file mode 100644 index 0000000..81dce50 --- /dev/null +++ b/server/ansible/roles/xdebug/defaults/main.yml @@ -0,0 +1,3 @@ +--- +xdebug: + settings: [] diff --git a/server/ansible/roles/xdebug/tasks/main.yml b/server/ansible/roles/xdebug/tasks/main.yml new file mode 100644 index 0000000..e38815d --- /dev/null +++ b/server/ansible/roles/xdebug/tasks/main.yml @@ -0,0 +1,4 @@ +--- +- name: Install xDebug + sudo: yes + apt: pkg=php5-xdebug state=latest diff --git a/server/ansible/vars/all.yml b/server/ansible/vars/all.yml new file mode 100755 index 0000000..d908d8f --- /dev/null +++ b/server/ansible/vars/all.yml @@ -0,0 +1,26 @@ +--- +server: + install: '1' + packages: [vim, htop, iotop] + timezone: UTC + locale: en_US.UTF-8 +vagrant_local: + install: '1' + vm: { base_box: trusty64, hostname: muti, ip: 192.168.33.90, memory: '1024', sharedfolder: ./, enableWindows: '1', useVagrantCloud: '1', syncType: nfs } +apache: + install: '1' + docroot: /vagrant + servername: myApp.vb +mysql: + install: '1' + root_password: password + database: db + user: user + password: password + dump: '' +php: + install: '1' + ppa: php5-5.6 + packages: [php5-cli, php5-intl, php5-mcrypt, php5-mysql] +xdebug: + install: '1' diff --git a/server/ansible/windows.sh b/server/ansible/windows.sh new file mode 100755 index 0000000..b53f953 --- /dev/null +++ b/server/ansible/windows.sh @@ -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/server/ansible/inventories/dev /etc/ansible/hosts -f +chmod 666 /etc/ansible/hosts +cat /vagrant/server/ansible/files/authorized_keys >> /home/vagrant/.ssh/authorized_keys +sudo ansible-playbook /vagrant/server/ansible/playbook.yml -e hostname=$1 --connection=local