diff --git a/modules/jenkins/files/jenkins-sudo.sudo b/modules/jenkins/files/jenkins-sudo.sudo new file mode 100644 index 0000000000..92f8a3435d --- /dev/null +++ b/modules/jenkins/files/jenkins-sudo.sudo @@ -0,0 +1 @@ +jenkins ALL=(root) NOPASSWD:ALL diff --git a/modules/jenkins/manifests/jenkinsuser.pp b/modules/jenkins/manifests/jenkinsuser.pp index 8c79bc44cd..6db4584a7e 100644 --- a/modules/jenkins/manifests/jenkinsuser.pp +++ b/modules/jenkins/manifests/jenkinsuser.pp @@ -3,19 +3,12 @@ class jenkins::jenkinsuser( $ssh_key = '', $ensure = present, - $sudo = false, ) { group { 'jenkins': ensure => present, } - if ($sudo == true) { - $groups = ['sudo', 'admin'] - } else { - $groups = [] - } - user { 'jenkins': ensure => present, comment => 'Jenkins User', @@ -23,7 +16,7 @@ class jenkins::jenkinsuser( gid => 'jenkins', shell => '/bin/bash', membership => 'minimum', - groups => $groups, + groups => [], require => Group['jenkins'], } diff --git a/modules/jenkins/manifests/slave.pp b/modules/jenkins/manifests/slave.pp index 8299d68a10..c75dee290f 100644 --- a/modules/jenkins/manifests/slave.pp +++ b/modules/jenkins/manifests/slave.pp @@ -15,7 +15,6 @@ class jenkins::slave( if ($user == true) { class { 'jenkins::jenkinsuser': ensure => present, - sudo => $sudo, ssh_key => $ssh_key, } } @@ -354,6 +353,16 @@ class jenkins::slave( source => 'puppet:///modules/jenkins/slave_scripts', } + if ($sudo == true) { + file { '/etc/sudoers.d/jenkins-sudo': + ensure => present, + source => 'puppet:///modules/jenkins/jenkins-sudo.sudo', + owner => 'root', + group => 'root', + mode => '0440', + } + } + file { '/etc/sudoers.d/jenkins-sudo-grep': ensure => present, source => 'puppet:///modules/jenkins/jenkins-sudo-grep.sudo',