Created
September 29, 2014 15:18
-
-
Save jicowan/e19fcbea08a9c6e2b1b6 to your computer and use it in GitHub Desktop.
knife-vcair plug-in, custom distro example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bash -c ' | |
<%= "export https_proxy=\"#{knife_config[bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%> | |
PACKAGE_URL="http://1.2.3.4/path-to-package-file/chef-11.16.2-1.el6.x86_64.rpm" | |
if [ ! -f /usr/bin/chef-client ]; then | |
curl -o /tmp/chef-client-package.rpm $PACKAGE_URL | |
rpm -Uvh /tmp/chef-client-package.rpm | |
fi | |
mkdir -p /etc/chef | |
cat > /etc/chef/validation.pem <<'EOP' | |
<%= validation_key %> | |
EOP | |
chmod 0600 /etc/chef/validation.pem | |
<% if encrypted_data_bag_secret -%> | |
cat > /etc/chef/encrypted_data_bag_secret <<'EOP' | |
<%= encrypted_data_bag_secret %> | |
EOP | |
chmod 0600 /etc/chef/encrypted_data_bag_secret | |
<% end -%> | |
<%# Generate OHai Hints -%> | |
<% unless @chef_config[:knife][:hints].nil? || @chef_config[:knife][:hints].empty? -%> | |
mkdir -p /etc/chef/ohai/hints | |
<% @chef_config[:knife][:hints].each do |name, hash| -%> | |
cat > /etc/chef/ohai/hints/<%= name %>.json <<'EOP' | |
<%= hash.to_json %> | |
EOP | |
<% end -%> | |
<% end -%> | |
cat > /etc/chef/client.rb <<'EOP' | |
<%= config_content %> | |
EOP | |
cat > /etc/chef/first-boot.json <<'EOP' | |
<%= first_boot.to_json %> | |
EOP | |
<%= start_chef %>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a custom distribution or distro file for the CentOS image in the VMware vCloud Air image library. You could use this file if you are prevented from downloading and bootstrapping the Chef client from the Internet. This script assumes that you have downloaded and published the chef-client package for CentOS onto a web server within your vCloud Air vDC. You can download the package for CentOS at https://www.getchef.com/download-chef-client/. Before this will work, you need to add a reference to this distro in you knife.rb file. You can do this by appending knife[:distro] = "centos" to your knife.rb file. Once that's complete, place this file [centos.erb] in same directory as the chef-full.erb file. If you're unsure where chef-full is on your file system, you can search for it by using "find / -name chef-full.erb". When you're ready to provision a new instance of CentOS using Chef, use the knife vcair server create command.