cookbook 'asset_provider', '~> 0.2.1'
asset_provider (3) Versions 0.2.1 Follow0
Installs/Configures asset_provider
cookbook 'asset_provider', '~> 0.2.1', :supermarket
knife supermarket install asset_provider
knife supermarket download asset_provider
asset_provider
Provides two LWRPs to manage the fetching of remote resources: asset_provider_directory
and asset_provider_file
.
The main reason to create this cookbook was the asset_provider_directory
LWRP, to allow for a simple way of transferring full directories as tarballs from a remote HTTP/S server to a node being converged.
Typically this LWRP is used with piedesaint, as this lightweight server based on Puma supports the transfer of full directories via cached tarballs, created on the fly.
In addition to this, by centralizing the configuration of the asset provider server, it declutters the configuration of multiple remote sources from the same endpoint.
Requirements
This is a Chef Cookbook and therefore requires a Chef installation.
When using the asset_provider_directory
LWRP, an accessible tar
installation is expected in the converging node.
Usage
Typically this cookbook will be used as a dependency of more complex one introducing recipes.
Add the corresponding dependency to the metadata.rb
or any other dependency description file.
%w{asset_provider}.each do |cookbook|
depends cookbook
end
Then, set the correct node attributes to point to your asset provider and have fun using assset_provider_directory
and asset_provider_file
.
Attributes
It's so much better if you take a look at the attributes/default.rb
file for the full list, but this is a brief summary:
- node[:asset_provider][:username] - Basic Authentication username. Default is: 'user'.
- node[:asset_provider][:password] - Basic Authentication password. Default is: 'password'.
- node[:asset_provider][:protocol] - Asset Provider protocol. Default is: 'http'.
- node[:asset_provider][:host] - Asset Provider hostname or IP. Default is: 'localhost'.
- node[:asset_provider][:port] - Asset Provider TCP port. Default is: '8080'.
LWRPs
asset_provider_directory
syntax
execute "copy_#{web_server_name}_untared" do
command "cp -r /tmp/untarred/#{web_server_name}/* #{web_server[:root]}"
user node[:apache][:user]
group node[:apache][:group]
action :nothing
end
asset_provider_directory web_server_name do
tmp_folder '/tmp/untarred'
chown_user node['apache']['user']
chown_group node['apache']['group']
notifies :run, "execute[copy_#{web_server_name}_untared]", :immediately
end
This example will fetch the web_server_name
resource from the asset provider, untar it, assign it to node['apache']['user']:node['apache']['group']
and then copy it to the root of the web server.
attributes
Attribute | Description | Example | Default |
---|---|---|---|
name | Resource name. It will be used to set the 'tmp_file' if that attribute is missing | 'myserver' | '' |
source | Path to the source folder in the asset provider server | 'myserver.backup.latest' | '' |
owner | User which will own the tar file once fetched | 'admin' | nil |
group | Group which will own the tar file once fetched | 'admin' | nil |
user | User to execute the untarring | 'admin' | nil |
chown_user | User to set as owner after untarring | 'foo' | nil |
chown_group | User to set as group after untarring | 'users' | nil |
tmp_file | File name for the fetched tarball | 'backup.temporary.tar' | nil |
tmp_folder | Folder where the temporary tar file will be untarred | '/tmp/untarred' | nil |
tmp_file
will be automatically set based on name
if it is not specified, like this;
tmp_file = File.join(Chef::Config[:file_cache_path], "#{new_resource.name}.tar")
-
owner
andgroup
are used to assing permissions to the fetched resource. -
user
is used to execute the untarring. -
chown_user
andchown_group
are used at the very last step.
asset_provider_file
example
asset_provider_file "/tmp/backup_file" do
source 'backup.latest'
owner 'apache'
group 'apache'
mode "0744"
notifies :run, "bash[import_backup_file]", :immediately
end
attributes
Attribute | Description | Example | Default |
---|---|---|---|
name | Destination path of the file in the node | '/tmp/backup_file' | '' |
source | Path to the source file in the asset provider server | 'backup.latest' | '' |
owner | User which will own the file once fetched | 'admin' | nil |
group | Group which will own the file once fetched | 'admin' | nil |
mode | File permissions | '0744' | '' |
Author
Author:: Tnarik Innael (tnarik@lecafeautomatique.co.uk)
Dependent cookbooks
This cookbook has no specified dependencies.
Contingent cookbooks
There are no cookbooks that are contingent upon this one.
Collaborator Number Metric
0.2.1 failed this metric
Failure: Cookbook has 0 collaborators. A cookbook must have at least 2 collaborators to pass this metric.
Contributing File Metric
0.2.1 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a CONTRIBUTING.md file
Foodcritic Metric
0.2.1 failed this metric
FC021: Resource condition in provider may not behave as expected: asset_provider/providers/directory.rb:17
FC064: Ensure issues_url is set in metadata: asset_provider/metadata.rb:1
FC065: Ensure source_url is set in metadata: asset_provider/metadata.rb:1
FC066: Ensure chef_version is set in metadata: asset_provider/metadata.rb:1
FC069: Ensure standardized license defined in metadata: asset_provider/metadata.rb:1
FC070: Ensure supports metadata defines valid platforms: asset_provider/metadata.rb:1
FC085: Resource using new_resource.updated_by_last_action to converge resource: asset_provider/providers/directory.rb:53
FC085: Resource using new_resource.updated_by_last_action to converge resource: asset_provider/providers/file.rb:31
Run with Foodcritic Version 16.3.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any
No Binaries Metric
0.2.1 passed this metric
Testing File Metric
0.2.1 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file
Version Tag Metric
0.2.1 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number
0.2.1 failed this metric
0.2.1 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a CONTRIBUTING.md file
Foodcritic Metric
0.2.1 failed this metric
FC021: Resource condition in provider may not behave as expected: asset_provider/providers/directory.rb:17
FC064: Ensure issues_url is set in metadata: asset_provider/metadata.rb:1
FC065: Ensure source_url is set in metadata: asset_provider/metadata.rb:1
FC066: Ensure chef_version is set in metadata: asset_provider/metadata.rb:1
FC069: Ensure standardized license defined in metadata: asset_provider/metadata.rb:1
FC070: Ensure supports metadata defines valid platforms: asset_provider/metadata.rb:1
FC085: Resource using new_resource.updated_by_last_action to converge resource: asset_provider/providers/directory.rb:53
FC085: Resource using new_resource.updated_by_last_action to converge resource: asset_provider/providers/file.rb:31
Run with Foodcritic Version 16.3.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any
No Binaries Metric
0.2.1 passed this metric
Testing File Metric
0.2.1 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file
Version Tag Metric
0.2.1 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number
0.2.1 failed this metric
FC064: Ensure issues_url is set in metadata: asset_provider/metadata.rb:1
FC065: Ensure source_url is set in metadata: asset_provider/metadata.rb:1
FC066: Ensure chef_version is set in metadata: asset_provider/metadata.rb:1
FC069: Ensure standardized license defined in metadata: asset_provider/metadata.rb:1
FC070: Ensure supports metadata defines valid platforms: asset_provider/metadata.rb:1
FC085: Resource using new_resource.updated_by_last_action to converge resource: asset_provider/providers/directory.rb:53
FC085: Resource using new_resource.updated_by_last_action to converge resource: asset_provider/providers/file.rb:31
Run with Foodcritic Version 16.3.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any
0.2.1 passed this metric
Testing File Metric
0.2.1 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file
Version Tag Metric
0.2.1 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number
0.2.1 failed this metric
0.2.1 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number