Skip to content
This repository has been archived by the owner on Jun 14, 2023. It is now read-only.

CloudHealth/ansible-cloudhealth-collector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License

CloudHealth Collector

This role allows CloudHealth's customers to integrate our platform into their Ansible setup.

Requirements

Make sure that you have not turned off fact gathering in your playbooks. gather_facts: no must not be present in your playbooks.

This module requires httplib2 to be installed on the host machine. It can be installed via apt-get (sudo apt-get install python-httplib2) or via pip (sudo pip install httplib2) if not available in the distribution package manager.

Additionally, there is a current limitation regarding the uptime of your nodes: you need to either use Ansible 2+, or to have ohai or facter installed on your managed nodes. Failing to do so will leave your nodes' uptime information blank on the CloudHealth platform.

Role Variables

cloudhealth_api_key

The cloudhealth_api_key is used to identify yourself to our API. This variable is required.

Go to the Ansible Accounts page. If there is no accounts listed yet, create one by clicking on New Account.

Your API key will then be listed next to your account name on that Ansible Accounts page:

Ansible Account API key

You then need to define it in your playbooks.

The most straightforward way to do so is to store it in plain text in your playbook variables:

cloudhealth_api_key: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

However, to avoid storing your API key in your playbooks, first set the following in your playbook variables:

cloudhealth_api_key: "{{ lookup('env','CLOUDHEALTH_API_KEY') }}"

Then, either add the following line in your ~/.bashrc file (don't forget to source ~/.bashrc or to open a new terminal) or run this command before executing your playbooks:

export CLOUDHEALTH_API_KEY=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Finally, a third option, more secure, is to use Ansible Vault to store the API key.

Development environment

Start by setting your API key in an environment variable called CLOUDHEALTH_API_KEY.

Then install Vagrant and VirtualBox using your favorite package manager and run:

vagrant up

This will spin up a minimal virtual machine and provision it with a test playbook using that role.

If that step succeeds, syntax of the role is correct and all tasks are successful on a bare machine.

To provision the virtual machine again, run the following:

vagrant up # Unnecessary if the VM is already running
vagrant provision

To run an ad-hocs command on that machine, for example to retrieve all facts from it, run the following:

ansible all -i .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory -u vagrant --private-key .vagrant/machines/default/virtualbox/private_key -m setup

Once you are done with changes, you can run one of the following:

vagrant halt -f # Shuts down the VM for later re-use
vagrant destroy -f # Destroys the VM entirely

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published