Skip to content

Commit

Permalink
Update staging to e9aae523a2c79ea5314a71bc6ea1afddd3168a03
Browse files Browse the repository at this point in the history
e9aae523a2c79ea5314a71bc6ea1afddd3168a03 Release 1.0.2
df5bdf4688a5a4c4747bb9ff51277184b1f9c91a Merge pull request redhat-openstack#46 from nanliu/fixture
0df9482a8f81fc393464f27f155e58ef322d7570 Update Gemfile and Rakefile
ffc158d05c30c2d8d6e8cdf88372c30620ae7191 Merge pull request redhat-openstack#43 from mhaskel/strict_variables
325558fab31105aabdd70b7e0f1e3f0bda93feef Fix for strict variables support
6452b80b62a9cc7f9dd9896a7a454276b01fd51b Merge pull request redhat-openstack#38 from nanliu/ENTERPRISE-258
e93d005809f91cfa6eb11d5f4d409ed0e458420e Release 1.0.0 for module team.
4ae247a28f6a3925d5da3143dcd0536e05be73e2 Merge pull request redhat-openstack#39 from epelletier/master
60aa376219e0e00118c863502c4575d6b336cdf2 Added S3 support.
09638af3a92482add1472aef1cb023f38ef8b030 Added S3 support.
f405a38974fc018660919557797ebd3941154a4d Fix conflict with pe_staging.
ebfb56c0c693374f8312b581f8729009dacab7be Merge pull request redhat-openstack#36 from nanliu/release
ec1ce78c1ec0c82d440cb5d1b98a065c858d3c0e Release 0.4.1 for forge.
9f331f5a93284cf254a180d2cbf1babc65fede17 Merge pull request redhat-openstack#34 from nanliu/readme
a041781023078506135e4ad0c24d22bb63bfb1d5 Update gitignore and readme example.
3dcb8934308cf710436d34694e9376a007004209 Merge pull request redhat-openstack#33 from reidmv/fix_windows_mode
d7ccedb29c61928a4f6809134a6b9c1b423e2d53 Merge pull request redhat-openstack#31 from mcanevet/fix/strict_variables
8c58bebf3ce9df9a017e8572d222217225c2051b Fix staging::extract with strict_variables
6a7c02a406212789ca01067018295c555410b110 Add missing facts in unit tests
b9be7175404f54696b4ef051069c8bfa1b2cee45 Use strict_variables when puppet version >= 3.5
1a4ce6fc6a815960f799cda37f93f5aff8eda925 Merge pull request redhat-openstack#30 from mhaskel/strip
8c0c77bf19d55b67deb459ec44296bd66cf6366e Add support for GNU tar's --strip option.
7a2667c589a7618b95b7c09674cab5c7eb7b7740 Merge pull request redhat-openstack#24 from reidmv/fix_target_path
2ece902cc7c5bc3a5eeba3fccbfd36d436ca81c1 Merge pull request redhat-openstack#27 from justinclayton/patch-2
be3b1371d9f4130a0d13b27cca4c240ea9a4d54a fix typo in error message
69c0c7cd84039c5520bc6d51800d2f7d7d7f36b7 On Windows, use well-known SIDs to set ownership
060121340f77e198795997ddb722dd25cce1408a Update spec tests to reflect absolute target
2b63b2763f4a599a2d11109e0259e817803c7bce Use $target_file in *_get variables, not $name
  • Loading branch information
xbezdick committed Dec 2, 2014
1 parent 63b86c8 commit 571c511
Show file tree
Hide file tree
Showing 18 changed files with 285 additions and 140 deletions.
2 changes: 1 addition & 1 deletion Puppetfile
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ mod 'ssh',
:git => 'https://github.com/saz/puppet-ssh.git'

mod 'staging',
:commit => '887275d8fb20e148c6f9eb327f1f6c8ea5ee280f',
:commit => 'e9aae523a2c79ea5314a71bc6ea1afddd3168a03',
:git => 'https://github.com/nanliu/puppet-staging.git'

mod 'stdlib',
Expand Down
2 changes: 1 addition & 1 deletion staging/.fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fixtures:
repositories:
stdlib: 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
stdlib: 'http://github.com/puppetlabs/puppetlabs-stdlib.git'
symlinks:
staging: "#{source_dir}"
2 changes: 2 additions & 0 deletions staging/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.bundle
.pkg
.ruby-version
.vagrant
Gemfile.lock
spec/fixtures
22 changes: 8 additions & 14 deletions staging/.travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
language: ruby
script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'"
before_install:
- gem update bundler
- bundle --version
- gem update --system 2.1.11
- gem --version
rvm:
- 1.8.7
- 1.9.3
env:
- PUPPET_GEM_VERSION="~> 3.2.0"
- PUPPET_GEM_VERSION=">= 3.0.0"
branches:
only:
- master
matrix:
exclude:
- rvm: 1.8.7
env: PUPPET_GEM_VERSION=">= 3.0.0"
fast_finish: true
include:
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 3.3.0" FACTER_GEM_VERSION="~> 1.7.0"
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.0"
notifications:
email: false
20 changes: 1 addition & 19 deletions staging/Gemfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
source "https://rubygems.org"

group :development, :test do
gem 'rake'
gem 'bodeco_module_helper', :git => 'https://github.com/bodeco/bodeco_module_helper.git'
gem 'rspec', "~> 2.11.0", :require => false
gem 'mocha', "~> 0.10.5", :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'rspec-puppet', :require => false
gem 'puppet-lint'
end

facterversion = ENV['GEM_FACTER_VERSION']
if facterversion
gem 'facter', facterversion
else
gem 'facter', :require => false
end

ENV['GEM_PUPPET_VERSION'] ||= ENV['PUPPET_GEM_VERSION']
puppetversion = ENV['GEM_PUPPET_VERSION']
if puppetversion
gem 'puppet', puppetversion
else
gem 'puppet', :require => false
end
2 changes: 1 addition & 1 deletion staging/Modulefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name 'nanliu-staging'
version '0.4.0'
version '1.0.2'
source '[email protected]:nanliu/puppet-staging.git'
author 'nanliu'
license 'Apache License Version 2.0'
Expand Down
61 changes: 37 additions & 24 deletions staging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,57 @@ Manages staging directory, along with download/extraction of compressed files.

WARNING: Version 0.2.0 no longer uses hiera functions. The same behavior should be available in Puppet 3.0.

NOTE: Version 1.0.0 will be the last feature release. New functionality such as checksum will be implemented in a type/provider module [puppet-archive](https://www.github.com/nanliu/puppet-archive).

## Usage

Specify a different default staging path (must be declared before using resource):

class { 'staging':
path => '/var/staging',
owner => 'puppet',
group => 'puppet',
}
```puppet
class { 'staging':
path => '/var/staging',
owner => 'puppet',
group => 'puppet',
}
```

Staging files from various sources:
```puppet
staging::file { 'sample':
source => 'puppet://modules/staging/sample',
}
staging::file { 'sample':
source => 'puppet://modules/staging/sample',
}

staging::file { 'apache-tomcat-6.0.35':
source => 'http://apache.cs.utah.edu/tomcat/tomcat-6/v6.0.35/bin/apache-tomcat-6.0.35.tar.gz',
}

staging::file { 'apache-tomcat-6.0.35':
source => 'http://apache.cs.utah.edu/tomcat/tomcat-6/v6.0.35/bin/apache-tomcat-6.0.35.tar.gz',
}
```

Staging and extracting files:

staging::file { 'sample.tar.gz':
source => 'puppet:///modules/staging/sample.tar.gz'
}

staging::extract { 'sample.tar.gz':
target => '/tmp/staging',
creates => '/tmp/staging/sample',
require => Staging::File['sample.tar.gz'],
}
```puppet
staging::file { 'sample.tar.gz':
source => 'puppet:///modules/staging/sample.tar.gz'
}
staging::extract { 'sample.tar.gz':
target => '/tmp/staging',
creates => '/tmp/staging/sample',
require => Staging::File['sample.tar.gz'],
}
```

Deploying a file (combining staging and extract):
```puppet
staging::deploy { 'sample.tar.gz':
source => 'puppet:///modules/staging/sample.tar.gz',
target => '/usr/local',
}
```

Staging files currently support the following source:

* http(s)://
* puppet://
* ftp://
* s3:// (requires aws cli to be installed and configured.)
* local (though this doesn't serve any real purpose.)

## Contributor
Expand Down
52 changes: 1 addition & 51 deletions staging/Rakefile
Original file line number Diff line number Diff line change
@@ -1,51 +1 @@
require 'rubygems'
require 'puppetlabs_spec_helper/rake_tasks'

def io_popen(command)
IO.popen(command) do |io|
io.each do |line|
print line
yield line if block_given?
end
end
end

# Customize lint option
task :lint do
PuppetLint.configuration.send("disable_80chars")
PuppetLint.configuration.send("disable_class_parameter_defaults")
end

desc "Validate manifests, templates, and ruby files in lib."
task :validate do
Dir['manifests/**/*.pp'].each do |manifest|
sh "puppet parser validate --noop #{manifest}"
end
Dir['lib/**/*.rb'].each do |lib_file|
sh "ruby -c #{lib_file}"
end
Dir['templates/**/*.erb'].each do |template|
sh "erb -P -x -T '-' #{template} | ruby -c"
end
end

# Initialize vagrant instance for testing
desc "Powers on Vagrant VMs with specific manifests"
task :vagrant, :manifest do |t, args|
Rake::Task["spec_prep"].execute

prefix = "VAGRANT_MANIFEST='#{args[:manifest]||'init.pp'}'"

puts args[:manifest]
provision = false
io_popen("export #{prefix}; vagrant up --provider=vmware_fusion") do |line|
provision = true if line =~ /Machine is already running./
end
io_popen("export #{prefix}; vagrant provision") if provision
end

# Cleanup vagrant environment
task :vagrant_clean do
`vagrant destroy -f`
Rake::Task["spec_clean"].execute
end
require 'bodeco_module_helper/rake_tasks'
20 changes: 17 additions & 3 deletions staging/manifests/extract.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
$user = undef, #: extract file as this user.
$group = undef, #: extract file as this group.
$environment = undef, #: environment variables.
$strip = undef, #: extract file with the --strip=X option. Only works with GNU tar.
$subdir = $caller_module_name #: subdir per module in staging directory.
) {

Expand All @@ -32,6 +33,8 @@
$folder = staging_parse($name, 'basename')
}
$creates_path = "${target}/${folder}"
} else {
$creates_path = undef
}

if scope_defaults('Exec','path') {
Expand Down Expand Up @@ -59,21 +62,32 @@
}
}

if $strip {
if $::osfamily == 'Solaris' or $name !~ /(.tar|.tgz|.tar.gz|.tar.bz2)$/ {
warning('strip is only supported with GNU tar, ignoring the parameter')
$strip_opt = ''
} else {
$strip_opt = " --strip=${strip}"
}
} else {
$strip_opt = ''
}

case $name {
/.tar$/: {
$command = "tar xf ${source_path}"
$command = "tar xf ${source_path}${strip_opt}"
}

/(.tgz|.tar.gz)$/: {
if $::osfamily == 'Solaris' {
$command = "gunzip -dc < ${source_path} | tar xf - "
} else {
$command = "tar xzf ${source_path}"
$command = "tar xzf ${source_path}${strip_opt}"
}
}

/.tar.bz2$/: {
$command = "tar xjf ${source_path}"
$command = "tar xjf ${source_path}${strip_opt}"
}

/.zip$/: {
Expand Down
26 changes: 16 additions & 10 deletions staging/manifests/file.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# resource as necessary.
#
define staging::file (
$source, #: the source file location, supports local files, puppet://, http://, https://, ftp://
$source, #: the source file location, supports local files, puppet://, http://, https://, ftp://, s3://
$target = undef, #: the target staging directory, if unspecified ${staging::path}/${caller_module_name}
$username = undef, #: https or ftp username
$certificate = undef, #: https certificate file
Expand Down Expand Up @@ -51,16 +51,16 @@

case $::staging_http_get {
'curl', default: {
$http_get = "curl ${curl_option} -f -L -o ${name} ${quoted_source}"
$http_get_passwd = "curl ${curl_option} -f -L -o ${name} -u ${username}:${password} ${quoted_source}"
$http_get_cert = "curl ${curl_option} -f -L -o ${name} -E ${certificate}:${password} ${quoted_source}"
$ftp_get = "curl ${curl_option} -o ${name} ${quoted_source}"
$ftp_get_passwd = "curl ${curl_option} -o ${name} -u ${username}:${password} ${quoted_source}"
$http_get = "curl ${curl_option} -f -L -o ${target_file} ${quoted_source}"
$http_get_passwd = "curl ${curl_option} -f -L -o ${target_file} -u ${username}:${password} ${quoted_source}"
$http_get_cert = "curl ${curl_option} -f -L -o ${target_file} -E ${certificate}:${password} ${quoted_source}"
$ftp_get = "curl ${curl_option} -o ${target_file} ${quoted_source}"
$ftp_get_passwd = "curl ${curl_option} -o ${target_file} -u ${username}:${password} ${quoted_source}"
}
'wget': {
$http_get = "wget ${wget_option} -O ${name} ${quoted_source}"
$http_get_passwd = "wget ${wget_option} -O ${name} --user=${username} --password=${password} ${quoted_source}"
$http_get_cert = "wget ${wget_option} -O ${name} --user=${username} --certificate=${certificate} ${quoted_source}"
$http_get = "wget ${wget_option} -O ${target_file} ${quoted_source}"
$http_get_passwd = "wget ${wget_option} -O ${target_file} --user=${username} --password=${password} ${quoted_source}"
$http_get_cert = "wget ${wget_option} -O ${target_file} --user=${username} --certificate=${certificate} ${quoted_source}"
$ftp_get = $http_get
$ftp_get_passwd = $http_get_passwd
}
Expand Down Expand Up @@ -107,8 +107,14 @@
command => $command,
}
}
/^s3:\/\//: {
$command = "aws s3 cp ${source} ${target_file}"
exec { $target_file:
command => $command,
}
}
default: {
fail("stage::file: do not recognize source ${source}.")
fail("staging::file: do not recognize source ${source}.")
}
}

Expand Down
13 changes: 8 additions & 5 deletions staging/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
$exec_path = $staging::params::exec_path #: executable default path
) inherits staging::params {

file { $path:
ensure => directory,
owner => $owner,
group => $group,
mode => $mode,
# Resolve conflict with pe_staging
if !defined(File[$path]) {
file { $path:
ensure => directory,
owner => $owner,
group => $group,
mode => $mode,
}
}

}
6 changes: 3 additions & 3 deletions staging/manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
}
'windows': {
$path = $::staging_windir
$owner = undef
$group = undef
$mode = '0755'
$owner = 'S-1-5-32-544' # Adminstrators
$group = 'S-1-5-18' # SYSTEM
$mode = '0660'
$exec_path = $::path
}
}
Expand Down
Loading

0 comments on commit 571c511

Please sign in to comment.