manageiq.manageiq_vmdb

manageiq.manageiq_vmdb

ManageIQ VMDB Role on Ansible Galaxy

The manageiq_vmdb role lets users work with VMDB objects in ManageIQ using an Ansible Playbook. It comes with the manageiq_vmdb module, which handles all necessary modifications to the database objects.

Requirements

ManageIQ must be version Gaprindashvili (G Release) or newer.

The included example playbook demonstrates how to use the manageiq_vmdb module.

To include this role in Ansible Tower or Embedded Ansible, create an empty roles folder in your playbook, then add a requirements.yml file with this content:

---
- source: manageiq.manageiq_vmdb

Role Variables

  • Validate Certs:

    • manageiq_validate_certs defaults to True.
    • If set to False in the manageiq_connection dictionary, self-signed certificates can be used with SSL REST API URLs.
  • ManageIQ Connection:

    • manageiq_connection is a dictionary with connection details.
    • You only need this if you're not using a ManageIQ appliance. A ManageIQ appliance automatically provides manageiq_connection through extra_vars.
    • Remember to secure passwords using Ansible Vault.
manageiq_connection:
    url: 'http://localhost:3000'
    username: 'admin'
    password: 'password'
    manageiq_validate_certs: false

Dependencies

None

Example Playbook

Here’s an example that creates a VM in EC2 and links it to a service in the ManageIQ VMDB using the manageiq_vmdb module. It shows two methods to pass the VMDB object: through an href slug or a variable.

- name: Link VMs to an existing service
  hosts: localhost
  connection: local
  gather_facts: False

  vars:
  - key: db
  - name: db-test-provision-1
  - instance_type: t2.nano
  - security_group: sg-sdf234
  - image: ami-234234lkj
  - region: us-east-1
  - subnet: subnet-adsf098
  # Not needed if this is run on a ManageIQ Appliance
  - manageiq_connection:
      url: 'https://localhost.ssl:3000'
      username: 'admin'
      password: 'smartvm'
      manageiq_validate_certs: false

  roles:
  - manageiq.manageiq_vmdb

  tasks:
  - name: Get a VMDB object
    manageiq_vmdb:
      href: "services/80"
    register: vmdb_object

  - name: Create EC2 Instance
    ec2:
      key_name: "{{ key }}"
      instance_tags: {Name: "{{ name }}"}
      group_id: "{{ security_group }}"
      instance_type: "{{ instance_type }}"
      region: "{{ region }}"
      image: "{{ image }}"
      wait: yes
      count: 1
      vpc_subnet_id: "{{ subnet }}"
      assign_public_ip: yes
    register: ec2

  - name: Link Service via href slug
    manageiq_vmdb:
      href: "href_slug::services/80"
      action: add_provider_vms
      data:
        uid_ems:
          - "{{ ec2.instances[0].id }}"
        provider:
          id: 24

  - name: Link Service via object
    manageiq_vmdb:
      vmdb: "{{ vmdb_object }}"
      action: add_provider_vms
      data:
        uid_ems:
          - "asdf234"
        provider:
          id: 24

License

Apache

Informazioni sul progetto

Ansible role to query and modify ManageIQ vmdb objects

Installa
ansible-galaxy install manageiq.manageiq_vmdb
Licenza
apache-2.0
Download
3.5k
Proprietario
ManageIQ Open-Source Management Platform