Google Cloud Shell on Google Cloud Platform
On the Google Cloud Platform, Google provides Google Cloud Shell for free to easily manage your services. Whenever you launch the shell, on the backend, the platform creates a new VM instance to drive the shell. This shell instance will if there is more than 30 minutes of inactivity. Because of this, the persistence between sessions is limited. However there is 5GB worth of storage within you
~) directory which persist between sessions.
Using Ansible on Google Cloud Shell
The Google Cloud Shell provides a great place to to run your Ansible playbooks since you will be able to clone your git repositories into the persistent home directory. However if you try to install Ansible through the package manager (
apt-get in this case), every time the session terminates, you lose your Ansible install.
This is less than ideal as you have to add the source before installing to get the latest version (at the moment of this post, the version from the package manager is 1.7.x) of Ansible. The easiest way I found was to clone the Ansible repository and run the following command in the repository directory.
sudo make install
Unfortunately, you will need to run this command for each new session, but this seems the shortest and easiest way to get Ansible running in Google Cloud Shell. Of course you can checkout the git repository tag you wish to use before installing so you have the right version of Ansible.
Once installed, you can use Ansible for the session like how you normally would.
If anyone knows a better or easier way of doing this, please let me know.