Chef-deployment

How to deploy node with Chef and Foreman :
This assumes you have a local (deb/yum/...) repository with chef-client available.
You may need to retrieve package directly from opscode repository with wget for example.

  1. Create a new admin user in chef-server and grant it admin rights
  2. On provisionning templates add a chef snippet like (

#installing chef repo
cat << 'EOF' > /etc/yum.repos.d/centos_management.repo
[chef-repo]
name=Chef Repository
baseurl=http://...
gpgcheck=1
EOF

#installing chef
yum install -y chef
mkdir /etc/chef
cat << 'EOF' > /etc/chef/validation.pem
-----BEGIN RSA PRIVATE KEY-----
## You need to paste here foreman's private key
-----END RSA PRIVATE KEY-----
EOF

cat << 'EOF' > /etc/chef/client.rb
log_level        :info
log_location     STDOUT
chef_server_url  "https://chef.example.com" 
validation_client_name "foreman" 
file_backup_path   "/var/lib/chef" 
file_cache_path    "/var/cache/chef" 
pid_file           "/var/run/chef/client.pid" 
EOF

# You may set here the default run list for all your nodes
cat << 'EOF' > /tmp/base.json
{
  "run_list": ["role[base]"]
}
EOF

#first run of chef-client
/usr/bin/chef-client -j /tmp/base.json

rm -rf /tmp/base.json /etc/chef/validation.pem

You need to include the snippet in your provision script like :

<%= snippet "chef-bootstrap" %>

You should think about removing all puppet references on the provision template :)