-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SVCPLAN-6686: Add support for AD createhost functionality
- Loading branch information
Showing
5 changed files
with
143 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,28 +41,15 @@ NCSA allows `createhost` principals for projects. This allows for two automated | |
|
||
In order to support this, you need to request a `createhost` principal keytab for your project, then assign the base64 encoding of the keytab file to `profile_system_auth::kerberos::createhostkeytab` and the first part of the principal's username to `profile_system_auth::kerberos::createhostuser` parameters. NCSA staff can request a `createhost` principal by emailing [email protected]. They will provide you a principal username and either the keytab file for that user or a BASE64 encoding of that keytab. | ||
|
||
## Reference | ||
The same sort of approach can be done if using Active Directory (AD) to create a computer object for your host and save its keytab locally. This can be configured by specifying the following paraters: | ||
|
||
``` | ||
profile_system_auth::kerberos::ad_computers_ou # AD OU FOR COMPUTER OBJECTS | ||
profile_system_auth::kerberos::ad_createhostkeytab # BASE64 ENCODING OF KRB5 CREATEHOST KEYTAB FILE | ||
profile_system_auth::kerberos::ad_createhostuser # AD CREATEHOST USER | ||
profile_system_auth::kerberos::ad_domain # AD DOMAIN | ||
``` | ||
|
||
### class profile_system_auth::config ( | ||
- String $authselect_profile, | ||
- Boolean $enable_mkhomedir, | ||
- String $oddjobd_mkhomedir_conf, | ||
- $removed_pkgs, | ||
- Array[ String[1] ] $required_pkgs, | ||
- Boolean $use_authconfig, | ||
### class profile_system_auth::kerberos ( | ||
- Hash $cfg_file_settings, # cfg files and their contents | ||
- Optional[ String ] $createhostkeytab, # BASE64 ENCODING OF KRB5 CREATEHOST KEYTAB FILE | ||
- Optional[ String ] $createhostuser, # CREATEHOST USER | ||
- Hash $crons, | ||
- Hash $files_remove_setuid, | ||
- Array[ String[1] ] $required_pkgs, # DEFAULT SET VIA MODULE DATA | ||
- Optional[ Array[ String[1] ] ] $root_k5login_principals, # PRINCIPALS WITH ROOT PRIVILEGES | ||
### class profile_system_auth::ldap ( | ||
- String $ldap_conf, # ldap.conf file contents | ||
- Array[ String[1] ] $required_pkgs, # DEFAULT SET VIA MODULE DATA | ||
### class profile_system_auth::su ( | ||
- Boolean $disable_su, | ||
- String $su_path, | ||
## Reference | ||
|
||
[REFERENCE.md](REFERENCE.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
|
||
# Enable debugging mode | ||
set -x | ||
|
||
# ASSIGN VARIABLES | ||
AD_DOMAIN="<%= @ad_domain %>" # Active Directory domain | ||
AD_OU_COMPUTERS="<%= @ad_computers_ou %>" # Organizational Unit for computers in AD | ||
AD_USER="<%= @ad_createhostuser %>" # User with permissions to create host in AD | ||
HOST_FQDN="<%= @fqdn %>" # Fully Qualified Domain Name of the host | ||
KEYTAB_BASE64="<%= @ad_createhostkeytab %>" # Base64 encoded keytab for creating host | ||
KEYTAB_FILE="/root/createhost.keytab" # Path to store the decoded keytab file | ||
OS_NAME="<%= @os['name'] %>" # Operating System name | ||
|
||
# Decode the base64 encoded keytab and save it to a file | ||
echo "${KEYTAB_BASE64}" | base64 --decode > $KEYTAB_FILE | ||
|
||
# Authenticate using the keytab file | ||
kinit -k -t $KEYTAB_FILE $AD_USER | ||
|
||
# Pre-create the computer account in the specified OU | ||
adcli preset-computer --domain="${AD_DOMAIN}" --domain-ou="${AD_OU_COMPUTERS}" -U "${AD_USER}" --login-ccache --os-name="${OS_NAME}" $HOST_FQDN | ||
|
||
# Join the computer to the AD domain | ||
adcli join --domain="${AD_DOMAIN}" -U "${AD_USER}" --login-ccache | ||
|
||
# Destroy the Kerberos ticket cache for the user | ||
kdestroy -p $AD_USER | ||
|
||
# Optionally, list the contents of the keytab file (uncomment for debugging) | ||
# klist -kte | ||
|
||
# Remove the keytab file for security reasons | ||
rm -f $KEYTAB_FILE |