Skip to content

Commit

Permalink
Consolidate realm command argument logic
Browse files Browse the repository at this point in the history
  • Loading branch information
walkamongus committed Jun 30, 2017
1 parent f8f8ede commit f657f0f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
18 changes: 8 additions & 10 deletions manifests/join/keytab.pp
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,19 @@
before => Exec['realm_join_with_keytab'],
}

if $_ou != undef {
exec { 'realm_join_with_keytab':
path => '/usr/bin:/usr/sbin:/bin',
command => "realm join ${_domain} --computer-ou=${_ou}",
unless => 'kinit -k host/$(hostname -f)',
require => Exec['run_kinit_with_keytab'],
if $_ou != undef {
$_realm_args = [$_domain, "--computer-ou=${_ou}"]
} else {
$_realm_args = [$_domain,]
}
}

else {
$_args = join($_realm_args, ' ')

exec { 'realm_join_with_keytab':
path => '/usr/bin:/usr/sbin:/bin',
command => "realm join ${_domain}",
command => "realm join ${_args}",
unless => 'kinit -k host/$(hostname -f)',
require => Exec['run_kinit_with_keytab'],
}
}

}
16 changes: 7 additions & 9 deletions manifests/join/password.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,18 @@
$_password = $::realmd::domain_join_password
$_ou = $::realmd::ou

if $_ou != undef {
exec { 'realm_join_with_password':
path => '/usr/bin:/usr/sbin:/bin',
command => "echo '${_password}' | realm join ${_domain} --unattended --computer-ou=${_ou} --user=${_user}",
unless => "klist -k /etc/krb5.keytab | grep -i '${::hostname[0,15]}@${_domain}'",
if $_ou != undef {
$_realm_args = [$_domain, "--unattended", "--computer-ou=${_ou}", "--user=${_user}"]
} else {
$_realm_args = [$_domain, "--unattended", "--user=${_user}"]
}
}

else {
$_args = join($_realm_args, ' ')

exec { 'realm_join_with_password':
path => '/usr/bin:/usr/sbin:/bin',
command => "echo '${_password}' | realm join ${_domain} --unattended --user=${_user}",
command => "echo '${_password}' | realm join ${_args}",
unless => "klist -k /etc/krb5.keytab | grep -i '${::hostname[0,15]}@${_domain}'",
}
}

}

0 comments on commit f657f0f

Please sign in to comment.