manageiq.manageiq_automate
manageiq.manageiq_automate
https://galaxy.ansible.com/manageiq/manageiq_automate
manageiq_automate
ロールは、ManageIQ Automate のユーザーが Ansible Playbook を通じて Automate Workspace を変更したり追加したりできるようにします。
このロールには、Automate Workspace を変更するために必要なすべての重作業を行う manageiq_automate
モジュールが含まれています。
要件
ManageIQ は Gaprindashvili 以上でなければなりません。
サンプル Playbook は、このロールの一部としても含まれている manageiq_automate
モジュールを使用しています。
Ansible Tower や Embedded Ansible でこのロールを使う必要がある場合は、Playbook のルートに空の roles
ディレクトリを追加し、その中に以下の内容を持つ requirements.yml
ファイルを含めてください:
---
- source: manageiq.manageiq_automate
version: v0.1.3
ロール変数
自動コミット:
auto_commit
は defaults/main.yml
でデフォルトが True
です。
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 Workspace と通信するために必要な href スラグと 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 Workspace を変更する
hosts: localhost
connection: local
gather_facts: False
vars:
- auto_commit: True
# 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: "state_var を確認する"
manageiq_automate:
workspace: "{{ workspace }}"
state_var_exists:
attribute: "task_id"
- name: "state_var を取得する"
manageiq_automate:
workspace: "{{ workspace }}"
get_state_var:
attribute: "task_id"
- name: "State Var を設定する"
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: "state_vars のリストを取得する"
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: オブジェクトの属性からdecryptする
manageiq_automate:
workspace: "{{ workspace }}"
get_decrypted_attribute:
object: root
attribute: fred
register: decrypted_attribute
- debug: msg=decrypted_attribute
- name: オブジェクトからメソッドパラメータをdecryptする
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
メソッドパラメータを使用してオブジェクト属性を変更し、リトライを変える例です。
- name: メソッドパラメータをオブジェクトに渡す
hosts: localhost
connection: local
vars:
- auto_commit: True
- object: root
- interval: 600
# 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