Skip to main content
Ansible Collection Equinix
  • Labs / 
  • Ansible Collection...
Version v0.11.1 was released on 21 October, 2024 View changelog External link icon

Ansible Collection Equinix

Manage Metal resources in event-driven configurations using our growing Ansible collection (provider). Reach out with features you need for your YAML playbooks!

The Ansible Collection for Equinix contains various plugins for managing Equinix services.

What is it?

This collection of Ansible modules enables workflows for interacting with the Equinix Digital Infrastructure APIs. We have modules for managing Equinix Metal devices, elastic IPs, and projects, as well as the related Shared Fabric Connection VCs, VRF, and Metal Gateway. Additional modules allow you to gather info about your Equinix Metal infrastructure to use in your playbooks.

Why do we love it?

  • Best of Both Worlds: Excels in configuration management while still able to deploy infrastructure as code by itself or be used with Terraform
  • Low Barrier to Entry: Uses simple YAML, no new language to learn before jumping in
  • Extensible: Leverages the powerful Equinix Metal API with growth plans to include dedicated connections and other requested items as needed for your playbooks
  • Mature: Well-established forum community and use-cases
  • Cloud-Agnostic: As home to major cloud on-ramps, and an encourager of multi-cloud this a pre-requisite!
  • More Cost, Time, Security Savings: Ansible is masterless and agentless like Terraform, which means no excess infrastructure costs, no software management updates, and less exposed ports that need configuring for authentication.
  • Simplify complex tasks: The broad module coverage enables repeatable deploy for complex use-cases, for example, BGP discovery of private IP pools over Metal VLANS

How do you use it?

The collection is available on Ansible Galaxy and can be installed with the following command:

ansible-galaxy collection install equinix.cloud

The Python module dependencies are not installed by ansible-galaxy. They can be manually installed using pip:

pip install -r https://raw.githubusercontent.com/equinix/ansible-collection-equinix/main/requirements.txt

Examples

The project includes examples for each module, included in the Ansible Galaxy documentation.

There are also a few larger examples to examine for more complex integrations:

  • Assign IP Addresses to Metal Devices - Demonstrates managing resources on Equinix Metal, including creating a project, reserving an IP block, provisioning a device, and assigning an IP address.
  • Configure Metal Device Networking Ports - Shows how to configure various network types for an Equinix Metal device, including creating VLANs and provisioning a device.
  • Layer-2 Networking with Interconnection and AWS - Demonstrates configuring Layer 2 connectivity from an Equinix Metal device to AWS S3 over a Metal-billed Fabric interconnection, including creating a project, VLAN, VRF, and configuring BGP peering.

Provisioning Equinix Metal

To run any of the examples, you will need an Equinix Metal API token. You can obtain an API token from the Equinix Metal Portal. Set the environment variable METAL_AUTH_TOKEN to your API token:

export METAL_AUTH_TOKEN=your_api_token_here

The following is a simple playbook that creates a new device in a project you specify.


---

- name: create Equinix Metal device
  hosts: localhost
  tasks:
    - equinix.cloud.metal_device:
        project_id: "3b516842-c8b1-485e-9f76-c891bd804c5e"
        hostname: "my-new-device"
        operating_system: ubuntu_20_04
        plan: c3.small.x86
        metro: sv

Save this to a file named main.yml and edit it to use your own project ID.

To run the playbook, navigate to the directory containing the playbook file main.yml and run the following command:

ansible-playbook main.yml

More info can be found at the Ansible Collection for Equinix GitHub repository.

Let us know about your experience with this project on the Equinix Community.

Interested in other Equinix API infrastructure-as-code integrations? Let us know.

Last updated

07 November, 2024

Category

Type

Plugins