manageiq.manageiq_automate

manageiq.manageiq_automate

https://galaxy.ansible.com/manageiq/manageiq_automate

manageiq_automate 角色允许 ManageIQ Automate 用户通过 Ansible Playbook 修改和添加到 Automate 工作区。 该角色中包含一个模块 manageiq_automate,它负责修改或更改 Automate 工作区所需的所有繁重工作。

要求

ManageIQ 必须是 Gaprindashvili 或更高版本。

示例 Playbook 使用了 manageiq_automate 模块,该模块也是此角色的一部分。

如果您希望在 Ansible Tower 或嵌入式 Ansible 中包含此角色,只需在 Playbook 的根目录下添加一个空的 roles 目录,并在该目录中包含一个 requirements.yml 文件,内容如下:

---
- source: manageiq.manageiq_automate
  version: v0.1.3

角色变量

自动提交: auto_commit 默认值为 Truedefaults/main.yml 中。 如果设置为 False,则在调用 manageiq_automate 模块的 set_ 方法时不会自动提交回 ManageIQ。

验证证书: manageiq_validate_certs 默认值为 True。 如果在 manageiq_connection 字典中设置为 False,或通过 extra_vars 传入,或在 Playbook 变量中分配,则在使用 SSL REST API 连接 URL 时允许自签名证书的使用。

ManageIQ: manageiq_connection 是一个包含连接默认键的字典。 仅在角色在 ManageIQ 设备之外使用时需要使用此连接信息。ManageIQ 设备通过 extra_vars 传入 manageiq_connection,因此连接信息会自动包含。 请记得使用 Ansible Vault 来管理密码。 automate_workspace 是与 Automate 工作区交互所需的 href slug 和 guid。

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

工作区: workspace 通过 tasks/main.yml 实例化。 工作区的当前版本是通过 manageiq_automate 模块中的方法进行修改的。

依赖

示例 Playbook

一个详细的示例,向 manageiq_automate 模块的每个方法传递手动字符串

- name: 修改 Automate 工作区
  hosts: localhost
  connection: local

  gather_facts: False
  vars:
  - auto_commit: True
  # 仅在此 Playbook 不在 ManageIQ 设备上运行时需要
  - 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: "检查一个属性"
      manageiq_automate:
        workspace: "{{ workspace }}"
        attribute_exists:
          object: "/ManageIQ/System/Request/call_instance"
          attribute: "::miq::parent"

    - name: "获取一个属性"
      manageiq_automate:
        workspace: "{{ workspace }}"
        get_attribute: 
          object: "/ManageIQ/System/Request/call_instance"
          attribute: "::miq::parent"

    - name: "检查一个状态变量"
      manageiq_automate:
        workspace: "{{ workspace }}"
        state_var_exists:
          attribute: "task_id"

    - name: "获取一个状态变量"
      manageiq_automate:
        workspace: "{{ workspace }}"
        get_state_var:
          attribute: "task_id"

    - name: "设置一个状态变量"
      manageiq_automate:
        workspace: "{{ workspace }}"
        set_state_var:
          attribute: "job_id"
          value: "xyz"
      register: workspace

    - name: "检查一个方法参数"
      manageiq_automate:
        workspace: "{{ workspace }}"
        method_parameter_exists:
          parameter: "task_id"

    - name: "获取一个方法参数"
      manageiq_automate:
        workspace: "{{ workspace }}"
        get_method_parameter:
          parameter: "invoice"

    - name: "获取所有对象列表"
      manageiq_automate:
        workspace: "{{ workspace }}"
        get_object_names: yes

    - name: "获取方法参数列表"
      manageiq_automate:
        workspace: "{{ workspace }}"
        get_method_parameters: yes
      register: method_params

    - name: "获取状态变量列表"
      manageiq_automate:
        workspace: "{{ workspace }}"
        get_state_var_names: yes

    - name: "获取所有对象属性名称"
      manageiq_automate:
        workspace: "{{ workspace }}"
        get_object_attribute_names:
          object: "root"

    - name: "设置一个属性"
      manageiq_automate:
        workspace: "{{ workspace }}"
        set_attribute:
          object: "root"
          attribute: "my_name"
          value:  "jim"
      register: workspace

    - name: "设置多个属性"
      manageiq_automate:
        workspace: "{{ workspace }}"
        set_attributes:
          object: "root"
          attributes:
            family_name: "timmer"
            eldest_son: "reed"
            youngest_son: "olaf"
      register: workspace

    - name: 解密对象中的属性
      manageiq_automate:
        workspace: "{{ workspace }}"
        get_decrypted_attribute:
          object: root
          attribute: fred
      register: decrypted_attribute

    - debug: msg=decrypted_attribute

    - name: 解密对象中的方法参数
      manageiq_automate:
        workspace: "{{ workspace }}"
        get_decrypted_method_parameter:
          attribute: fred

    - name: 加密对象属性
      manageiq_automate:
        workspace: "{{ workspace }}"
        set_encrypted_attribute:
          object: root
          attribute: freddy
          value: 'smartvm'

    - name: 获取一个 vmdb 对象
      manageiq_automate:
        workspace: "{{ workspace }}"
        get_vmdb_object:
          object: root
          attribute: miq_group

一个示例,利用变量替换修改某些对象属性,传入 method_parameters 和修改重试。

- name: 将方法参数传入对象
  hosts: localhost
  connection: local
  vars:
  - auto_commit: True
  - object: root
  - interval: 600
  # 仅在此 Playbook 不在 ManageIQ 设备上运行时需要
  - 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: "获取方法参数列表"
      manageiq_automate:
        workspace: "{{ workspace }}"
        get_method_parameters: yes
      register: method_params

    - name: "设置属性"
      manageiq_automate:
        workspace: "{{ workspace }}"
        set_attributes:
          object: "{{ object }}"
          attributes: "{{ method_params.value }}"

    - name: 设置重试
      manageiq_automate:
        workspace: "{{ workspace }}"
        set_retry:
          interval: "{{ interval }}"

许可证

Apache

关于项目

Ansible role to modify the ManageIQ automate workspace

安装
ansible-galaxy install manageiq.manageiq_automate
许可证
apache-2.0
下载
3k
拥有者
ManageIQ Open-Source Management Platform