Skip to content

Commit

Permalink
Merge pull request #9 from alavaliant/master
Browse files Browse the repository at this point in the history
Add support for specifying --service-name when doing an AD join
  • Loading branch information
acjohnson authored Dec 1, 2020
2 parents d896184 + b89e3e2 commit a1e69cd
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class {'::adcli':
ad_join_password => 'secret',
ad_join_ou => 'ou=container,dc=example,dc=com',
ad_join_domain_controller => 'dc01.example.com',
ad_join_service_names => ['spn1', 'spn2']
ad_join_computer_name => 'TEST-CENTOS-76',
ad_join_os => 'CentOS',
ad_join_os_version => '7',
Expand All @@ -56,6 +57,9 @@ adcli::ad_join_username: 'username'
adcli::ad_join_password: 'secret'
adcli::ad_join_ou: 'ou=container,dc=example,dc=com'
adcli::ad_join_domain_controller: 'dc01.example.com'
adcli::ad_join_service_names:
- spn1
- spn2
adcli::ad_join_computer_name: 'TEST-CENTOS-76'
adcli::ad_join_os: 'CentOS'
adcli::ad_join_os_version: '7'
Expand Down Expand Up @@ -90,6 +94,11 @@ Default: undef
Type: string
Default: undef

`$ad_join_service_names`
(optional) Specify additional kerberos service principals to be created on the account.
Type: array
Default: []

`$ad_join_computer_name`
(optional) Specify a custom computer name to use during the join operation. This equates to the
sAMAccountName property in Active Directory.
Expand Down
1 change: 1 addition & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
$ad_join_password = $adcli::params::ad_join_password,
$ad_join_ou = $adcli::params::ad_join_ou,
$ad_join_domain_controller = $adcli::params::ad_join_domain_controller,
$ad_join_service_names = $adcli::params::ad_join_service_names,
$ad_join_computer_name = $adcli::params::ad_join_computer_name,
$ad_join_os = $adcli::params::ad_join_os,
$ad_join_os_version = $adcli::params::ad_join_os_version,
Expand Down
9 changes: 8 additions & 1 deletion manifests/join.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
$ad_join_password = $adcli::ad_join_password,
$ad_join_ou = $adcli::ad_join_ou,
$ad_join_domain_controller = $adcli::ad_join_domain_controller,
$ad_join_service_names = $adcli::ad_join_service_names,
$ad_join_computer_name = $adcli::ad_join_computer_name,
$ad_join_os = $adcli::ad_join_os,
$ad_join_os_version = $adcli::ad_join_os_version,
Expand All @@ -34,6 +35,11 @@
} else {
$ad_join_domain_controller_command = ''
}
if $ad_join_service_names != [] {
$ad_join_service_names_command = join([" --service-name='", join($ad_join_service_names, "' --service-name='"), "'"], '')
} else {
$ad_join_service_names_command = ''
}
if $ad_join_computer_name != undef {
$ad_join_computer_name_command = " --computer-name='${ad_join_computer_name}'"
} else {
Expand All @@ -57,7 +63,8 @@
exec {'adcli_join':
command => "/bin/echo -n \'${ad_join_password}\' | /usr/sbin/adcli join ${ad_join_domain_controller_command} \
${ad_join_computer_name_command} --login-user=\'${ad_join_username}\' --domain=\'${ad_domain}\' --domain-ou=\'${ad_join_ou}\' \
--stdin-password --verbose ${ad_join_os_command} ${ad_join_os_version_command} ${ad_join_os_service_pack_command}",
--stdin-password --verbose ${ad_join_os_command} ${ad_join_os_version_command} ${ad_join_os_service_pack_command} \
${ad_join_service_names_command}",
logoutput => true,
creates => '/etc/krb5.keytab',
}
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
$ad_join_password = undef
$ad_join_ou = undef
$ad_join_domain_controller = undef
$ad_join_service_names = []
$ad_join_computer_name = undef
$ad_join_os = undef
$ad_join_os_version = undef
Expand Down

0 comments on commit a1e69cd

Please sign in to comment.