gpt4 book ai didi

amazon-web-services - Chef : HOME environment variable (or HOMEDRIVE and HOMEPATH) must be set and point to a directory

转载 作者:行者123 更新时间:2023-12-03 07:46:23 26 4
gpt4 key购买 nike

我正在尝试通过执行 memcached Chef 配方来自动化 aws ec2 memcached 实例引导。我从云形成 UserData 部分调用 shell 脚本名称cache-init.sh。我的 shell 脚本中有以下步骤:

我正在运行 AMI RHEL 6.7 版本

!/bin/bash

init () {
BINARIES=/root/.binaries
PROFILE_SCRIPT=/etc/profile.d/instance_profile.sh
APPLICATION_RELEASE_VERSION="app-v3.0.1"
CHEF_ZIP="app-chef-${APPLICATION_RELEASE_VERSION}.zip"
APP_FILES="${CHEF_ZIP}"
HOME=/root
}

# Initializing the script vairables.
init

# Create chef folders
mkdir /root/.chef;
mkdir /root/.metadata;

# Disable rhui-lb plugin, this has an issue in RHEL within VPC
sed -i 's/enabled=1/enabled=0/g' /etc/yum/pluginconf.d/rhui-lb.conf

# Print all environment varialbes in log
set > /root/.metadata/metadata.txt


# Update ${PROFILE_SCRIPT}
echo "export HOME=${HOME}" >> ${PROFILE_SCRIPT};
chmod 644 ${PROFILE_SCRIPT};
log 'Added ${PROFILE_SCRIPT}';

echo ${HOME}

# Install chef
# Set these just for Chef installation
/usr/bin/curl -L https://www.opscode.com/chef/install.sh | bash -s -- -v 11.16.2-1;
chef_version=`chef-solo --version`;
log "Installed Chef Version : $chef_version in /opt/chef " ;

log "Installing ChefDk"
/usr/bin/curl -L https://omnitruck.chef.io/install.sh | sudo bash -s -- -c current -P chefdk

chef-repo=/root/.chef/chef-repo
memcached_cookbook=${chef-repo}/cookbooks/memcached
cd ${memcached_cookbook}


# download and package the dependencies.
chef exec berks install
chef exec berks vendor

log "memcached dependencies downloaded and packaged"

cp -r berks-cookbooks/runit /root/.chef/itduzzit/cookbooks
cp -r berks-cookbooks/yum /root/.chef/itduzzit/cookbooks
cp -r berks-cookbooks/yum-epel /root/.chef/itduzzit/cookbooks
cp -r berks-cookbooks/packagecloud /root/.chef/itduzzit/cookbooks

# Clean up the dependencies.
rm -rf berks-cookbooks

执行berks install命令后,出现以下错误:

/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/rb-readline-0.5.3/lib/rbreadline.rb:1097:in <module:RbReadline>: HOME environment variable   (or HOMEDRIVE and HOMEPATH) must be set and point to a directory (RuntimeError)
from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/rb-readline- 0.5.3/lib/rbreadline.rb:17:in <top (required)>
from ...
from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/berkshelf-4.3.2/bin/berks:3:in `<top (required)>'
from /usr/bin/berks:49:in `load'
from /usr/bin/berks:49:in `<main>'

我尝试通过在cache-init.sh脚本开头导出它来设置HOME环境变量,但仍然遇到相同的错误。当我 ssh 到盒子并手动运行脚本时,它工作正常。我尝试寻找错误,但没有找到合适的修复方法。非常感谢这里的任何帮助。

最佳答案

在 init 下,应该是 export HOME=... (对于其他所有内容都相同。如果没有 export,您将创建一个 bash 变量,而不是一个环境变量。

关于amazon-web-services - Chef : HOME environment variable (or HOMEDRIVE and HOMEPATH) must be set and point to a directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36560160/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com