如何将用户名/密码传递到ambari-server sync-ldap命令中

问题描述 投票:0回答:2

我正在尝试使用sync ldap命令运行剧本:

ambari-server sync-ldap --all

事情是,在执行命令之后,它要求输入用户名,然后要求输入密码。

无论如何,是否有必要从echo或使用脚本外壳自动传递用户名和密码,而无需手动传递?

shell hadoop ldap cloudera ambari
2个回答
0
投票

您是否检查过此cloudera案例

https://community.cloudera.com/t5/Community-Articles/Automate-the-Ambari-LDAP-sync/tac-p/245865

或尝试以下脚本

# cat /tmp/ambari-server-sync-ldap-unattended.sh
#!/usr/bin/expect 
set timeout 20
spawn /usr/sbin/ambari-server sync-ldap --groups=/etc/ambari-server/ambari-groups.csv
expect "Enter Ambari Admin login:" { send "admin\n" }
expect "Enter Ambari Admin password:" { send "notTheRealPasswordOfCourse\n" }
interact

0
投票

签出expect

一个简单的示例是使用以下脚本。

#!/usr/bin/expect -f
ambari-server sync-ldap --all
expect "username: " # adapt this to the prompt
send "your_username\r"
expect "password: " # adapt this to the prompt
send "yourPAssWoRD\r"

免责声明:我以前从未使用过ambari-server命令。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.