mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-16 06:23:18 +00:00
Update provisioning workflow, check if a box name is defined. A playbook for box usage is created
This commit is contained in:
46
Vagrantfile
vendored
46
Vagrantfile
vendored
@@ -1,16 +1,5 @@
|
|||||||
Vagrant.require_version ">= 1.5"
|
Vagrant.require_version ">= 1.5"
|
||||||
|
require 'json'
|
||||||
class MyCustomError < StandardError
|
|
||||||
attr_reader :code
|
|
||||||
|
|
||||||
def initialize(code)
|
|
||||||
@code = code
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_s
|
|
||||||
"[#{code} #{super}]"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Check to determine whether we're on a windows or linux/os-x host,
|
# 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
|
# later on we use this to launch ansible in the supported way
|
||||||
@@ -39,7 +28,16 @@ unless Vagrant.has_plugin?('vagrant-hostmanager')
|
|||||||
raise "vagrant-hostmanager is not installed! Please run\n vagrant plugin install vagrant-hostmanager\n\n"
|
raise "vagrant-hostmanager is not installed! Please run\n vagrant plugin install vagrant-hostmanager\n\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
if ARGV[1] == '--provision'
|
# Check to determine if box_meta JSON is present
|
||||||
|
# if provisionned : pick name of box
|
||||||
|
if File.file?(".vagrant/machines/default/virtualbox/box_meta")
|
||||||
|
data = File.read(".vagrant/machines/default/virtualbox/box_meta")
|
||||||
|
parsed_json = JSON.parse(data)
|
||||||
|
$box = parsed_json["name"]
|
||||||
|
end
|
||||||
|
|
||||||
|
# if not : run prompt to configure provisioning
|
||||||
|
if !File.file?(".vagrant/machines/default/virtualbox/box_meta") && ARGV[0] == 'up'
|
||||||
print "\033[34m \nChoose a Build type :\n\n(1) Use prebuilt Phraseanet Box\n(2) Build Phraseanet from scratch (xenial)\n\033[00m"
|
print "\033[34m \nChoose a Build type :\n\n(1) Use prebuilt Phraseanet Box\n(2) Build Phraseanet from scratch (xenial)\n\033[00m"
|
||||||
type = STDIN.gets.chomp
|
type = STDIN.gets.chomp
|
||||||
print "\n"
|
print "\n"
|
||||||
@@ -47,9 +45,10 @@ if ARGV[1] == '--provision'
|
|||||||
case (type)
|
case (type)
|
||||||
when '1'
|
when '1'
|
||||||
$box = "alchemy/Phraseanet-vagrant-dev_php"
|
$box = "alchemy/Phraseanet-vagrant-dev_php"
|
||||||
|
$playbook = "resources/ansible/playbook-boxes.yml"
|
||||||
when '2'
|
when '2'
|
||||||
$box = "ubuntu/xenial64"
|
$box = "ubuntu/xenial64"
|
||||||
print("\033[91mComplete build selected, don't forget to uncomment all roles on playbook.yml\n\n\033[00m")
|
$playbook = "resources/ansible/playbook.yml"
|
||||||
else
|
else
|
||||||
raise "\033[31mYou should specify Build type before running vagrant\n\n (Available : 1, 2)\n\n\033[00m"
|
raise "\033[31mYou should specify Build type before running vagrant\n\n (Available : 1, 2)\n\n\033[00m"
|
||||||
end
|
end
|
||||||
@@ -133,8 +132,6 @@ else if $env == "linux"
|
|||||||
$hostIps = `ifconfig | sed -nE 's/[[:space:]]*inet ([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})(.*)$/\\1/p'`.split("\n");
|
$hostIps = `ifconfig | sed -nE 's/[[:space:]]*inet ([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})(.*)$/\\1/p'`.split("\n");
|
||||||
else
|
else
|
||||||
$hostIps = `resources/ansible/inventories/GetIpAdresses.cmd`;
|
$hostIps = `resources/ansible/inventories/GetIpAdresses.cmd`;
|
||||||
# raise MyCustomError.new($hostIps), "HOST IP"
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -157,21 +154,17 @@ Vagrant.configure("2") do |config|
|
|||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
config.vm.box = ($box) ? $box : "ubuntu/xenial64"
|
config.vm.box = $box
|
||||||
|
|
||||||
# In case, Phraseanet box, choose the php version
|
|
||||||
# For php 7.0 use box 0.0.1
|
|
||||||
# For php 7.1 use box 0.0.2
|
|
||||||
#config.vm.box_version = "0.0.1"
|
|
||||||
|
|
||||||
config.ssh.forward_agent = true
|
config.ssh.forward_agent = true
|
||||||
config_net(config)
|
config_net(config)
|
||||||
|
|
||||||
# If ansible is in your path it will provision from your HOST machine
|
# If ansible is in your path it will provision from your HOST machine
|
||||||
# If ansible is not found in the path it will be instaled in the VM and provisioned from there
|
# If ansible is not found in the path it will be instaled in the VM and provisioned from there
|
||||||
if which('ansible-playbook')
|
if which('ansible-playbook')
|
||||||
|
|
||||||
|
if $playbook
|
||||||
config.vm.provision "ansible_local" do |ansible|
|
config.vm.provision "ansible_local" do |ansible|
|
||||||
ansible.playbook = "resources/ansible/playbook.yml"
|
ansible.playbook = $playbook
|
||||||
ansible.limit = 'all'
|
ansible.limit = 'all'
|
||||||
ansible.verbose = 'vvv'
|
ansible.verbose = 'vvv'
|
||||||
ansible.extra_vars = {
|
ansible.extra_vars = {
|
||||||
@@ -183,6 +176,7 @@ Vagrant.configure("2") do |config|
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
config.vm.provision "ansible_local", run: "always" do |ansible|
|
config.vm.provision "ansible_local", run: "always" do |ansible|
|
||||||
ansible.playbook = "resources/ansible/playbook-always.yml"
|
ansible.playbook = "resources/ansible/playbook-always.yml"
|
||||||
@@ -194,10 +188,6 @@ Vagrant.configure("2") do |config|
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
# raise MyCustomError.new([$hostname, $phpVersion, $hostIps]), "HOST IP"
|
|
||||||
# raise MyCustomError.new($hostIps), "HOST IP"
|
|
||||||
# raise MyCustomError.new($hostIps), "HOST IP"
|
|
||||||
|
|
||||||
config.vm.provision :shell, path: "resources/ansible/windows.sh", args: [$hostname, $phpVersion, $hostIps]
|
config.vm.provision :shell, path: "resources/ansible/windows.sh", args: [$hostname, $phpVersion, $hostIps]
|
||||||
# config.vm.provision :shell, run: "always", path: "resources/ansible/windows-always.sh", args: ["default"]
|
# config.vm.provision :shell, run: "always", path: "resources/ansible/windows-always.sh", args: ["default"]
|
||||||
end
|
end
|
||||||
|
21
resources/ansible/playbook-boxes.yml
Normal file
21
resources/ansible/playbook-boxes.yml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
- hosts: all
|
||||||
|
sudo: true
|
||||||
|
vars_files:
|
||||||
|
- vars/all.yml
|
||||||
|
roles:
|
||||||
|
# - server
|
||||||
|
# - repositories
|
||||||
|
# - vagrant_local
|
||||||
|
# - nginx
|
||||||
|
# - mariadb
|
||||||
|
# - elasticsearch
|
||||||
|
# - rabbitmq
|
||||||
|
# - php
|
||||||
|
# - xdebug
|
||||||
|
# - composer
|
||||||
|
# - mailcatcher
|
||||||
|
# - node
|
||||||
|
# - yarn
|
||||||
|
# - ffmpeg
|
||||||
|
- app
|
@@ -4,18 +4,18 @@
|
|||||||
vars_files:
|
vars_files:
|
||||||
- vars/all.yml
|
- vars/all.yml
|
||||||
roles:
|
roles:
|
||||||
# - server
|
- server
|
||||||
# - repositories
|
- repositories
|
||||||
# - vagrant_local
|
- vagrant_local
|
||||||
- nginx
|
- nginx
|
||||||
# - mariadb
|
- mariadb
|
||||||
# - elasticsearch
|
- elasticsearch
|
||||||
# - rabbitmq
|
- rabbitmq
|
||||||
# - php
|
- php
|
||||||
- xdebug
|
- xdebug
|
||||||
# - composer
|
- composer
|
||||||
# - mailcatcher
|
- mailcatcher
|
||||||
# - node
|
- node
|
||||||
# - yarn
|
- yarn
|
||||||
# - ffmpeg
|
- ffmpeg
|
||||||
- app
|
- app
|
||||||
|
Reference in New Issue
Block a user