You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by oc...@apache.org on 2021/03/29 22:59:19 UTC

[trafficcontrol] branch master updated: Convert deprecated LDAP key `hostname` to `host` (#5691)

This is an automated email from the ASF dual-hosted git repository.

ocket8888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git


The following commit(s) were added to refs/heads/master by this push:
     new 2d566df  Convert deprecated LDAP key `hostname` to `host` (#5691)
2d566df is described below

commit 2d566df2af5e8f3cd4589cacb76a15e21d3af27d
Author: Zach Hoffman <zr...@apache.org>
AuthorDate: Mon Mar 29 16:59:08 2021 -0600

    Convert deprecated LDAP key `hostname` to `host` (#5691)
    
    * Convert deprecated LDAP key `hostname` to `host`
    
    * Use "host" config_var, not "hostname"
---
 .../roles/traffic_ops/templates/postinstall.input.j2     |  2 +-
 traffic_ops/install/bin/_postinstall                     |  5 +++++
 traffic_ops/install/bin/postinstall.test.sh              | 16 ++++++++--------
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/infrastructure/ansible/roles/traffic_ops/templates/postinstall.input.j2 b/infrastructure/ansible/roles/traffic_ops/templates/postinstall.input.j2
index 43624d7..10d1c1e 100644
--- a/infrastructure/ansible/roles/traffic_ops/templates/postinstall.input.j2
+++ b/infrastructure/ansible/roles/traffic_ops/templates/postinstall.input.j2
@@ -37,7 +37,7 @@
     },
     {
       "LDAP server hostname": "{{ to_ldap_hostname }}",
-      "config_var": "hostname"
+      "config_var": "host"
     },
     {
       "LDAP Admin DN": "{{ to_ldap_admin_dn }}",
diff --git a/traffic_ops/install/bin/_postinstall b/traffic_ops/install/bin/_postinstall
index ae1213b..1262209 100755
--- a/traffic_ops/install/bin/_postinstall
+++ b/traffic_ops/install/bin/_postinstall
@@ -398,6 +398,11 @@ def generate_ldap_conf(questions, fname, automatic, root): # type: (list[Questio
 		if key not in ldap_conf:
 			raise ValueError("{key} is a required key in {fname}".format(key=key, fname=fname))
 
+	keys_converted = {'password': 'admin_pass', 'hostname': 'host'}
+	for deprecated, key in keys_converted.items():
+		if deprecated in ldap_conf and ldap_conf[key] == '':
+			ldap_conf[key] = ldap_conf[deprecated]
+
 	if not re.match(r"^\S+:\d+$", ldap_conf["host"]):
 		raise ValueError("host in {fname} must be of form 'hostname:port'".format(fname=fname))
 
diff --git a/traffic_ops/install/bin/postinstall.test.sh b/traffic_ops/install/bin/postinstall.test.sh
index aa5d30a..035f96c 100755
--- a/traffic_ops/install/bin/postinstall.test.sh
+++ b/traffic_ops/install/bin/postinstall.test.sh
@@ -205,42 +205,42 @@ cat <<- EOF > "$ROOT_DIR/defaults.json"
 	],
 	"/opt/traffic_ops/app/conf/ldap.conf": [
 		{
-			"Do you want to set up LDAP?": "no",
+			"Do you want to set up LDAP?": "yes",
 			"config_var": "setupLdap",
 			"hidden": false
 		},
 		{
-			"LDAP server hostname": "",
+			"LDAP server hostname": "ldaps://ad.cdn.site:3269",
 			"config_var": "host",
 			"hidden": false
 		},
 		{
-			"LDAP Admin DN": "",
+			"LDAP Admin DN": "contact@cdn.site",
 			"config_var": "admin_dn",
 			"hidden": false
 		},
 		{
-			"LDAP Admin Password": "",
+			"LDAP Admin Password": "${TO_PASSWORD}",
 			"config_var": "admin_pass",
 			"hidden": true
 		},
 		{
-			"LDAP Search Base": "",
+			"LDAP Search Base": "dc=cdn,dc=site",
 			"config_var": "search_base",
 			"hidden": false
 		},
 		{
-			"LDAP Search Query": "",
+			"LDAP Search Query": "(&(objectCategory=person)(objectClass=user)(sAMAccountName=%s))",
 			"config_var": "search_query",
 			"hidden": false
 		},
 		{
-			"LDAP Skip TLS verify": "",
+			"LDAP Skip TLS verify": "True",
 			"config_var": "insecure",
 			"hidden": false
 		},
 		{
-			"LDAP Timeout Seconds": "",
+			"LDAP Timeout Seconds": "120",
 			"config_var": "ldap_timeout_secs",
 			"hidden": false
 		}