WIP ansible

This commit is contained in:
Benoît Burnichon
2015-11-26 17:26:22 +01:00
parent e8e996bb67
commit f1dccd0632
13 changed files with 48 additions and 22 deletions

17
Vagrantfile vendored
View File

@@ -20,11 +20,6 @@ def which(cmd)
end end
def config_net(config) def config_net(config)
# Configure hostmanager
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.ignore_private_ip = false
config.hostmanager.include_offline = true
config.hostmanager.aliases = [ config.hostmanager.aliases = [
$hostname + ".vb", $hostname + ".vb",
"www." + $hostname + ".vb", "www." + $hostname + ".vb",
@@ -52,10 +47,18 @@ def config_net(config)
end end
# By default, the name of the VM is the project's directory name # By default, the name of the VM is the project's directory name
$hostname = File.basename($root) $hostname = File.basename($root).downcase
Vagrant.configure("2") do |config| Vagrant.configure("2") do |config|
# Configure hostmanager
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.ignore_private_ip = false
config.hostmanager.include_offline = true
config.vm.hostname = $hostname
config.vm.provider :virtualbox do |v| config.vm.provider :virtualbox do |v|
v.name = $hostname v.name = $hostname
v.customize [ v.customize [
@@ -76,8 +79,8 @@ Vagrant.configure("2") do |config|
if which('ansible-playbook') if which('ansible-playbook')
config.vm.provision "ansible" do |ansible| config.vm.provision "ansible" do |ansible|
ansible.playbook = "resources/ansible/playbook.yml" ansible.playbook = "resources/ansible/playbook.yml"
#ansible.inventory_path = "ansible/inventories/dev"
ansible.limit = 'all' ansible.limit = 'all'
ansible.verbose = 'v'
ansible.extra_vars = { ansible.extra_vars = {
hostname: $hostname, hostname: $hostname,
postfix: { postfix: {

View File

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

View File

@@ -13,3 +13,4 @@
- xdebug - xdebug
- composer - composer
- app - app
- mailcatcher

View File

@@ -0,0 +1,2 @@
---
mailcatcher_gem: mailcatcher

View File

@@ -5,7 +5,8 @@
- name: Add MariaDB-Repository - name: Add MariaDB-Repository
sudo: yes sudo: yes
apt_repository: repo='deb http://mirror3.layerjet.com/mariadb/repo/10.1/ubuntu {{ ansible_distribution_release }} main' state=present apt_repository: repo='deb http://mirror6.layerjet.com/mariadb/repo/10.1/ubuntu {{ ansible_distribution_release }} main' state=present
register: mariadb_repository
- name: Add Key for MariaDB Repository - name: Add Key for MariaDB Repository
sudo: yes sudo: yes
@@ -14,6 +15,7 @@
- name: Update apt - name: Update apt
sudo: yes sudo: yes
apt: update_cache=yes apt: update_cache=yes
when: mariadb_repository.changed
- name: mariadb | Install MariaDB Packages - name: mariadb | Install MariaDB Packages
sudo: yes sudo: yes

View File

@@ -5,5 +5,5 @@
- name: Change default nginx site - name: Change default nginx site
sudo: yes sudo: yes
template: src=default.tpl dest=/etc/nginx/sites-available/default template: src=default.j2 dest=/etc/nginx/sites-available/default
notify: restart nginx notify: restart nginx

View File

@@ -4,7 +4,7 @@ server {
root {{ nginx.docroot }}; root {{ nginx.docroot }};
index index.html index.php; index index.html index.php;
server_name {{ nginx.servername }}; server_name {{ nginx|to_yaml }};
location / { location / {
try_files $uri $uri/ /index.php?$query_string; try_files $uri $uri/ /index.php?$query_string;

View File

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

View File

@@ -2,6 +2,7 @@
- name: Update apt - name: Update apt
sudo: yes sudo: yes
apt: update_cache=yes apt: update_cache=yes
when: server.prevent_update is defined
- name: Install System Packages - name: Install System Packages
sudo: yes sudo: yes
@@ -19,13 +20,13 @@
- name: Configure the timezone - name: Configure the timezone
sudo: yes sudo: yes
template: src=timezone.tpl dest=/etc/timezone template: src=timezone.j2 dest=/etc/timezone
- name: More Configure the timezone - name: More Configure the timezone
sudo: yes sudo: yes
file: src=/usr/share/zoneinfo/{{server.timezone}} dest=/etc/localtime state=link force=yes backup=yes file: src=/usr/share/zoneinfo/{{server.timezone}} dest=/etc/localtime state=link force=yes backup=yes
- name: Set default system language pack - name: Set default system language pack
shell: locale-gen {{server.locale}} shell: locale-gen {{server.locales|join(' ')}}
sudo: yes sudo: yes

View File

@@ -8,4 +8,5 @@
when: vagrant_local.vm.hostname is defined when: vagrant_local.vm.hostname is defined
- name: Update /etc/hosts - 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 lineinfile: dest=/etc/hosts regexp='^127\.0\.0\.1' line='127.0.0.1 localhost {{ vagrant_local.vm.hostname|default('') }}' owner=root group=root mode=0644
when: vagrant_local.vm.hostname is defined

View File

@@ -1,16 +1,34 @@
--- ---
server: server:
install: '1' install: '1'
packages: [vim, git, imagemagick, htop, nodejs, npm, iotop, pkg-config, libzmq3-dev] packages:
- vim
- git
- imagemagick
- htop
- nodejs
- npm
- iotop
- pkg-config
- libzmq3-dev
- supervisor
timezone: UTC timezone: UTC
locale: fr_FR.UTF-8 locales:
- en_GB.UTF-8
- fr_FR.UTF-8
- de_DE.UTF-8
- nl_NL.UTF-8
vagrant_local: vagrant_local:
install: '1' install: '1'
vm: { base_box: trusty64, hostname: phraseanet.dev, ip: 192.168.56.101, memory: '4096', sharedfolder: ./, useVagrantCloud: '1', syncType: nfs } vm:
base_box: trusty64
memory: '4096'
sharedfolder: ./
useVagrantCloud: '1'
syncType: nfs
nginx: nginx:
install: '1' install: '1'
docroot: /vagrant docroot: /vagrant
servername: master.phraseanet.vb
mariadb: mariadb:
install: '1' install: '1'
root_password: toor root_password: toor
@@ -21,7 +39,7 @@ mariadb:
elasticsearch: elasticsearch:
install: '1' install: '1'
port: '9200' port: '9200'
version: 1.5.2 version: '1.7.3'
php: php:
install: '1' install: '1'
ppa: php5 ppa: php5