HOWTO: AWS EC2 and Hosted Chef

Chef_Vertical_CCan_Reg.png   687474703a2f2f63646e3030312e70726163746963616c636c6f7564732e636f6d2f757365722d636f6e74656e742f315f446176652532304d63436f726d69636b2f2f6c6f676f732f416d617a6f6e253230415753253230706c75732532304543322532306c6f676f5f7363616c65642e706e67.png

AWS EC2 and Hosted Chef (in-progress)

Requirements

  1. A hosted chef account from http://chef.io
  2. An AWS account
  3. A RHEL/CentOS AMI

Setup

  1. Create an AWS resource handler connection in CloudBolt.
    1. This includes an Internet-accessible VPC.
    2. Import an AMI for the region used
    3. On your CB server, create the directory /var/opt/cloudbolt/resourcehandlers/aws/<instance_id>/; where <instance_id> is take from the URL for the Resource Handler configuration page for this resource handler, e.g. for https://your_cloudbolt_server/admin/resourcehandlers/1/, the <instance_id> is "1"
    4. Upload your private .pem file to the directory created in the previous script. This is case sensitive, so if the key name is MyKeY, then the .pem file should be MyKeY.pem.
  2. Create a Configuration Management connection to Hosted Chef in CloudBolt.
    1. Create an organization in Hosted Chef and be sure to save the validator key as <organization_name>_validator.pem
    2. Create an Configuration Manager Chef instance in CloudBolt under Admin > Configuration Managers > "Add a configuration manager".
    3. Create /var/opt/cloudbolt/connectors/chef/<provider_id>/ where <provider_id> is taken from the URL after clicking your Chef Configuration Manager instance in CloudBolt. For instance in this url: https://your_cloudbolt_instance/providers/1; the provider_id = 1.
    4. Be sure to download the private key for your Hosted Chef user account and save it as <username>.pem to /var/opt/cloudbolt/connectors/chef/<provider_id>/<username>.pem
    5. From Hosted Chef, select the organization in the list of organizations and click "Generate Knife Config" to download the knife config to your local computer. Copy this file (knife.rb) to /var/opt/cloudbolt/connectors/chef/<provider_id>/.
    6. Copy <organization_name>_validator.pem to /var/opt/cloudbolt/connectors/chef/<provider_id>/
    7. Complete the install of knife per instructions provided by Chef. There's a link to these instructions in the CloudBolt documentation for Chef setup.
    8. Import any cookbooks or roles being used from Hosted Chef.
  3. Create an environment for the above resource handler.
    1. Set the configuration manager to the chef instance created above
    2. Set the AWS Region and select the appropriate VPC
    3. Add an OS Build (AMI) that was imported via the Resource Handler configuration
    4. Be sure the availability zone is set the zone containing your VPC
  4. Upload sleep orchestration hook attached to this article. By default this script sleeps for 3 minutes.
    1. Link to this file is just below this text.
    2. Add to the Pre-Network hook, give it any name, and bind it to the CloudBolt Environment defined in step 3.
    3. If CloudBolt needs to wait longer for the EC2 instance to initialize before bootstrapping the Chef client, edit line 6 of sleep.py.
  5. Provision a server -- you should see an Applications select list at the bottom of your server configuration.

Questions or comments? Leave them here! 

Have more questions? Submit a request

1 Comments

  • 0
    Avatar
    Dilip Bhapkar

    Hi Rick

    is it applicable to Azure Env. I am provisioning to  RHEL on Azure  . finding Net::SSH::ConnectionTimeout 

    As suggested, if I add sleep.py at Pre-Network hook script will it work for me with more timeout value selected?

Please sign in to leave a comment.