memcachedシェフレシピを実行してaws ec2 memcachedインスタンスのブートストラップを自動化しようとしています。クラウドの構成UserDataセクションからシェルスクリプト名cache-init.shを呼び出しています。私は、コマンドが実行されますインストールバークス後AMI RHEL 6.7バージョンCHEF:HOME環境変数(またはHOMEDRIVEとHOMEPATH)を設定し、ディレクトリを指す必要があります
!/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
を実行しています
、私はエラー以下の取得:
/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>'
私が設定しようとした私は、シェルスクリプトで次の手順を持っていますHOME-env変数はcache-init.shスクリプトの開始時にエクスポートしても、同じエラーが表示されます。私がボックスにsshしてスクリプトを手動で実行すると、正常に動作します。私はエラーを検索しようとしましたが、適切な修正が見つかりませんでした。ここで何か助けに感謝します。
はあなたが環境を設定する方法を示してください変数。 – coderanger
@coderangerのI – sjaiswal