Deploy OpsWorks to RHEL 7

Amazon Web Services offers OpsWorks as an orchestration tool for Chef. It works with built-in modules, community Chef cookbooks as well as private repositories.

In this tutorial I’ll attempt to bring an existing Linux server under OpsWorks’ realm so can manage it with Chef later on.


After logging into the AWS console navigate to OpsWorks and select Register instances then select EC2.


Register EC2 instance in OpsWorks

Select EC2 in OpsWorks

OpsWorks will detect any running EC2 instance and present it in a nice list. Specify a new stack name, place it in a region, custom VPC. OpsWorks will create a new role here (actually two of them) – note this may take a little while so don’t despair just be patient and get a cuppa.

One of these roles will be assigned to OpsWorks and the other will be empty. You’d need to jump to IAM roles and specify the correct policies so OpsWorks can manage the server and any additional resources specified in the second role.

OpsWorks setting up new IAM role

After 5-10 minutes this task should be completed. Next up the OpsWorks agent will need adding to the existing EC2 instance – very similar to installing any monitoring, anti-virus agents on servers/desktops so it can be imported and managed by OW and Chef. The console is quite handy here as it gives the exact command to be used including instance class, region and stack ID.

Register instance with OpsWorks

Copy the command given SSH to your EC2 instance and run the command and that’s it… unless you face issues as I did.

The command seemed to complete however it did not register. After a few attempts I checked the logs under /var/log/aws/opswork and found that agent installation failed.

[Thu, 14 Sep 2017 13:26:32 +0000] opsworks-init: Agent installation failed.

Checked the logs further and the installation did not complete with Error 5 and Error 12 “Cannot allocate memory”. Quickly tried a yum update which failed with the same results – seemed the server indeed was out of memory confirmed by running the free command!

I realized I must have forgotten to set the swap file so decided to give it 1GB (shows as 1M*1024 count).

With the swap file configured it was time to re-try installing the agent again – which seemed to have worked just fine.

OpsWorks CLI installer

Refreshed OpsWorks console a few times and I found the status has changed from “not yet imported” to “running_setup” and then to “registered

AWS OpsWorks Instance running setup  AWS OpsWorks Instance registered

From now on the EC2 instance is part of the OpsWorks stack and can be managed via built-in, custom or community Chef recipes. Happy days!

As always leave me a message or comment if you found this helpful.


Disclaimer here!

Leave a Reply

Your email address will not be published. Required fields are marked *