Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom computer names #10

Merged
merged 3 commits into from
Mar 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 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_computer_name => 'TEST-CENTOS-76',
ad_join_os => 'CentOS',
ad_join_os_version => '7',
ad_join_os_service_pack => '6'
Expand All @@ -55,6 +56,7 @@ 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_computer_name: 'TEST-CENTOS-76'
adcli::ad_join_os: 'CentOS'
adcli::ad_join_os_version: '7'
adcli::ad_join_os_service_pack: '6'
Expand Down Expand Up @@ -88,6 +90,12 @@ Default: undef
Type: string
Default: undef

`$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.
Type: string
Default: undef

`$ad_join_os`
(optional) Populates the Active Directory value for Operating System Name.
Type: string
Expand Down
2 changes: 2 additions & 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_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,
$ad_join_os_service_pack = $adcli::params::ad_join_os_service_pack,
Expand All @@ -56,6 +57,7 @@
validate_legacy(String, 'validate_string', $ad_join_password)
validate_legacy(String, 'validate_string', $ad_join_ou)
validate_legacy(String, 'validate_string', $ad_join_domain_controller)
validate_legacy(String, 'validate_string', $ad_join_computer_name)
validate_legacy(String, 'validate_string', $ad_join_os)
validate_legacy(String, 'validate_string', $ad_join_os_version)
validate_legacy(String, 'validate_string', $ad_join_os_service_pack)
Expand Down
12 changes: 9 additions & 3 deletions 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_computer_name = $adcli::ad_join_computer_name,
$ad_join_os = $adcli::ad_join_os,
$ad_join_os_version = $adcli::ad_join_os_version,
$ad_join_os_service_pack = $adcli::ad_join_os_service_pack
Expand All @@ -33,6 +34,11 @@
} else {
$ad_join_domain_controller_command = ''
}
if $ad_join_computer_name != undef {
$ad_join_computer_name_command = " --computer-name='${ad_join_computer_name}'"
} else {
$ad_join_computer_name_command = ''
}
if $ad_join_os != undef {
$ad_join_os_command = " --os-name=\'${ad_join_os}\'"
} else {
Expand All @@ -49,9 +55,9 @@
$ad_join_os_service_pack_command = ''
}
exec {'adcli_join':
command => "/bin/echo -n \'${ad_join_password}\' | /usr/sbin/adcli join ${ad_join_domain_controller_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}",
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}",
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_computer_name = undef
$ad_join_os = undef
$ad_join_os_version = undef
$ad_join_os_service_pack = undef
Expand Down
2 changes: 2 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
ad_join_password: 'secret',
ad_join_domain_controller: 'dc01.example.com',
ad_join_ou: 'cn=computers,dn=ad,dn=example,dn=com',
ad_join_computer_name: 'TEST-RHEL-67',
ad_join_os: 'RedHat',
ad_join_os_version: '6',
ad_join_os_service_pack: '7',
Expand Down Expand Up @@ -47,6 +48,7 @@
ad_join_password: 'secret',
ad_join_domain_controller: 'dc01.example.com',
ad_join_ou: 'cn=computers,dn=ad,dn=example,dn=com',
ad_join_computer_name: 'TEST-RHEL-72',
ad_join_os: 'RedHat',
ad_join_os_version: '7',
ad_join_os_service_pack: '2',
Expand Down