Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
default['s3cmd']['encrypt'] = false
default['s3cmd']['https'] = false
default['s3cmd']['user'] = 'ubuntu'
default['s3cmd']['install_method'] = 'source'
27 changes: 27 additions & 0 deletions recipes/configure.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# Cookbook Name:: s3cmd
# Recipe:: configure
# Frederico Araujo (fred.the.master@gmail.com)
# https://github.com/fred/chef-s3cmd
#

if node['s3cmd']['config_dir']
home_folder = node['s3cmd']['config_dir']
else
home_folder = node['etc']['passwd'][node['s3cmd']['user']]['dir']

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be home_folder = node['s3cmd']['user']]['dir']

end

template "#{home_folder}/.s3cfg" do
source "s3cfg.erb"
variables(
:access_key => node['s3cmd']['access_key'],
:secret_key => node['s3cmd']['secret_key'],
:gpg_passphrase => node['s3cmd']['gpg_passphrase'],
:bucket_location => node['s3cmd']['bucket_location'],
:https => node['s3cmd']['https'],
:encrypt => node['s3cmd']['encrypt']
)
owner node['s3cmd']['user']
group node['s3cmd']['user']
mode 0600
end
49 changes: 10 additions & 39 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,15 @@
# https://github.com/fred/chef-s3cmd
#

package "python"
package "python-setuptools"
package "python-distutils-extra"
package "python-dateutil"


remote_file "#{Chef::Config[:file_cache_path]}/master.tar.gz" do
source node['s3cmd']['url']
mode "0644"
end

bash "install-s3cmd" do
user "root"
cwd Chef::Config[:file_cache_path]
code <<-EOH
tar xzvf master.tar.gz
cd s3cmd-master
python setup.py install
EOH
# install s3cmd based on your configuration
case node['s3cmd']['install_method']
when 'source'
include_recipe 's3cmd::install_from_source'
when 'package'
include_recipe 's3cmd::install_from_package'
else
Chef::Application.fatal!("There install method #{node['s3cmd']['install_method']} is not provided; please use one of: 'source', 'package'.")
end

if node['s3cmd']['config_dir']
home_folder = node['s3cmd']['config_dir']
else
home_folder = node['etc']['passwd'][node['s3cmd']['user']]['dir']
end

template "#{home_folder}/.s3cfg" do
source "s3cfg.erb"
variables(
:access_key => node['s3cmd']['access_key'],
:secret_key => node['s3cmd']['secret_key'],
:gpg_passphrase => node['s3cmd']['gpg_passphrase'],
:bucket_location => node['s3cmd']['bucket_location'],
:https => node['s3cmd']['https'],
:encrypt => node['s3cmd']['encrypt']
)
owner node['s3cmd']['user']
group node['s3cmd']['user']
mode 0600
end
# configure s3cmd
include_recipe 's3cmd::configure'
8 changes: 8 additions & 0 deletions recipes/install_from_package.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Cookbook Name:: s3cmd
# Recipe:: install_from_package
# Frederico Araujo (fred.the.master@gmail.com)
# https://github.com/fred/chef-s3cmd
#

package 's3cmd'
27 changes: 27 additions & 0 deletions recipes/install_from_source.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# Cookbook Name:: s3cmd
# Recipe:: install_from_source
# Frederico Araujo (fred.the.master@gmail.com)
# https://github.com/fred/chef-s3cmd
#

package "python"
package "python-setuptools"
package "python-distutils-extra"
package "python-dateutil"


remote_file "#{Chef::Config[:file_cache_path]}/master.tar.gz" do
source node['s3cmd']['url']
mode "0644"
end

bash "install-s3cmd" do
user "root"
cwd Chef::Config[:file_cache_path]
code <<-EOH
tar xzvf master.tar.gz
cd s3cmd-master
python setup.py install
EOH
end