Quick Tip: Resolve Salt-Cloud EC2 Instance Provisioning Failure during Dependency Installation

I recently began learning SaltStack to compliment my knowledge of Puppet. I always like to use a new technology I’m learning to accomplish meaningful tasks related to whatever project I’m working on at the time and SaltStack, along with its cloud-oriented companion Salt-Cloud, seemed like they would be very helpful when migrating my personal website and Blog from Squarespace back to Amazon Web Services. Once I had deployed a salt-master server and configured it with the necessary packages and profiles, I attempted to deploy my first EC2 instance using Salt-Cloud and ran into the following error:

[bash]salt-cloud * ERROR: Failed to run install_amazon_linux_ami_deps()!!![/bash]

A quick Google search led me to this Github issue which included a simple solution. Before we discuss implementation of the solution, though, let’s first examine the root cause of the error. The version of Salt-Cloud available in the EPEL repository (2015.5.10-2 as of this writing) includes hard-coded references to the Saltstack repository in bootstrap-salt.sh which point to an incorrect URL. During the bootstrapping process Salt-Cloud uses this script to create a repository so it can install dependencies as well as the salt-minion package itself, but the incorrect URL (and resulting incorrect BASEURL parameter in the repository file created by the script) prevents Yum from downloading any packages which causes minion deployment/provisioning to fail with the error message above.

Since the issue ultimately amounts to nothing more than an outdated URL in the bootstrap-salt.sh, we can remedy it by replacing each instance of http://copr.fedoraproject.org in the file with https://copr.fedorainfracloud.org. Before replacing the incorrect links, though, you should make a backup copy of the original file with the following command (just in case something goes terribly wrong in the process):

[bash]sudo cp /usr/lib/python2.7/site-packages/salt/cloud/deploy/bootstrap-salt.sh /usr/lib/python2.7/site-packages/salt/cloud/deploy/bootstrap-salt.sh.orig[/bash]

Once you’ve made a backup copy of the file, open it with Vim and replace the incorrect URL globally with the following editor command:

[bash]:%s/http://copr.fedoraproject.org/https://copr.fedorainfracloud.org/g[/bash]

(Note: The above command should result in four substitutions)

Once you have corrected the URL’s and saved the file you should restart the salt-master service with one of the following commands:

CentOS/RHEL 6.x

[bash]sudo service restart salt-master[/bash]

CentOS/RHEL 7.x

[bash]sudo systemctl salt-master restart[/bash]

After completing the above steps, you should now be able to successfully deploy EC2 instances using Salt-Cloud. If you encounter any issues with any of these steps or have any other comments or questions regarding Saltstack or Salt-Cloud please don’t hesitate to leave a comment below.

Leave a Reply

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