diff --git a/Vagrantfile b/Vagrantfile index 3c3b583..b1383c6 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,40 +1,10 @@ require 'berkshelf/vagrant' Vagrant::Config.run do |config| - # All Vagrant configuration is done here. The most common configuration - # options are documented and commented below. For a complete reference, - # please see the online documentation at vagrantup.com. - - # The path to the Berksfile to use with Vagrant Berkshelf - # config.berkshelf.berksfile_path = "./Berksfile" - - # An array of symbols representing groups of cookbook described in the Vagrantfile - # to skip installing and copying to Vagrant's shelf. - # config.berkshelf.only = [] - - # An array of symbols representing groups of cookbook described in the Vagrantfile - # to skip installing and copying to Vagrant's shelf. - # config.berkshelf.except = [] - config.vm.host_name = "crystalline-berkshelf" - -# config.vm.box = "Berkshelf-CentOS-6.3-x86_64-minimal" -# config.vm.box_url = "https://dl.dropbox.com/u/31081437/Berkshelf-CentOS-6.3-x86_64-minimal.box" config.vm.box = "lucid32" - # Boot with a GUI so you can see the screen. (Default is headless) - # config.vm.boot_mode = :gui - - # Assign this VM to a host-only network IP, allowing you to access it - # via the IP. Host-only networks can talk to the host machine as well as - # any other machines on the same network, but cannot be accessed (through this - # network interface) by any external networks. - config.vm.network :hostonly, "33.33.33.10" - - # Assign this VM to a bridged network, allowing you to connect directly to a - # network using the host's network device. This makes the VM appear as another - # physical device on your network. - + #config.vm.network :hostonly, "33.33.33.10" config.vm.network :bridged # Forward a port from the guest to the host, which allows for outside @@ -44,7 +14,7 @@ Vagrant::Config.run do |config| # Share an additional folder to the guest VM. The first argument is # an identifier, the second is the path on the guest to mount the # folder, and the third is the path on the host to the actual folder. - config.vm.share_folder "appdir", "/tmp/vagrant_data", "../crystalline" + config.vm.share_folder "appdir", "/tmp/app", "../crystalline" config.ssh.max_tries = 40 config.ssh.timeout = 120 @@ -55,6 +25,9 @@ Vagrant::Config.run do |config| :server_root_password => 'rootpass', :server_debian_password => 'debpass', :server_repl_password => 'replpass' + }, + :crystalline => { + :database_server => '192.168.0.169' } } diff --git a/attributes/default.rb b/attributes/default.rb index a33c147..c0cfb76 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -7,8 +7,15 @@ # All rights reserved - Do Not Redistribute # -default[:app][:user] = 'crystalline' -default[:app][:group] = 'appgroup' -default[:app][:url] = 'git://github.com/iancoffey/crystalline' -default[:app][:revision] = 'HEAD' -default[:app][:local_config][:file] = '' +default[:crystalline][:user] = 'crystalline' +default[:crystalline][:group] = 'appgroup' +default[:crystalline][:url] = 'git://github.com/iancoffey/crystalline' +default[:crystalline][:revision] = 'HEAD' +default[:crystalline][:database_server] = 'localhost' +default[:crystalline][:database_name] = 'crystalline' +default[:crystalline][:keepalive] = '100' +default[:crystalline][:api_authkey] = 'changeme' +default[:crystalline][:api_secret] = 'me' + + + diff --git a/recipes/default.rb b/recipes/default.rb index fa57fe9..a7463bf 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -15,11 +15,9 @@ common_tools = %w{ vim curl wget } -ENV['CRYSTALLINE_SETTINGS'] = node[:app][:config] +group node[:crystalline][:group] -group node[:app][:group] - -user node[:app][:user] do +user node[:crystalline][:user] do system true shell "/bin/bash" end @@ -37,21 +35,29 @@ end directory "/opt/crystalline/shared" do - owner node[:app][:user] - group node[:app][:group] + owner node[:crystalline][:user] + group node[:crystalline][:group] recursive true end +template "/opt/crystalline/shared/config.ini" do + source "config.ini.erb" + mode 755 + owner node[:crystalline][:user] + group node[:crystalline][:group] + variables({}.merge(node[:crystalline])) +end + deploy "/opt/crystalline" do - repo node[:app][:url] - revision node[:app][:revision] - user node[:app][:user] - group node[:app][:group] + repo node[:crystalline][:url] + revision node[:crystalline][:revision] + user node[:crystalline][:user] + group node[:crystalline][:group] enable_submodules true action :deploy - restart_command "touch tmp/restart.txt" +# restart_command "touch tmp/restart.txt" scm_provider Chef::Provider::Git - symlink_before_migrate({}) + create_dirs_before_symlink(%w{logs}) + symlinks({}) + symlink_before_migrate({'config.cfg' => 'config.cfg'}) end - - diff --git a/templates/default/config.ini.erb b/templates/default/config.ini.erb new file mode 100644 index 0000000..e1f59d8 --- /dev/null +++ b/templates/default/config.ini.erb @@ -0,0 +1,7 @@ +[ database ] +name = <%= @database_name %> +host = <%= @database_server %> +[ api ] +authkey = <%= @api_authkey %> +secret = "<%= @api_secret %> +