Created 03-06-2017 10:46 AM
I need to automate the process of setting up LDAP in ambari server. I do use EXPECT script for it. Here is my sample_backup.exp file:
#!/usr/bin/expect spawn ambari-server setup-ldap expect "Primary URL* {host:port} :" send "<host>:<port>\r" expect "Secondary URL {host:port} :" send " \r" expect "Use SSL* [true/false] (false):" send "false\r" expect "User object class* (posixAccount):" send "person\r" expect "User name attribute* (uid):" send "uid\r" expect "Group object class* (posixGroup):" send "groupOfUniqueNames\r" expect "Group name attribute* (cn):" send "cn\r" expect "Group member attribute* (memberUid):" send "uniqueMember\r" expect "Distinguished name attribute* (dn):" send "dn\r" expect "Base DN* :" send "<base_dn>\r" expect "Referral method [follow/ignore] :" send "ignore\r" expect "Bind anonymously* [true/false] (false):" send "false\r" expect "Manager DN* :" send "<manager_dn>\r" expect "Enter Manager Password* :" send "<manager_password>\r" expect "Re-enter password:" send "<manager_password>\r" expect "Save settings [y/n]" send "y\r" expect eof
When running the above I am getting:
[root@dkhdp251 expect_app]# expect sample_backup.exp spawn ambari-server setup-ldap Using python /usr/bin/python Setting up LDAP properties... Primary URL* {host:port} : <host>:<port> Secondary URL {host:port} : invalid command name "true/false" while executing "true/false" invoked from within "expect "Use SSL* [true/false] (false):"" (file "sample_backup.exp" line 7)
Any ideas of what wrong is?
Created 03-06-2017 11:20 AM
I have got it working now. Here it is what I have changed:
I. FROM expect "Use SSL* [true/false] (false):" TO expect "Use SSL* (false):" II. FROM expect "Referral method [follow/ignore] :" TO expect "Referral method :" III. FROM expect "Bind anonymously* [true/false] (false):" TO expect "Bind anonymously* (false):" IV. FROM expect "Save settings [y/n]" TO expect "Save settings "
Now, when running the script I have this:
[root@dkhdp251 expect_app]# expect sample_new.exp spawn ambari-server setup-ldap Using python /usr/bin/python Setting up LDAP properties... Primary URL* {host:port} : <host>:<port> Secondary URL {host:port} : Use SSL* [true/false] (false): false User object class* (posixAccount): person User name attribute* (uid): uid Group object class* (posixGroup): groupOfUniqueNames Group name attribute* (cn): cn Group member attribute* (memberUid): uniqueMember Distinguished name attribute* (dn): dn Base DN* : <base_dn> Referral method [follow/ignore] : ignore Bind anonymously* [true/false] (false): false Manager DN* : <manager_dn> Enter Manager Password* : Re-enter password: ==================== Review Settings ==================== authentication.ldap.managerDn: <manager_dn> authentication.ldap.managerPassword: ***** Save settings [y/n] (y)? y Saving...done Ambari Server 'setup-ldap' completed successfully.
Created 03-06-2017 11:20 AM
I have got it working now. Here it is what I have changed:
I. FROM expect "Use SSL* [true/false] (false):" TO expect "Use SSL* (false):" II. FROM expect "Referral method [follow/ignore] :" TO expect "Referral method :" III. FROM expect "Bind anonymously* [true/false] (false):" TO expect "Bind anonymously* (false):" IV. FROM expect "Save settings [y/n]" TO expect "Save settings "
Now, when running the script I have this:
[root@dkhdp251 expect_app]# expect sample_new.exp spawn ambari-server setup-ldap Using python /usr/bin/python Setting up LDAP properties... Primary URL* {host:port} : <host>:<port> Secondary URL {host:port} : Use SSL* [true/false] (false): false User object class* (posixAccount): person User name attribute* (uid): uid Group object class* (posixGroup): groupOfUniqueNames Group name attribute* (cn): cn Group member attribute* (memberUid): uniqueMember Distinguished name attribute* (dn): dn Base DN* : <base_dn> Referral method [follow/ignore] : ignore Bind anonymously* [true/false] (false): false Manager DN* : <manager_dn> Enter Manager Password* : Re-enter password: ==================== Review Settings ==================== authentication.ldap.managerDn: <manager_dn> authentication.ldap.managerPassword: ***** Save settings [y/n] (y)? y Saving...done Ambari Server 'setup-ldap' completed successfully.