Giter Club home page Giter Club logo

ansible-manageiq-automate's Introduction

manageiq-automate

The manageiq-automate role allows for users of ManageIQ Automate to modify and add to the Automate Workspace via an Ansible Playbook. The role includes a module manageiq_automate which does all the heavy lifting needed to modify or change the Automate Workspace.

Requirements

ManageIQ has to be Gaprindashvili (G Release) or higher.

The example playbook makes use of the manageiq_automate module which is also included as part of this role.

If you have a requirement to include this Role in Ansible Tower or Embedded Ansible, simply add an empty roles directory at the root of your playbook and include a requirements.yml file with the following contents inside that directory:

---
- src: syncrou.manageiq-automate
  version: v0.1.0

Role Variables

Auto Commit: auto_commit defaults to True in defaults/main.yml. If set to False it will not auto commit back to ManageIQ each call to a set_ method in the manageiq_automate module.

Validate Certs: manageiq_validate_certs defaults to True. If set to False in the manageiq_connection dictionary or passed in via extra_vars or assigned in the playbook vars then the lookup will allow self signed certificates to be used when using SSL REST API connection urls.

ManageIQ: manageiq_connection is a dictionary with connection default keys. Use of this connection information is ONLY needed if the role is used outside of a ManageIQ appliance. A ManageIQ appliance passes in manageiq_connection via extra_vars so connection information is included automatically. Remember to use Ansible Vault for passwords. automate_workspace is the href slug and guid required to talk to the Automate Workspace.

    manageiq_connection:
        url: 'http://localhost:3000'
        username: 'admin'
        password: 'password'
        automate_workspace: 'automate_workspaces/1234'
        manageiq_validate_certs: false

Workspace: workspace instantiated via tasks/main.yml. The current version of the workspace as it is modified via methods in the manageiq_automate module.

Dependencies

None

Example Playbook

A verbose example with manual strings passed to each method of 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:
  - syncrou.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

An example making use of variable substitution to modify some object attributes with passed in 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:
  - syncrou.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-manageiq-automate's People

Contributors

miha-plesko avatar pkomanek avatar syncrou avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.