Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Use reasonable defaults for user home in maven::settings

No need to specify the home parameter for root or normal users
  • Loading branch information...
commit b82f8cb4e16248ee501ff4d5384ce6d8097ffabf 1 parent 14e22df
Carlos Sanchez carlossg authored
6 README.md
Source Rendered
@@ -76,17 +76,17 @@ Examples
76 76 #username => "",
77 77 #password => "",
78 78 },
79   - user => "root", # if you want to run it as a different user (defaults to root), will create it if not defined
80   - home => "/root", # home directory of the user
  79 + user => "maven", # if you want to run it as a different user (defaults to root), will create it if not defined
81 80 user_system => true, # make the user a system user
82 81 maven_opts => "", # anything to add to MAVEN_OPTS in ~/.mavenrc
83 82 maven_path_additions => "", # anything to add to the PATH in ~/.mavenrc
84 83 } ->
85 84
86 85 # Create a settings.xml with the repo credentials
87   - maven::settings { 'root' :
  86 + maven::settings { 'maven-user-settings' :
88 87 mirrors => [$central], # mirrors entry in settings.xml, uses id, url, mirrorof from the hash passed
89 88 servers => [$central], # servers entry in settings.xml, uses id, username, password from the hash passed
  89 + user => 'maven',
90 90 }
91 91
92 92 # defaults for all maven{} declarations
5 manifests/environment.pp
@@ -19,7 +19,10 @@
19 19 define maven::environment( $user, $home = undef, $maven_opts = '', $maven_path_additions = '', $mavenrc_additions = '' ) {
20 20
21 21 if $home == undef {
22   - $home_real = "/home/$user"
  22 + $home_real = $user ? {
  23 + 'root' => '/root',
  24 + default => "/home/${user}"
  25 + }
23 26 }
24 27 else {
25 28 $home_real = $home
16 manifests/settings.pp
@@ -16,15 +16,25 @@
16 16 #
17 17 # A puppet recipe to set the contents of the settings.xml file
18 18 #
19   -define maven::settings( $home = '/root', $user = 'root',
  19 +define maven::settings( $home = undef, $user = 'root',
20 20 $servers = [], $mirrors = [], $default_repo_config = {}, $properties = {}, $local_repo = '' ) {
21 21
22   - file { "${home}/.m2":
  22 + if $home == undef {
  23 + $home_real = $user ? {
  24 + 'root' => '/root',
  25 + default => "/home/${user}"
  26 + }
  27 + }
  28 + else {
  29 + $home_real = $home
  30 + }
  31 +
  32 + file { "${home_real}/.m2":
23 33 ensure => directory,
24 34 owner => $user,
25 35 mode => '0700',
26 36 } ->
27   - file { "${home}/.m2/settings.xml":
  37 + file { "${home_real}/.m2/settings.xml":
28 38 owner => $user,
29 39 mode => '0600',
30 40 content => template('maven/settings.xml.erb'),

0 comments on commit b82f8cb

Please sign in to comment.
Something went wrong with that request. Please try again.