Giter VIP home page Giter VIP logo

puppet-s3's Introduction

#puppet-s3

Build Status Puppet Forge

Table of Contents

  1. Overview
  2. Setup
  3. Usage - Configuration options and additional functionality
  4. Reference - An under-the-hood peek at what the module is doing and how
  5. Limitations - OS compatibility, etc.
  6. Development - Guide for contributing to the module

Overview

This module presents a type and provider for fetching files from amazon s3 using IAM profiles.

Setup

gem install aws-sdk => version 2

If you've already installed version and rely on it you'll have to look into the rdoc for the SDK since V2 is reverse breaking to V1.

Mainly:

Upgrading - Client Classes - Versioned client classes removed, e.g. Aws::S3::Client::V20060301.new is now Aws::S3::Client. new The :api_version constructor option is no longer accepted.

Upgrading - Aws Module - Helper methods on Aws for client classes deprecated; For example, calling Aws.s3 will generate a deprecation warning. Use Aws::S3::Client.new instead. Helpers will be removed as of v2.0.0 final.

More information can be found here

Usage

Put the classes, types, and resources for customizing, configuring, and doing the fancy stuff with your module here.

Reference

Types

Currently this module has a single type and provider 's3'. The 's3' resource is instanciated as such:

s3 { '/path/to/file/on/my/local/filesystem':
    # Required paramters:
    ensure              => present,
    source              => '/bucket/path/to/object',
    access_key_id       => 'mysecret',
    secret_access_key   => 'anothersecret',
    # Optional parameters:
    region              => 'us-west-1', # Defaults to us-east-1
}

This provider is 'psudo-idempotent' in that the exists? method, on each run, has to pull down the S3 object in order to compare it to the one of the local filesystem.

In order to do this comparison it creates a temp file in the same path as the file on the local filesystem and pulls down the S3 resource. It then compares the MD5 checksum of each resource, the local file and the S3 object. If this returns true, the filesystem is not written to; if it returns false, the new resource is written.

Currently, on each run, the S3 object is actually pulled down twice since exists? and create methods both grab the object. This isn't great for performance and I would like to update this in future versions.

Limitations

The S3 type and provider rely on aws-sdk 'version -> 2'. There is a feature which the provider is :confined to that will post-pone S3 resources until the gems for the aws-sdk are present on the local filesystem. Ensure to include s3 in your catalogue so those gems get installed.

Todo

  • Better &more testing.
  • Better checking to determine if a file must be downloaded or not

Development

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Contributors

Individual contributors can be found at: [https://github.com/malnick/puppet-s3/graphs/contributors]

puppet-s3's People

Contributors

adamcrews avatar malnick avatar thilinapiy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

puppet-s3's Issues

Could not find a suitable provider for s3 - first start vagrant virtualbox

I've the problem that if I start the vagrant virtualbox the first time I get always the output below that there is no suitable provider for s3. If I trigger the provision a second time it works.

Puppet 3.4.3
Vagrant 1.7.2

==> default: Debug: Prefetching gem resources for package
==> default: Debug: Executing '/usr/bin/gem list --local'
==> default: Debug: Executing '/usr/bin/gem list --local aws-sdk$'
==> default: Debug: Executing '/usr/bin/gem install --no-rdoc --no-ri aws-sdk'
==> default: Notice: /Stage[main]/S3/Package[aws-sdk]/ensure: created
==> default: Debug: /Stage[main]/S3/Package[aws-sdk]: The container Class[S3] will propagate my refresh event
...
==> default: Debug: Failed to load library 'aws-sdk' for feature 'awssdk'
==> default: Debug: Puppet::Type::S3::ProviderS3: feature awssdk is missing
...
==> default: Error: Could not find a suitable provider for s3

Toplevel class variable access warning

We are seeing:

....../puppet/modules/s3/lib/puppet/type/s3.rb:3: warning: class variable access from toplevel

Is this a function of our environment or a defect in the code?

Thanks!

s3.rb exists? method causes re-download of large files

Because the exists? method in lib/puppet/provider/s3/s3.rb re-downloads the entire file from S3 in order to calculate the MD5 hash, it greatly slows down re-provisioning when there are large files involved. It also doesn't guarantee that the re-downloaded file is newer, just different.

I have worked around this by simply returning true if File.exists?(resource[:path]) and false otherwise. A better option would be to query the s3 object last-modified or create date and compare to the file system.

  def exists?

      if File.exists?(resource[:path])  
          return true
      end

      return false
  end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.