manageiq.manageiq_automate
manageiq.manageiq_automate
The manageiq_automate
role helps ManageIQ Automate users to change and add to the Automate Workspace using an Ansible Playbook. It includes the manageiq_automate
module, which handles the important tasks for modifying the Automate Workspace.
Requirements
- You need to have ManageIQ version Gaprindashvili or higher.
The example playbook shows how to use the manageiq_automate
module included in this role.
If you want to use this Role in Ansible Tower or Embedded Ansible, create an empty roles
directory at the start of your playbook and add a requirements.yml
file with the following lines:
---
- source: manageiq.manageiq_automate
version: v0.1.3
Role Variables
Auto Commit:
auto_commit
is set toTrue
by default.- If it's
False
, it won't automatically save changes back to ManageIQ each time you call aset_
method.
Validate Certs:
manageiq_validate_certs
isTrue
by default.- If set to
False
, you can use self-signed certificates when connecting with SSL.
ManageIQ Connection:
manageiq_connection
is a dictionary for connection settings.- You only need this if you're not using a ManageIQ appliance.
- The appliance automatically provides this information.
- Make sure to use Ansible Vault for storing passwords.
automate_workspace
is required to interact with the Automate Workspace.
manageiq_connection:
url: 'http://localhost:3000'
username: 'admin'
password: 'password'
automate_workspace: 'automate_workspaces/1234'
manageiq_validate_certs: false
- Workspace:
workspace
is created intasks/main.yml
.- It holds the current version of the workspace with the changes made through the
manageiq_automate
module.
Dependencies
- None
Example Playbook
Here's a detailed example that shows how to modify the Automate Workspace using the manageiq_automate
module.
- name: Modify the Automate Workspace
hosts: localhost
connection: local
gather_facts: False
vars:
- auto_commit: True
# Only needed if this playbook is NOT run on a ManageIQ Appliance
- manageiq_connection:
url: 'https://localhost:3000'
username: 'admin'
password: 'password'
automate_workspace: 'automate_workspaces/1234'
manageiq_validate_certs: false
roles:
- manageiq.manageiq_automate
tasks:
- name: "Check an attribute"
manageiq_automate:
workspace: "{{ workspace }}"
attribute_exists:
object: "/ManageIQ/System/Request/call_instance"
attribute: "::miq::parent"
- name: "Get an attribute"
manageiq_automate:
workspace: "{{ workspace }}"
get_attribute:
object: "/ManageIQ/System/Request/call_instance"
attribute: "::miq::parent"
- name: "Check a state_var"
manageiq_automate:
workspace: "{{ workspace }}"
state_var_exists:
attribute: "task_id"
- name: "Get a state_var"
manageiq_automate:
workspace: "{{ workspace }}"
get_state_var:
attribute: "task_id"
- name: "Set a State Var"
manageiq_automate:
workspace: "{{ workspace }}"
set_state_var:
attribute: "job_id"
value: "xyz"
register: workspace
- name: "Check a Method Parameter"
manageiq_automate:
workspace: "{{ workspace }}"
method_parameter_exists:
parameter: "task_id"
- name: "Get a Method Parameter"
manageiq_automate:
workspace: "{{ workspace }}"
get_method_parameter:
parameter: "invoice"
- name: "Get the full list of Objects"
manageiq_automate:
workspace: "{{ workspace }}"
get_object_names: yes
- name: "Get the list of Method Parameters"
manageiq_automate:
workspace: "{{ workspace }}"
get_method_parameters: yes
register: method_params
- name: "Get the list of State Vars"
manageiq_automate:
workspace: "{{ workspace }}"
get_state_var_names: yes
- name: "Get the full list of Object Attribute Names"
manageiq_automate:
workspace: "{{ workspace }}"
get_object_attribute_names:
object: "root"
- name: "Set an attribute"
manageiq_automate:
workspace: "{{ workspace }}"
set_attribute:
object: "root"
attribute: "my_name"
value: "jim"
register: workspace
- name: "Set attributes"
manageiq_automate:
workspace: "{{ workspace }}"
set_attributes:
object: "root"
attributes:
family_name: "timmer"
eldest_son: "reed"
youngest_son: "olaf"
register: workspace
- name: Decrypt an attribute from an object
manageiq_automate:
workspace: "{{ workspace }}"
get_decrypted_attribute:
object: root
attribute: fred
register: decrypted_attribute
- debug: msg=decrypted_attribute
- name: Decrypt a method_parameter from an object
manageiq_automate:
workspace: "{{ workspace }}"
get_decrypted_method_parameter:
attribute: fred
- name: Encrypt an object attribute
manageiq_automate:
workspace: "{{ workspace }}"
set_encrypted_attribute:
object: root
attribute: freddy
value: 'smartvm'
- name: Grab a vmdb object
manageiq_automate:
workspace: "{{ workspace }}"
get_vmdb_object:
object: root
attribute: miq_group
Another Example
Here’s another example that uses variable substitution to update some object attributes with method_parameters
and change the retry.
- name: Siphon Method Parameters into an object
hosts: localhost
connection: local
vars:
- auto_commit: True
- object: root
- interval: 600
# Only needed if this playbook is NOT run on a ManageIQ Appliance
- manageiq_connection:
url: 'http://localhost:3000'
username: 'admin'
password: 'password'
automate_workspace: 'automate_workspaces/1234'
manageiq_validate_certs: false
gather_facts: False
roles:
- manageiq.manageiq_automate
tasks:
- name: "Get the list of Method Parameters"
manageiq_automate:
workspace: "{{ workspace }}"
get_method_parameters: yes
register: method_params
- name: "Set attributes"
manageiq_automate:
workspace: "{{ workspace }}"
set_attributes:
object: "{{ object }}"
attributes: "{{ method_params.value }}"
- name: Set Retry
manageiq_automate:
workspace: "{{ workspace }}"
set_retry:
interval: "{{ interval }}"
License
Apache
Ansible role to modify the ManageIQ automate workspace
ansible-galaxy install manageiq.manageiq_automate