Commit ac71307

mo khan <mo@mokhan.ca>
2015-12-24 18:40:51
fix broken chefspecs.
1 parent 9128f93
libraries/aws.rb
@@ -1,26 +0,0 @@
-class Chef
-  class Recipe
-    def aws_cli(username)
-      package "python-pip"
-      execute "pip install awscli"
-
-      home = node['etc']['passwd'][username]['dir']
-      directory "#{home}/.aws/" do
-        owner username
-        group username
-        mode "0755"
-        recursive true
-        action :create
-      end
-
-      configuration = node["stronglifters"]["aws"]
-      template "#{home}/.aws/config" do
-        variables(configuration)
-      end
-
-      template "#{home}/.aws/credentials" do
-        variables(configuration)
-      end
-    end
-  end
-end
recipes/aws.rb
@@ -0,0 +1,21 @@
+package "python-pip"
+execute "pip install awscli"
+
+username = node["stronglifters"]["username"]
+home = node['etc']['passwd'][username]['dir']
+directory "#{home}/.aws/" do
+  owner username
+  group username
+  mode "0755"
+  recursive true
+  action :create
+end
+
+configuration = node["stronglifters"]["aws"]
+template "#{home}/.aws/config" do
+  variables(configuration)
+end
+
+template "#{home}/.aws/credentials" do
+  variables(configuration)
+end
recipes/postgres.rb
@@ -61,7 +61,7 @@ file "/var/lib/postgresql/.pgpass" do
   user "postgres"
 end
 
-aws_cli("postgres")
+#aws_cli("postgres")
 
 cron 'pg_backups' do
   action :create
@@ -69,6 +69,7 @@ cron 'pg_backups' do
   environment({
     "PGPASSFILE" => "/var/lib/postgresql/.pgpass",
     "PGPASSWORD" => node["postgresql"]["password"]["postgres"],
+    "AWS_KEY" => "",
   })
   hour '1'
   minute '0'
recipes/rails.rb
@@ -1,5 +1,5 @@
 include_recipe "stronglifters::user"
-aws_cli(node["stronglifters"]["username"])
+include_recipe "stronglifters::aws"
 
 root_path = node["stronglifters"]["root_path"]
 shared_path = File.join(root_path, "shared")
@@ -41,4 +41,5 @@ runit_service "foreman" do
   log_size 1_000_000
   log_num 31
   retries 3
+  #only_if { ::File.exists?("#{File.join(root_path, "current")}/Procfile") }
 end if File.exists?("#{File.join(root_path, "current")}/Procfile")
spec/aws_spec.rb
@@ -2,6 +2,7 @@ describe "stronglifters::aws" do
   subject do
     ChefSpec::SoloRunner.new do |node|
       node.set["stronglifters"]["username"] = username
+      node.set["etc"]["passwd"][username]["dir"] = "/home/#{username}"
     end.converge(described_recipe)
   end
 
spec/rails_spec.rb
@@ -7,10 +7,11 @@ describe "stronglifters::rails" do
       node.set["postgres"]["username"] = username
       node.set["postgres"]["password"] = "password"
       node.set["postgres"]["host"] = "localhost"
+      node.set["etc"]["passwd"][username]["dir"] = "/home/#{username}"
     end.converge(described_recipe)
   end
   let(:root_path) { "/var/www/#{FFaker::Internet.domain_name}"  }
-  let(:shared_path) { "#{root_path}/shared" }
+  let(:shared_path) { File.join(root_path, "shared") }
   let(:username) { "deployer" }
 
   before :each do