Skip to content

Commit cfa356b

Browse files
author
SHaselbauer
committed
initial version of netrc with a simple template
0 parents  commit cfa356b

File tree

8 files changed

+98
-0
lines changed

8 files changed

+98
-0
lines changed

Modulefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name 'sarah-puppet-netrc'
2+
version ''
3+
source ''
4+
author 'sarah'
5+
license ''
6+
summary ''
7+
description ''
8+
project_page ''
9+
10+
## Add dependencies, if any:
11+
# dependency 'username/name', '>= 1.2.0'

README

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
puppet-netrc
2+
3+
This is the puppet-netrc module.

manifests/init.pp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Class: puppet-netrc
2+
#
3+
# This module manages puppet-netrc
4+
#
5+
# Parameters: $user is the useraccount on the machine for which the netrc shall be configured,
6+
# $machine_user_password_triples is an array of arrays containing three string params: machine, user, password
7+
# $root_home_directory (optional) is the directory where all user homes are located on the target machine, default value is "/home"
8+
#
9+
# Actions:
10+
#
11+
# Requires:
12+
#
13+
# Sample Usage: netrc::foruser("netrc_myuser": user => 'myuser', machine_user_password_triples => [['myserver.localdomain','myuser','pw'],['mysecondserver.localdomain','myuser','pw2']])
14+
#
15+
# [Remember: No empty lines between comments and class definition]
16+
class netrc {
17+
18+
}
19+
20+
define netrc::foruser($root_home_directory="/home",$user, $machine_user_password_triples) {
21+
$filename = ".netrc"
22+
file { "$root_home_directory/$user/$filename":
23+
ensure => present,
24+
content => template('netrc/netrc.erb'),
25+
mode => '0600',
26+
owner => '$user'
27+
}
28+
}

metadata.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "sarah-puppet-netrc",
3+
"author": "sarah",
4+
"description": "",
5+
"license": "",
6+
"project_page": "",
7+
"source": "",
8+
"summary": "",
9+
"version": "",
10+
"checksums": {
11+
"Modulefile": "fa13ce98c3e9f5f61c39c8ad2039a686",
12+
"README": "c758de74c3c942f3f5aa5162190b5603",
13+
"manifests/init.pp": "7768439747250f1d0d855d7c56cf80e8",
14+
"spec/spec.opts": "a600ded995d948e393fbe2320ba8e51c",
15+
"spec/spec_helper.rb": "ca19ec4f451ebc7fdb035b52eae6e909",
16+
"templates/netrc.erb": "2fbf8e72cd28519514b015dadc804dd1",
17+
"tests/init.pp": "3fde5b9e2ed9c260fb933d7f1db2c1f1"
18+
},
19+
"dependencies": []
20+
}

spec/spec.opts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
--format
2+
s
3+
--colour
4+
--loadby
5+
mtime
6+
--backtrace

spec/spec_helper.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
require 'pathname'
2+
dir = Pathname.new(__FILE__).parent
3+
$LOAD_PATH.unshift(dir, dir + 'lib', dir + '../lib')
4+
5+
require 'mocha'
6+
require 'puppet'
7+
gem 'rspec', '=1.2.9'
8+
require 'spec/autorun'
9+
10+
Spec::Runner.configure do |config|
11+
config.mock_with :mocha
12+
end
13+
14+
# We need this because the RAL uses 'should' as a method. This
15+
# allows us the same behaviour but with a different method name.
16+
class Object
17+
alias :must :should
18+
end

templates/netrc.erb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<% $machine_user_password_triples.each do |triple| -%>
2+
<% $triple.each do |param| -%>
3+
<%= param %>
4+
<% end -%>
5+
6+
<% end -%>

tests/init.pp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
include netrc
2+
3+
netrc::foruser{"netrc_myuser":
4+
user => 'myuser',
5+
machine_user_password_triples => [['myserver.localdomain','myuser','pw'],['mysecondserver.localdomain','myuser','pw2']]
6+
}

0 commit comments

Comments
 (0)