Skip to content

Commit

Permalink
first working version
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhem committed Oct 4, 2012
0 parents commit 99e151c
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 0 deletions.
62 changes: 62 additions & 0 deletions README.md
@@ -0,0 +1,62 @@
Description
===========

Manage an htpasswd file.
If htpasswd exe isn't found, we install a python implementation.

Requirements
============

Work on Windows

Resource/Provider
=================

This cookbook includes LWRPs for managing:
* chocolatey

htpasswd
--------

# Actions

- :install: Install a chocolatey package (default)
- :upgrade: Update a chocolatey package
- :remove: Uninstall a chocolatey package

# Attribute Parameters

- package_name: string or package to manage
- package: package to manage (default package_name)
- version
- source
- args: arguments to the installation


# Example

chocolatey "sysinternals"

chocolatey "7zip"

chocolatey "notepadplusplus"

chocolatey "GoogleChrome"

chocolatey "Console2"

chocolatey "bash" do
source "cygwin"
end

chocolatey "openssh" do
source "cygwin"
end

chocolatey "grep" do
source "cygwin"
end

chocolatey "DotNet4.5"

chocolatey "PowerShell"
Empty file added attributes/default.rb
Empty file.
9 changes: 9 additions & 0 deletions metadata.rb
@@ -0,0 +1,9 @@
maintainer "Guilhem Lettron"
maintainer_email "guilhem.lettron@youscribe.com"
license "Apache 2.0"
description "Install chocolatey and packages on Windows"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.0.1"

depends "powershell"
supports "windows"
56 changes: 56 additions & 0 deletions providers/default.rb
@@ -0,0 +1,56 @@
#
# Cookbook Name:: htpasswd
# Provider:: htpasswd
# Author:: Guilhem Lettron <guilhem.lettron@youscribe.com>
#
# Copyright 20012, Societe Publica.
#
# 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.
#

def initialize(*args)
super
@action = :install
end

def cmd_build
output = ""
if new_resource.version
output << " -version #{new_resource.version}"
end
if new_resource.source
output << " -source #{new_resource.source}"
end
if new_resource.args
output << " -installArgs #{new_resource.args}"
end
return output
end

action :install do
execute "install package" do
command "cinst " + new_resource.package + cmd_build
end
end

action :upgrade do
execute "update package" do
command "chocolatey update " + new_resource.package + cmd_build
end
end

action :remove do
execute "uninstall package" do
command "chocolatey uninstall " + new_resource.package + cmd_build
end
end
23 changes: 23 additions & 0 deletions recipes/default.rb
@@ -0,0 +1,23 @@
#
# Cookbook Name:: chocolatey
# recipe:: default
# Author:: Guilhem Lettron <guilhem.lettron@youscribe.com>
#
# Copyright 2012, Societe Publica.
#
# 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.
#

powershell "install chocolatey" do
code 'iex ((new-object net.webclient).DownloadString("http://bit.ly/psChocInstall"))'
end
11 changes: 11 additions & 0 deletions resources/default.rb
@@ -0,0 +1,11 @@
actions :install, :remove, :upgrade

attribute :package, :kind_of => String, :name_attribute => true
attribute :source, :kind_of => String
attribute :version, :kind_of => String
attribute :args, :kind_of => String

def initialize(*args)
super
@action = :install
end

0 comments on commit 99e151c

Please sign in to comment.