Chef Cookbook to Install and Manage s3cmd for amazon s3
This is a Chef cookbook to manage s3cmd using LWRP.
This cookbook allows to manage different s3cmd config files, sync a directory or sync a s3 file and it can be extracted to a directory.
https://github.com/vkhatri/chef-s3cmd-ng
s3cmd::default
- default recipe (used for run_list)
s3cmd::install
- install s3cmd
default['s3cmd']['setup_epel']
(default: true
): whether to setup epel repository using cookbook yum-epel
default['s3cmd']['user']
(default: root
): s3cmd default user, used in lwrp
default['s3cmd']['group']
(default: root
): s3cmd default group, used in lwrp
default['s3cmd']['mode']
(default: 0750
): s3cmd file/directories permission
default['s3cmd']['umask']
(default: 0027
): s3cmd file/directories umask
default['s3cmd']['manage_sync_dir']
(default: true
): whether to manage s3 sync dir, used in lwrp dir
default['s3cmd']['template_source']
(default: s3cfg.conf.erb
): s3cmd config file template name for lwrp s3cmd_cfg
default['s3cmd']['template_cookbook']
(default: 15
): s3cmd config file template cookbook name for lwrp s3cmd_cfg
default['s3cmd']['download_dir']
(default: /tmp
): s3 download location for lwrp s3cmd_file
default['s3cmd']['file']
(default: nil
): s3cmd default config file location for lwrp s3cmd_cfg
default['s3cmd']['binary']
(default: /usr/bin/s3cmd
): s3cmd binary command location, used by lwrp s3cmd_dir
and s3cmd_file
default['s3cmd']['config']['S3CMD_OPTION']
(default: S3CMD_OPTION_VALUE
): s3cmd config file attributes for lwrp s3cmd_cfg
, check lwrp resource file for more details
s3cmd_cfg
: create s3cmd config files3cmd_file
: s3 get file resource which also supports tar file extracts3cmd_dir
: s3 sync directory resourceLWRP s3cmd_cfg
is used to create/delete s3cmd config file.
Create a s3cmd config file
s3cmd_cfg "foo" do
access_key "aws s3 access key"
secret_key "aws s3 secret key"
file "file location"
user "user name"
group "group name"
region "aws region name, e.g. Singapore"
option "value" ..
end
Create a s3cmd config file from a databag
s3cmd_cfg "foo" do
file "file location"
user "user name"
group "group name"
databag "databag name for aws access/secret key"
databag_item "databag item name to load access_key & secret_key"
databag_secret "encrypted databag secret if any"
bucket_location "aws region name, e.g. Singapore"
option "value" ..
end
Delete a s3cmd config file
s3cmd_cfg "foo" do
action :delete
end
LWRP Options
Parameters:
node['s3cmd']['file']
) - s3cmd config file locationnode['s3cmd']['user']
) - s3cmd config file usernode['s3cmd']['group']
) - s3cmd config file groupnode['s3cmd']['mode']
) - s3cmd config file modenode['s3cmd']['template_source']
) - s3cmd config file template sourcenode['s3cmd']['template_cookbook']
) - s3cmd config file template cookbooknode['s3cmd']['databag']
) - data bag for access_key
and secret_key
node['s3cmd']['databag_item']
) - data bag itemdatabag_secret (default: node['s3cmd']['databag_secret']
) - encrypted data bag secret
access_key (default: node['s3cmd']['config']['access_key']
) - s3cmd config access_key
node['s3cmd']['config']['secret_key']
) - s3cmd config secret_keynode['s3cmd']['config']['bucket_location']
) - s3cmd config bucket_location / aws regionDEFAULT_VALUE
) - s3cmd config optionLWRP s3cmd_dir
is a wrapper for s3cmd sync
.
Create a s3cmd sync dir resource
s3cmd_dir "foo" do
s3cfg_file "s3cmd config file"
s3_url "s3 bucket url"
user "user name"
group "group name"
s3cmd_options "--option value --option value .. if any"
sync_dir "local dir to sync s3 url to"
verify_file "verify file, raie exception is missing"
mode "dirs / files mode"
umask "user umask"
manage_sync_dir "whether to manage local sync dir"
end
Delete a s3cmd sync dir
s3cmd_dir "foo" do
action :delete
end
LWRP Options
Parameters:
nil
, required: true
) - s3cmd config file locationnil
, required: true
) - s3 bucket location to sync to sync_dir
nil
) - s3cmd options for s3cmd sync
nil
, required: true
) - sync s3 url to this locationnil
) - verify file / location in sync_dir
after s3cmd sync
, raise exception is missingnode['s3cmd']['user']
) - sync_dir
file user ownershipnode['s3cmd']['group']
) - sync_dir
file group ownershipnode['s3cmd']['mode']
) - sync_dir
file permissionsnode['s3cmd']['umask']
) - sync_dir user exec umasknode['s3cmd']['manage_sync_dir']
) - whether to manage directory sync_dir
node['s3cmd']['binary']
) - s3cmd command locationLWRP s3cmd_dir
is a wrapper for s3cmd sync
.
Create a s3cmd sync dir resource
s3cmd_file "foo" do
s3cfg_file "s3cmd config file"
s3_url "s3 bucket file url"
user "user name"
group "group name"
s3cmd_options "--option value --option value .. if any"
download_dir "local dir to download s3 file"
manage_download_dir true # whether to manage download_dir
extract_dir "untar a tar file to this location"
extract true # whether to extract a tar file
mode "dirs / files mode"
umask "user umask"
end
Delete a s3cmd file
s3cmd_file "foo" do
s3_url "s3 bucket file url"
download_dir "download location"
extract_dir "directory location" # delete extract directory if specified
action :delete
end
LWRP Options
Parameters:
nil
, required: true
) - s3cmd config file locationnil
, required: true
) - s3 file location for s3cmd get
nil
) - s3cmd options for s3cmd get
node['s3cmd']['download_dir']
) - download s3 file herefalse
) - whether to extract a tar filenode['s3cmd']['download_dir']
) - extract s3 tar file herenode['s3cmd']['user']
) - files user ownershipnode['s3cmd']['group']
) - files group ownershipnode['s3cmd']['mode']
) - files permissionsnode['s3cmd']['umask']
) - files user exec umasknode['s3cmd']['manage_sync_dir']
) - whether to manage directory download_dir
node['s3cmd']['binary']
) - s3cmd command locationadd_component_x
)rake
), ensuring they all passREADME.md
Authors:: Virender Khatri and Contributors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.