Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
Update provisioning scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Snape committed Mar 26, 2015
1 parent d7ab13c commit 78c1867
Show file tree
Hide file tree
Showing 29 changed files with 2,145 additions and 221 deletions.
19 changes: 13 additions & 6 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
#=============================================================================
# Midas Server
# Copyright Kitware SAS, 26 rue Louis Guérin, 69100 Villeurbanne, France.
Expand All @@ -18,11 +19,17 @@
# limitations under the License.
#=============================================================================

Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: ".git/"
config.vm.provision "ansible" do |ansible|
ansible.playbook = "provisioning/ansible/site.yml"
Vagrant.configure('2') do |config|
if Vagrant.has_plugin?('vagrant-cachier')
config.cache.auto_detect = false
config.cache.enable :apt
config.cache.enable :apt_lists
config.cache.enable :composer
config.cache.scope = :box
end
config.vm.box = 'ubuntu/trusty64'
config.vm.network 'forwarded_port', guest: 80, host: 8080, auto_correct: true
config.vm.provision 'ansible' do |ansible|
ansible.playbook = 'provisioning/ansible/site.yml'
end
end
2 changes: 1 addition & 1 deletion provisioning/ansible/roles/apache2/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@

---
- name: restart apache2
service: name=apache2 state=restarted
service: name={{ apache2_service }} state=restarted
41 changes: 28 additions & 13 deletions provisioning/ansible/roles/apache2/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,56 @@
#=============================================================================

---
- name: include vars
include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_distribution | lower }}.yml"
- "{{ ansible_os_family | lower }}.yml"
- default.yml

- name: apt install
apt: name={{ item }} state=present
with_items:
- apache2
- php5
- php5-gd
- sendmail
when: ansible_pkg_mgr == 'apt'

- name: php.ini
template: src=etc-php5-apache2-php.ini.j2 dest=/etc/php5/apache2/php.ini
notify:
- restart apache2

- name: enable modules
apache2_module: name={{ item }} state=present
- name: yum install
yum: name={{ item }} state=present
with_items:
- rewrite
- vhost_alias
- httpd
- sendmail
when: ansible_pkg_mgr == 'yum'

- name: enable rewrite module
apache2_module: name=rewrite state=present
notify:
- restart apache2
when: ansible_os_family == 'Debian'

- name: ln
command: ln -s /vagrant /var/www/vagrant creates=/var/www/vagrant
- name: ln vagrant
file: src=/vagrant dest=/var/www/vagrant state=link

- name: sites-available
template: src=etc-apache2-sites-available-vagrant.conf.j2 dest=/etc/apache2/sites-available/vagrant.conf
notify:
- restart apache2
when: ansible_os_family == 'Debian'

- name: disable site
command: a2dissite 000-default.conf removes=/etc/apache2/sites-enabled/000-default.conf
notify:
- restart apache2
when: ansible_os_family == 'Debian'

- name: enable site
command: a2ensite vagrant.conf creates=/etc/apache2/sites-enabled/vagrant.conf
notify:
- restart apache2
when: ansible_os_family == 'Debian'

- name: conf.d
template: src=etc-httpd-conf.d-vagrant.conf.j2 dest=/etc/httpd/conf.d/vagrant.conf
notify:
- restart apache2
when: ansible_os_family == 'RedHat'
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<Directory /var/www/vagrant>
Options FollowSymLinks
AllowOverride All
</Directory>

<VirtualHost *:80>
ServerName vagrant.dev
DocumentRoot /var/www/vagrant
<Directory /var/www/vagrant>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
ServerName localhost
ServerAdmin webmaster@localhost
DocumentRoot /var/www/vagrant
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Directory /var/www/vagrant>
Options FollowSymLinks
AllowOverride All
</Directory>

<VirtualHost *:80>
ServerName localhost
ServerAdmin webmaster@localhost
DocumentRoot /var/www/vagrant
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
#=============================================================================

---
apache2_service: apache2
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
#=============================================================================

---
apache2_service: httpd
37 changes: 36 additions & 1 deletion provisioning/ansible/roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,48 @@
---
- name: apt update
apt: cache_valid_time=3600 update_cache=yes
when: ansible_pkg_mgr == 'apt'

- name: apt install
apt: name={{ item }} state=present
with_items:
- bzip2
- cmake
- curl
- git
- gzip
- nano
- subversion
- tar
- unzip
when: ansible_pkg_mgr == 'apt'

- name: yum update
yum: update_cache=yes
when: ansible_pkg_mgr == 'yum'

- name: yum install epel-release
yum: name=epel-release state=present
when: ansible_distribution in ['CentOS', 'RedHat']

- name: yum install
yum: name={{ item }} state=present
with_items:
- bzip2
- cmake
- curl
- git
- gzip
- nano
- subversion
- tar
- unzip
when: ansible_pkg_mgr == 'yum'

- name: chmod 0777
file: path=core/configs mode=0777 recurse=yes state=directory
file: path={{ item }} mode=0777 state=directory
with_items:
- /vagrant/core/configs
- /vagrant/data
- /vagrant/log
- /vagrant/tmp
3 changes: 1 addition & 2 deletions provisioning/ansible/roles/memcached/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@

---
dependencies:
- { role: common }
- { role: apache2 }
- { role: php }
11 changes: 8 additions & 3 deletions provisioning/ansible/roles/memcached/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@
- php5-memcached
notify:
- restart apache2
when: ansible_pkg_mgr == 'apt'

- name: memcached.conf
template: src=etc-memcached.conf.j2 dest=/etc/memcached.conf
- name: yum install
yum: name={{ item }} state=present
with_items:
- memcached
- php-pecl-memcached
notify:
- restart memcached
- restart apache2
when: ansible_pkg_mgr == 'yum'

This file was deleted.

2 changes: 1 addition & 1 deletion provisioning/ansible/roles/mysql/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@

---
- name: restart mysql
service: name=mysql state=restarted
service: name={{ mysql_service }} state=restarted
4 changes: 2 additions & 2 deletions provisioning/ansible/roles/mysql/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@

---
dependencies:
- { role: common }
- { role: apache2 }
- { role: php }
- { role: python }
26 changes: 23 additions & 3 deletions provisioning/ansible/roles/mysql/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,41 @@
#=============================================================================

---
- name: include vars
include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_distribution | lower }}.yml"
- "{{ ansible_os_family | lower }}.yml"
- default.yml

- name: apt install
apt: name={{ item }} state=present
with_items:
- mysql-server
- php5-mysqlnd
- python-mysqldb
notify:
- restart apache2
when: ansible_pkg_mgr == 'apt'

- name: my.cnf
template: src=etc-mysql-my.cnf.j2 dest=/etc/mysql/my.cnf
- name: yum install
yum: name={{ item }} state=present
with_items:
- mariadb-server
- MySQL-python
- php-mysqlnd
notify:
- restart mysql
- restart apache2
when: ansible_pkg_mgr == 'yum'

- name: db
mysql_db: name={{ item }} state=present
with_items:
- midas
- midas_test

- name: user
mysql_user: user=vagrant password=vagrant priv={{ item }}.*:ALL state=present
with_items:
- midas
- midas_test
Loading

0 comments on commit 78c1867

Please sign in to comment.