Browse files

Bugfixes in composer::configure:

 * ensure the deploy user is created before used
 * add a couple if's to check status/environment
 * test this with vagrant
  • Loading branch information...
1 parent 7947a2c commit 5d5fb0b4fe23c1e9960d9b4f0ff18111c20e6188 @till committed Nov 22, 2012
Showing with 84 additions and 17 deletions.
  1. +45 −14 composer/recipes/configure.rb
  2. +4 −3 vagrant-test/Vagrantfile
  3. +35 −0 vagrant-test/deploy.json
View
59 composer/recipes/configure.rb
@@ -1,16 +1,47 @@
-directory "/home/#{node[:scalarium][:deploy_user][:user]}/.composer" do
- owner node[:scalarium][:deploy_user][:user]
- group node[:scalarium][:deploy_user][:group]
- mode "0750"
- recursive true
-end
+if node[:scalarium]
+
+ deploy_username = node[:scalarium][:deploy_user][:user]
+ deploy_group = node[:scalarium][:deploy_user][:group]
+
+ # this is an assumption, so sue me
+ home_dir = "/home/#{deploy_username}"
+
+ # copied this from scalarium's deploy/definition/scalarium_deploy_user.rb
+ user deploy_username do
+ action :create
+ comment "deploy user"
+ gid deploy_group
+ supports :manage_home => true
+ shell node[:scalarium][:deploy_user][:shell]
+ home home_dir
+ not_if do
+ existing_usernames = []
+ Etc.passwd {|user| existing_usernames << user['name']}
+ existing_usernames.include?(deploy_username)
+ end
+ end
+
+ directory "#{home_dir}/.composer" do
+ owner deploy_username
+ group deploy_group
+ mode "0750"
+ recursive true
+ end
+
+ if node["composer"]
+ template "#{home_dir}/.composer/config.json" do
+ owner deploy_username
+ group deploy_group
+ source "composer.config.json.erb"
+ mode "0640"
+ variables(
+ :oauth_key => node["composer"]["oauth_key"]
+ )
+ end
+ else
+ Chef::Log.error('Configuration error, missing node["composer"]["oauth_key"]')
+ end
-template "/home/#{node[:scalarium][:deploy_user][:user]}/.composer/config.json" do
- owner node[:scalarium][:deploy_user][:user]
- group node[:scalarium][:deploy_user][:group]
- source "composer.config.json.erb"
- mode "0640"
- variables(
- :oauth_key => node["composer"]["oauth_key"]
- )
+else
+ Chef::Log.debug("Recipe requires `scalarium` to be present.")
end
View
7 vagrant-test/Vagrantfile
@@ -1,5 +1,6 @@
Vagrant::Config.run do |config|
- config.vm.box = "lucid-nfs_0.1_4.1.0"
+
+ config.vm.box = "easybib-ubuntu-10.04.4_vbox-4.1.8"
config.vm.network :hostonly, "33.33.33.124"
@@ -11,8 +12,6 @@ Vagrant::Config.run do |config|
"--memory", "256"
]
- config.vm.provision :shell, :path => "./update-mirrors.sh"
-
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "./../"
chef.log_level = :debug
@@ -23,5 +22,7 @@ Vagrant::Config.run do |config|
chef.add_recipe "composer::configure"
chef.add_recipe "php-suhosin"
chef.add_recipe "php-gearman"
+
+ chef.json = JSON.parse(File.read("./deploy.json"))
end
end
View
35 vagrant-test/deploy.json
@@ -0,0 +1,35 @@
+{
+ "deploy": {
+ "ssl": {
+ "ssl_certificate": "",
+ "ssl_certificate_key": "",
+ "domains": [
+ "vagrant.local",
+ "ssl"
+ ]
+ }
+ },
+ "scalarium": {
+ "deploy_user": {
+ "user": "deploy",
+ "group": "www-data"
+ },
+ "activity": "deploy",
+ "applications": [
+ {
+ "name": "SSL",
+ "slug_name": "ssl",
+ "application_type": "other"
+ }
+ ],
+ "cluster": {
+ "name": "EasyBib Playground"
+ },
+ "instance": {
+ "id": 1,
+ "roles": [
+ "lb"
+ ]
+ }
+ }
+}

0 comments on commit 5d5fb0b

Please sign in to comment.