knife vsphere 请求 root 密码 - 是否可以无人值守执行?
knife vsphere requests root password - is unattended execution possible?
有没有什么办法可以让knife vsphere无人值守执行?我有一个部署 shell 脚本,我正在使用它来帮助我:
cat deploy-production-20-vm.sh
#!/bin/bash
##############################################
# These are machine dependent variables (need to change)
##############################################
HOST_NAME=
IP_ADDRESS="/24"
CHEF_BOOTSTRAP_IP_ADDRESS=""
RUNLIST=\"\"
CHEF_HOST= $HOSTNAME.my.lan
##############################################
# These are psuedo-environment independent variables (could change)
##############################################
DATASTORE="dcesxds04"
##############################################
# These are environment dependent variables (should not change per env)
##############################################
TEMPLATE="\"CentOS\""
NETWORK="\"VM Network\""
CLUSTER="ProdCluster01" #knife-vsphere calls this a resource pool
GATEWAY="10.7.20.1"
DNS="\"10.7.20.11,10.8.20.11,10.6.20.11\""
##############################################
# the magic
##############################################
VM_CLONE_CMD="knife vsphere vm clone $HOST_NAME \
--template $TEMPLATE \
--cips $IP_ADDRESS \
--vsdc MarkleyDC\
--datastore $DATASTORE \
--cvlan $NETWORK\
--resource-pool $CLUSTER \
--cgw $GATEWAY \
--cdnsips $DNS \
--start true \
--bootstrap true \
--fqdn $CHEF_BOOTSTRAP_IP_ADDRESS \
--chost $HOST_NAME\
--cdomain my.lan \
--run-list=$RUNLIST"
echo $VM_CLONE_CMD
eval $VM_CLONE_CMD
回显(单行):
knife vsphere vm clone dcbsmtest --template "CentOS" --cips 10.7.20.84/24
--vsdc MarkleyDC --datastore dcesxds04 --cvlan "VM Network"
--resource-pool ProdCluster01 --cgw 10.7.20.1
--cdnsips "10.7.20.11,10.8.20.11,10.6.20.11" --start true
--bootstrap true --fqdn 10.7.20.84 --chost dcbsmtest --cdomain my.lan
--run-list="role[my-env-prod-server]"
运行时输出:
Cloning template CentOS Template to new VM dcbsmtest
Finished creating virtual machine dcbsmtest
Powered on virtual machine dcbsmtest
Waiting for sshd...done
Doing old-style registration with the validation key at /home/me/chef-repo/.chef/our-validator.pem...
Delete your validation key in order to use your user credentials instead
Connecting to 10.7.20.84
root@10.7.20.84's password:
如果我离开我的办公桌,它会提示输入 PWD - 然后有时它会超时,连接会丢失,而厨师不会 bootstrap。此外,我希望能够根据系统需求将所有这些自动化,使其具有弹性——这不适用于有人值守的执行。
我要运行的想法,除非提供更好的解决方案是在模板中有一个默认密码,并在命令行上将其传递给 knife,然后让厨师更改密码构建完成,最大限度地减少 bash 脚本控制刀中硬编码密码的暴露...
更新:我想补充一点,这非常有效。理想情况下,我们可以更改我们正在部署的 centOs 模板 - 但在这里不可能 - 所以这是一个很好的选择(因为我们在部署后更改了 root 密码)。
有没有什么办法可以让knife vsphere无人值守执行?我有一个部署 shell 脚本,我正在使用它来帮助我:
cat deploy-production-20-vm.sh
#!/bin/bash
##############################################
# These are machine dependent variables (need to change)
##############################################
HOST_NAME=
IP_ADDRESS="/24"
CHEF_BOOTSTRAP_IP_ADDRESS=""
RUNLIST=\"\"
CHEF_HOST= $HOSTNAME.my.lan
##############################################
# These are psuedo-environment independent variables (could change)
##############################################
DATASTORE="dcesxds04"
##############################################
# These are environment dependent variables (should not change per env)
##############################################
TEMPLATE="\"CentOS\""
NETWORK="\"VM Network\""
CLUSTER="ProdCluster01" #knife-vsphere calls this a resource pool
GATEWAY="10.7.20.1"
DNS="\"10.7.20.11,10.8.20.11,10.6.20.11\""
##############################################
# the magic
##############################################
VM_CLONE_CMD="knife vsphere vm clone $HOST_NAME \
--template $TEMPLATE \
--cips $IP_ADDRESS \
--vsdc MarkleyDC\
--datastore $DATASTORE \
--cvlan $NETWORK\
--resource-pool $CLUSTER \
--cgw $GATEWAY \
--cdnsips $DNS \
--start true \
--bootstrap true \
--fqdn $CHEF_BOOTSTRAP_IP_ADDRESS \
--chost $HOST_NAME\
--cdomain my.lan \
--run-list=$RUNLIST"
echo $VM_CLONE_CMD
eval $VM_CLONE_CMD
回显(单行):
knife vsphere vm clone dcbsmtest --template "CentOS" --cips 10.7.20.84/24
--vsdc MarkleyDC --datastore dcesxds04 --cvlan "VM Network"
--resource-pool ProdCluster01 --cgw 10.7.20.1
--cdnsips "10.7.20.11,10.8.20.11,10.6.20.11" --start true
--bootstrap true --fqdn 10.7.20.84 --chost dcbsmtest --cdomain my.lan
--run-list="role[my-env-prod-server]"
运行时输出:
Cloning template CentOS Template to new VM dcbsmtest
Finished creating virtual machine dcbsmtest
Powered on virtual machine dcbsmtest
Waiting for sshd...done
Doing old-style registration with the validation key at /home/me/chef-repo/.chef/our-validator.pem...
Delete your validation key in order to use your user credentials instead
Connecting to 10.7.20.84
root@10.7.20.84's password:
如果我离开我的办公桌,它会提示输入 PWD - 然后有时它会超时,连接会丢失,而厨师不会 bootstrap。此外,我希望能够根据系统需求将所有这些自动化,使其具有弹性——这不适用于有人值守的执行。
我要运行的想法,除非提供更好的解决方案是在模板中有一个默认密码,并在命令行上将其传递给 knife,然后让厨师更改密码构建完成,最大限度地减少 bash 脚本控制刀中硬编码密码的暴露...
更新:我想补充一点,这非常有效。理想情况下,我们可以更改我们正在部署的 centOs 模板 - 但在这里不可能 - 所以这是一个很好的选择(因为我们在部署后更改了 root 密码)。