Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ sudo: false
matrix:
fast_finish: true
include:
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="3.4.3"
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 2.1.5
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Change Log for Puppet Module locp-gitssh

##2016-09-21 - Release 0.1.2 ([diff](https://github.com/locp/gitssh/compare/0.1.1...0.1.2))

* Fixed a fatal error when running a Puppet version < 3.6.0.
* Improved unit and acceptance testing.
* Improved the documentation.

##2016-09-18 - Release 0.1.1 ([diff](https://github.com/locp/gitssh/compare/0.1.0...0.1.1))

* Ensure the service runs on Red Hat and Debian families.
* Improved the project metadata.

##2016-09-11 - Release 0.1.0

An initial release.
9 changes: 5 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,21 @@ group :system_tests do
gem 'beaker-rspec', require: false
gem 'coveralls', require: false
gem 'docker-api', require: false
gem 'google-api-client', '<= 0.9.4'
gem 'json_pure', '<= 2.0.1'
gem 'metadata-json-lint', require: false
gem 'pry', require: false
gem 'puppet-blacksmith', require: false
gem 'puppet-lint', require: false
gem 'puppetlabs_spec_helper', require: false
gem 'rspec_junit_formatter', require: false
gem 'rspec_junit_formatter', '0.2.2'
gem 'rspec-puppet', '<= 2.3.2'
gem 'rspec-puppet-utils', require: false
gem 'rubocop', '<= 0.41.2'
gem 'serverspec', require: false
gem 'specinfra', '<= 2.59.0'
gem 'spdx-licenses', '<= 1.0.0'
gem 'tins', '<= 1.6.0'
end

group :development do
Expand All @@ -38,7 +42,4 @@ end
if RUBY_VERSION >= '1.8.7' && RUBY_VERSION < '1.9'
gem 'rspec', '~> 2.0'
gem 'rake', '~> 10.0'
else
# rubocop requires ruby >= 1.9
gem 'rubocop'
end
62 changes: 56 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,30 +110,80 @@ gitssh::repos:

## Reference

### Class gitssh
* [Defined type gitssh::client](#defined-type-gitsshclient)
* [Class gitssh](#class-gitssh)
* [Defined type gitssh::repo](#defined-type-gitsshrepo)

#### Parameters
### Parameters

#### Defined type gitssh::client

##### `ensure`
If the SSH key is to be present in the git account. Valid values are
*present* and *absent*.
Default value: **present**

##### `type`
The type of SSH key. See
[here](https://docs.puppet.com/puppet/latest/reference/types/ssh_authorized_key.html#ssh_authorized_key-attribute-type)
for a list of valid values.
Default value: 'ssh-rsa'

##### `key`
This value can be left as *undef* (the default) if `ensure` is set to
*absent*. Otherwise it should be the SSH key.
Default value: *undef*

#### Class gitssh

##### `basedir`
This is set as the home directory for the git user.
Default value: '/var/git'

##### `clients`
An array of hashes that can be passed to the gitssh::client definition.
An array of hashes that can be passed to the `gitssh::client` definition.
Default value: []

##### `package_ensure`
Passed as the **ensure** parameter package for the **git** package. Valid
Passed as the **ensure** attribute to the package resource. Valid
values are **present** or a specific version number.
Default value: present
Default value: **present**

##### `package_name`
Passed as the **name** attribute for the package resource for the git
package.
Default value: 'git'

##### `purge_ssh_keys`
Passed as an attribute for the user resource for git. This will remove all
SSH keys from the git user that are not controlled by Puppet. This
attribute has no effect on version of Puppet < 3.6.0 and will generate a
warning unless set to **false**.
Default value: **true**

##### `repos`
An array of hashes that can be passed to the `gitssh::repo` definition.
Default value: []

#### Defined type gitssh::repo

##### `ensure`
If the repository is to be *present* or *absent*.
Default value: **present**

## Limitations

Currently only developed and tested on CentOS and Debian 7.
Currently only developed and tested on CentOS 7, Ubuntu 14.04 and Debian 7.

## Development

Contributions will be gratefully accepted. Please go to the project page,
fork the project, make your changes locally and then raise a pull request.
Details on how to do this are available at
https://guides.github.com/activities/contributing-to-open-source.

### Contributers

| Release | Issue/PR | Contributer |
| :------------- | :-------------------------------------------------------------------------------------------------------------------------- | :------------------------------------|
| 0.1.2 | [The module does not work on Puppet 3.4.3The module does not work on Puppet 3.4.3](https://github.com/locp/gitssh/issues/3) | [@nl0pvm](https://github.com/nl0pvm) |
2 changes: 2 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ machine:
environment:
PUPPET_GEM_VERSION: '~> 4.0'
STRICT_VARIABLES: yes
BEAKER_destroy: no
ruby:
version: 2.1.6
services:
Expand All @@ -27,3 +28,4 @@ test:
- bundle exec rake lint
- bundle exec rake validate
- bundle exec rake spec SPEC_OPTS="--format RspecJunitFormatter -o $CIRCLE_TEST_REPORTS/rspec/puppet.xml"
- bundle exec rake beaker
20 changes: 14 additions & 6 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@
before => User['git']
}

if versioncmp($::puppetversion,'3.6.0') >= 0 {
User {
purge_ssh_keys => $purge_ssh_keys,
}
} elsif $purge_ssh_keys {
warning('gitssh::purge_ssh_keys is ignored in Puppet < 3.6.0.')
warning('To disable this warning, set gitssh::purge_ssh_keys to false.')
}

user { 'git':
ensure => present,
home => $basedir,
shell => '/usr/bin/git-shell',
managehome => true,
purge_ssh_keys => $purge_ssh_keys,
require => Package[$package_name],
ensure => present,
home => $basedir,
shell => '/usr/bin/git-shell',
managehome => true,
require => Package[$package_name],
}

if size($clients) > 0 {
Expand Down
6 changes: 6 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
"7"
]
},
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"7"
]
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
Expand Down
3 changes: 3 additions & 0 deletions spec/acceptance/gitssh_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
describe 'Git SSH installation.' do
it 'should work with no errors' do
apply_manifest(pre_req_install_pp, catch_failures: true)
end

it 'check code is idempotent' do
expect(apply_manifest(pre_req_install_pp,
catch_failures: true).exit_code).to be_zero
end
Expand Down
29 changes: 15 additions & 14 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,25 @@
end
end

context 'with defaults for all parameters' do
it do
should contain_class('gitssh').with('basedir' => '/var/git',
'package_ensure' => 'present',
'package_name' => 'git',
'purge_ssh_keys' => 'true')
end

it do
should contain_package('git').with('ensure' => 'present')
end
puppetversion = Gem.loaded_specs['puppet'].version

it do
should contain_user('git').with('home' => '/var/git',
'purge_ssh_keys' => true)
context "With defaults for all parameters (puppet-#{puppetversion})" do
let :facts do
{
puppetversion: puppetversion.to_s
}
end

it do
should contain_class('gitssh')
.with(
basedir: '/var/git',
package_ensure: 'present',
package_name: 'git',
purge_ssh_keys: 'true'
)
should contain_package('git').with('ensure' => 'present')
should contain_user('git').with('home' => '/var/git')
should contain_exec('/bin/echo /usr/bin/git-shell >> /etc/shells')
end
end
Expand Down
14 changes: 14 additions & 0 deletions spec/defines/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,27 @@
context 'Manage authorised SSH key' do
let(:title) { 'nick@magpie.puppetlabs.lan' }

puppetversion = Gem.loaded_specs['puppet'].version

let :facts do
{
puppetversion: puppetversion.to_s
}
end

let :params do
{
key: 'AAAAB...aQ=='
}
end

it do
should contain_gitssh__client('nick@magpie.puppetlabs.lan').with(
ensure: 'present',
type: 'ssh-rsa',
key: 'AAAAB...aQ=='
)

should contain_ssh_authorized_key(
'gitssh::client::nick@magpie.puppetlabs.lan'
).with('user' => 'git',
Expand Down
14 changes: 11 additions & 3 deletions spec/defines/repo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@
end
end

puppetversion = Gem.loaded_specs['puppet'].version

context 'Add a repo (Red Hat)' do
let(:title) { 'foobar' }

let :facts do
{
osfamily: 'RedHat'
osfamily: 'RedHat',
puppetversion: puppetversion.to_s
}
end

it do
should contain_gitssh__repo('foobar').with(
ensure: 'present'
)

should contain_exec('/usr/bin/mkdir /var/git/foobar.git')
.with('user' => 'git')

Expand All @@ -27,12 +34,13 @@
end
end

context 'Add a repo (Red Hat)' do
context 'Add a repo (Debian)' do
let(:title) { 'foobar' }

let :facts do
{
osfamily: 'Debian'
osfamily: 'Debian',
puppetversion: puppetversion.to_s
}
end

Expand Down