I wanted to set up my Raspberry Pi with Ansible and the AWSCLI package to allow the creation of AWS servers from the Pi.
As I was recycling a card I no longer needed reformatting the card and installing Raspbian on it seemed sensible start.
I use the SD Formatter programme to ensure that the SD Card is formatted correctly.
Then downloaded the latest image of Raspbian and used Win32DiskImager to install the OS onto the card.
I have been caught out before with errors of “No space left on device” or similar so the first command I run is
Then select the Expand Filesystem menu option. This ensures that all the SD card is used.
A reboot is required for the changes to take effect.
The Pi is now ready to begin downloading packages.
The next task is to update and upgrade the software on the Pi using
sudo apt-get update
sudo apt-get upgrade –y
sudo apt-get dist-upgrade
The below will help with explaining what is the difference between upgrade and dist-upgrade
upgrade upgrade is used to install the newest versions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list. Packages currently installed with new versions available are retrieved and upgraded; under no circumstances are currently installed packages removed, or packages not already installed retrieved and installed. New versions of currently installed packages that cannot be upgraded without changing the install status of another package will be left at their current version. An update must be performed first so that apt-get knows that new versions of packages are available. dist-upgrade dist-upgrade in addition to performing the function of upgrade, also intelligently handles changing dependencies with new versions of packages; apt-get has a "smart" conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones if necessary. So, dist-upgrade command may remove some packages. The /etc/apt/sources.list file contains a list of locations from which to retrieve desired package files. See also apt_preferences(5) for a mechanism for overriding the general settings for individual packages.
If you want to clean up the build and remove any package files the following command can be used. This can also help save space if you have a small card.
sudo apt-get clean
After some Googling I found a good set of instructions on installing Ansible onto the Pi. As this Article says it needs some extra bits to make it work.
There are a couple of steps missing below this site which I have added in below in bold.
sudo apt-get install python-dev -y sudo apt-get install libffi-dev libssl-dev -y cd ~ wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python wget https://pypi.python.org/packages/f7/83/377e3dd2e95f9020dbd0dfd3c47aaa7deebe3c68d3857a4e51917146ae8b/pyasn1-0.1.9.tar.gz#md5=f00a02a631d4016818659d1cc38d229a tar –xvzf pyasn1-0.1.9.tar.gz cd pyasn1-0.1.9 python setup.py install cd ~ wget http://releases.ansible.com/ansible/ansible-18.104.22.168.tar.gz tar zxvf ansible-22.214.171.124.tar.gz cd ansible-126.96.36.199 make sudo make install cd ~
It is always worth checking to see if there is a later version of the packages available and making the necessary changes to the lines above.
Next install the boto package
pip install --user boto
Next install the awscli package
sudo pip install awscli
more information on installing awscli can be found at http://docs.aws.amazon.com/cli/latest/userguide/installing.html
once installed you can then use the
command to check the installation has worked.
To configure the awscli follow the instructions at http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html
assuming that you have an AWS account already.
command you can enter your keys. The keys below are examples only
aws configureAWS Access Key ID [None]:
AWS Secret Access Key [None]:
Default region name [None]:
Default output format [None]:
You should now be able to use Ansible and the AWSCLI on your Raspberry PI.