adammck / terraform-inventory

Terraform State → Ansible Dynamic Inventory
MIT License
1.82k stars 321 forks source link

Add support for Azure Public IP resource #127

Open nicosingh opened 5 years ago

nicosingh commented 5 years ago

The idea is to use azurerm_public_ip terraform resources, which are the place where public IP addresses are defined for Azure VMs.

For instance:

resource "azurerm_public_ip" "cheap-worker-vm-ip" {
  name                = "cheap-worker-ip-address"
  location            = "${azurerm_resource_group.my-resource-group.location}"
  resource_group_name = "${azurerm_resource_group.my-resource-group.name}"
  allocation_method   = "Dynamic"

  tags = {
    Role = "cheap-worker"
  }
}

Will match later in ansible-playbook using the defined Role:

---
- hosts: role_cheap-worker
  remote_user: ubuntu
  become: yes
  become_user: root
  tasks:
    - name: install apps
       apt: name=cowsay update_cache=yes