1. Ansible common

1.1. Introduction

This document aims to explain how to use the Ansible driver's common functions.

1.2. Ansible driver overview

This document explains the functions of Ansible Core, Ansible Automation Controller, Ansible driver and the Ansible Execution Agent.

1.2.1. Ansible Core

The Ansible Core is an PF construction automation tool that makes application/system deployment operations for multiple construction targets easier.
Ansible Core uses Playbook, YAML type text files, which contains routine tasks that can be run by Ansible Core.
The "Tasks" are linked to processing programs called Modules and can control different devices.
For more information regarding Ansible Core, see the official Ansible manuals.

1.2.2. Ansible Automation Controller

The Ansible Automation Controller is a management platform that comes with functions such as controling Ansible access, scheduling jobs and visualizing tasks.
It can be used to create job templates that contains Projects, Inventories and Authentication information that can be run with Ansible.
By combining multiple "Job templates", the user can create a "Workflow template", which can be used to express more variegated task flows.
For more information regarding Ansible Automation Controller, see the official Ansible Automation Controller manuals.
For information regarding ITA compatible Ansible Automation Controller versions, see Ansible Automation Platform.
Note that all notations regarding the newest version might not work.

1.2.3. Ansible Execution Agent

The Ansible Execution Agent is a Server for executing Ansible constructed seperately from ITA.
Users can construct an environment(Container) with Ansible-builder and run Playbook through an execution environment(Container) with Ansible runner.
Ansible Execution Agents must be prepared per Workspace.
By preparing multiple Ansible Execution Agents for the same Workspace, users can use a redundant architecture.
Ansible Execution Agent architecture diagram

1.2.4. Ansible driver

The Ansible driver uses the ITA functions to automatically run Playbook processes to Servers, Storage or Network devices registered to ITA through either Ansible Core, Ansible Automation Controller or Ansible Execution Agent.
Exastro overview
The Ansible driver comes with the following 3 modes.
They each comes with their own strengths, so make sure to use the one that suits the situation best.
  1. Legacy mode
    Uses Ansible's standard functions to input settings to the host.
    The Legacy mode registers construction code as single YAML files and creates operation patterns using them.
    Often used for configuring environments for Server, Storage and Network devices.
  2. Legacy Role mode
    Similar to the Legacy mode, this mode also uses Ansible's standard functions to input settings to the host.
    The Legacy Role mode registers consdtruction code as packages and creates operation patterns by combining them with Roles.
    Often used by using Role packages provided by product and other departments to install products and construct environments.
  3. Pioneer mode
    Adds original modules to Ansible and allows users to input settings in an interactive format.
    Support Server, Storage and Network devices that can be logged in with Telnet or SSH. We recommend that the user has adequate IT skills, since this mode works directly with the target host.

1.3. Handling variables with Ansible driver

In the Ansible driver, the specific values within the variables in the Playbook can be set from ITA.

1.3.1. Variable types

The variables within Playbooks that can be handled as ITA variables are the following 7 types.

Normal

Variable that can define 1 specific value for variable names.

e.g.) Example within Playbook
# Ansible-LegacyRole variable definition example
user: user1

# Playbook example
- name: Create user
  user:
    name: "{{ user }}"

Multiple specific value variables

Variable that can specify multiple specific values for variable names.

e.g.) Example within Playbook
# Ansible-LegacyRole variable definition example
users:
  - user1
  - user2

# Playbook example
- name: Create user
  user:
    name: "{{ item }}"
  with_items: "{{ users }}"

Multistage variables

Variables in hierarchy.
Multiple variables can only be used in Ansible-LegacyRole.

e.g.) Example within Playbook
# Ansible-LegacyRole variable definition example
users:
  - name: user3
    groups: root
  - name: user4
    groups: root

# Playbook example
- name: Create user
  user:
    name: "{{ item.name }}"
  with_items: "{{ users }}"

Global variables

Variables registered from Ansible common ▶ Global variable list.
e.g.) Example within Playbook
- command: echo {{ GBL_user }}

Template embedded variables

Variables registered from Ansible common ▶ Template list.
e.g.) Example within Playbook
- template: src={{ TPF_SAMPLE }} dest=/tmp/SAMPLE.txt

File embedded variables

Variables registered from Ansible common ▶ File list.
e.g.) Example within Playbook
- copy: src={{ CPF_SAMPLE }} dest=/tmp/SAMPLE.txt

ITA original variables

Variables defined by ITA.
Device list
The following items in Basic console ▶ Device list can be handled as variables.

Item name

Variable name

Host name

__inventory_hostname__

DNS host name

__dnshostname__

IP address

__ipaddress__

Protocol

__loginprotocol__

Login user ID

__loginuser__

Login password

__loginpassword__

Tip

The "__" before and after the variable names are created by 2 underscores.
The Ansible common ▶ Device list ` items can be used as variables if set . If the items are not set, the operations run in :menuselection:`Mode ▶ Execute will display an error.
Movement ID
The Mode ▶ Movement list's :menuselection:`Movement ID`can be selected as variables

Item name

Variable name

Movement ID

__movement_id__

Operation
The Basic console ▶ Operation list operations that are selected during execution can be selected as variables.

Item name

Variable name

Operation

__operation__

Setting value: "YYYY/MM/DD HH:MM" _ "Operation ID" : "Operation name"
YYYY/MM/DD HH:MM: Basic console ▶ Operation list's Scheduled execution date/time
Operation ID: Basic console ▶ Operation list's Operation ID
Operation name: Basic console ▶ Operation list's Operation name

Operation instance ID
The Mode ▶ Operation status confirmation's Operation No. generated when executed can be selected as variables.

Item name

Variable name

Operation instance ID

__execution_no__

Conductor instance ID
The Conductor ▶ Conductor confirmation's Conductor instance ID can be handled as variables when run.
For more information regarding the Conductor function, see "Conductor

Item name

Variable name

Conductor instance ID

__conductor_id__

__conductor_id__ can be handled as a variable when executing Conductor.
If Mode ▶ Execute is used, the operation will end in an error.

1.3.2. Extracting variables and registering specific variables

Variable extraction files

If the variable extraction target is a registered file, the variables can be extracted from the registered information.

Tip

〇:Extraction target ×:Not extraction target
Playbook file extractable variable types and their format
The following table displays what variable types can be extracted from the Ansible-Legacy ▶ Playbook file collection's Playbook files and their format.

Tip

Notes regarding variable names
△:Half-width space
vvv: Half-width characters and underscore within 255 bytes ( _ )
xxx: Half-width characters and underscore within 251 bytes ( _ )
Interactive file extractable variable types and their format
The following table displays what variable types can be extracted from the Ansible-Pioneer ▶ Interactive file collection's Interactive files.

Tip

Notes regarding variable names
△:Half-width space
vvv: Half-width characters and underscore within 255 bytes ( _ )
xxx: Half-width characters and underscore within 251 bytes ( _ )
Local package file (ZIP format) extractable variable types and their format.
The following table displays what variable types can be extracted from the Ansible-LegacyRole ▶ Role package management's :menuselection:`Role package file (ZIP format) `.

Tip

〇:Variable definition extraction target ×:Not variable definition extraction target

Tip

Notes regarding variable names
△:Half-width space
vvv: Half-width characters and underscore within 255 bytes ( _ )
xxx: Half-width characters and underscore within 251 bytes ( _ )
Member variables can use all ascii characters (0x20~0x7e) except for the 7 characters written below.
" . [ ] ' \ :
Note that some characters can not be used at the start of the variable's names unless they are in quoatation marks.
For more information, see the official Ansible manuals' YAML and Syntax section.
Inventory file options and header section parameter value extractable variable types and their format.
The following table displays what variables can be extraccted with the Parameter values found in Ansible-Common ▶ Device list's Inventory file option and Ansible mode ▶ Movement list's Header section

Tip

Notes regarding variable names
△:Half-width space
vvv: Half-width characters and underscore within 255 bytes ( _ )

Specific values for variables

Ansible-Legacy
The specific values of the extracted variables are set by setting specific values to the items on the parameter sheet and tying them to each variable in Ansible-Legacy ▶ Substitute value automatic registration settings.
They are output to the host variable file when the operation is executed.
The following diagram illustrates the specific value's relationships through Ansible-Legacy ▶ Substitute value management in the host's variable file's variables from when the operation is executed to when they are output.
For more information regarding Parameter sheets, see ""Parameter sheet creation function".
Variable's specific values in Ansible-Legacy host variable files

図 1.60 Variable's specific values in Ansible-Legacy host variable files

① Variables are extracted from one of the variable extractable files in "Variable extraction files" which makes them selectable in Ansible-Legacy ▶ Substitute value automatic registration settings.
② Register specific values for the variable linked to the parameter sheet item.
③ Register a link between the parameter sheet item and the variable in Ansible-Legacy ▶ Substitute value automatic registration settings.
④ Executing the operation displays the parameter sheet item and variable information linked in Ansible-Legacy ▶ Substitute value automatic registration settings to Ansible-Legacy ▶ Substitute value management and outputs it to the host variable file.
Ansible-Pioneer
The specific values of the extracted variables are set by setting specific values to the items on the parameter sheet and tying them to each variable in Ansible-Pioneer ▶ Substitute value automatic registration settings.
They are output to the host variable file when the operation is executed.
The following diagram illustrates the specific value's relationships through Ansible-Pioneer ▶ Substitute value management in the host's variable file's variables from when the operation is executed to when they are output.
Variable's specific values in Ansible-Pioneer host variable files

図 1.61 Variable's specific values in Ansible-Pioneer host variable files

① Variables are extracted from one of the variable extractable files in "Variable extraction files" which makes them selectable in Ansible-Pioneer ▶ Substitute value automatic registration settings.
② Register specific values for the variable linked to the parameter sheet item.
③ Register a link between the parameter sheet item and the variable in Ansible-Pioneer ▶ Substitute value automatic registration settings.
④ Executing the operation displays the parameter sheet item and variable information linked in Ansible-Pioneer ▶ Substitute value automatic registration settings to Ansible-Pioneer ▶ Substitute value management and outputs it to the host variable file.
Ansible-LegacyRole
The specific values of the extracted variables are set by setting specific values to the items on the parameter sheet and tying them to each variable in Ansible-LegacyRole ▶ Substitute value automatic registration settings.
They are output to the host variable file when the operation is executed.
The following diagram illustrates the specific value's relationships through Ansible-LegacyRole ▶ Substitute value management in the host's variable file's variables from when the operation is executed to when they are output.
Variable's specific values in Ansible-LegacyRole host variable files

図 1.62 Variable's specific values in Ansible-LegacyRole host variable files

① Variables are extracted from one of the variable extractable files in "Variable extraction files" which makes them selectable in Ansible-LegacyRole ▶ Substitute value automatic registration settings.
② Register specific values for the variable linked to the parameter sheet item.
③ Register a link between the parameter sheet item and the variable in Ansible-LegacyRole ▶ Substitute value automatic registration settings.
④ Executing the operation displays the parameter sheet item and variable information linked in Ansible-LegacyRole ▶ Substitute value automatic registration settings to Ansible-LegacyRole ▶ Substitute value management and outputs it to the host variable file.
The specific values for the variables registered in Ansible-LegacyRole ▶ Substitute value automatic registration settings are output to the Host variable definition file, (host_vars) .
The order in which specific values are handled are as follows.
  1. Host variable definition file value
  2. values defined in defaults variable definition file

1.4. Ansible common menu

This section explains the Ansible common menus and their configurations.

1.6. Appendix

1.6.1. Using the Template file registered to Ansible common ▶ Execution environment definition template ` and :menuselection:"Execution Environment Parameter Definition" Parameter sheet`

ITAをインストールすると、実行環境定義テンプレート管理パラメータシート「実行環境パラメータ定義」 にpythonモジュールやansible galaxyコレクションが追加できるテンプレートファイルとパラメータ値が登録されます。
  1. Ansible共通 ▶ 実行環境定義テンプレート管理 に登録するテンプレートファイルの仕様
    ファイルの形式は「Jinjer2型式」です。
    ファイルの書式は、ansible-biulderで使用する定義ファイル「execution-environment.yml」に準じます。詳細は、ansible-biulderのマニュアルを参照して下さい。
  2. ITAインストール時に登録される パラメータシート「実行環境パラメータ定義」 の項目一覧は以下のとおりです。
    パラメータシート「実行環境パラメータ定義」
    表 1.110 パラメータシート「実行環境パラメータ定義」

    項目

    説明

    入力必須

    入力方法

    制約事項

    execution_environment_name

    レコードの名称を入力します。

    手動入力

    最大長255バイト

    python_requirements_file

    実行環境(コンテナ)にpipコマンドで追加インストールをしたいPythonパッケージを列挙したファイルを入力します。

    ファイル選択

    最大サイズ 100Mバイト 尚、空ファイルを入力しないで下さい。ansible-builder実行時にエラーになります。

    galaxy_requirements_file

    実行環境(コンテナ)にansible-galaxyで追加インストールをしたいコレクションを列挙したファイルを入力します。

    ファイル選択

    最大サイズ 100Mバイト 尚、空ファイルを入力しないで下さい。ansible-builder実行時にエラーになります。

    bindep_file

    実行環境(コンテナ)にdnfコマンドで追加インストールをしたいLinuxモジュールを列挙したファイルを入力します。

    ファイル選択

    最大サイズ 100Mバイト 尚、空ファイルを入力しないで下さい。ansible-builder実行時にエラーになります。

    ansible_runner

    「ansible_runner」を入力します。

    手動入力

    最大長255バイト

    image

    実行環境(コンテナ)のベースイメージを入力します。 ITA Ver2.5.1では、以下の2個のベースイメージについて動作確認がとれています。

    • Redhat有償版のベースイメージの場合
      registry.redhat.io/ansible-automation-platform-24/ee-supported-rhel9:latest
    • Redhat無償版のベースイメージの場合
      registry.access.redhat.com/ubi9/ubi-init:latest

    手動入力

    最大長255バイト

    package_manager_path

    パッケージ管理コマンドのパスを入力します。

    • Redhat有償版のベースイメージの場合
      /usr/bin/microdnf
    • Redhat無償版のベースイメージの場合
      /usr/bin/dnf

    手動入力

    最大長255バイト

  3. パラメータシート 「実行環境パラメータ定義」 を新規作成したり更新する場合の注意事項
    パラメータシート 「実行環境パラメータ定義」 を新規作成したり更新する場合の注意事項について以下に列挙します。
    1. パラメータシート名(rest)は、先頭が「execution_environment_parameter_definition_sheet」で始まる名称にして下さい。
    2. 作成対象は、データシートを選択して下さい。
    3. パラメータシートの項目に以下の項目を含んで下さい。

      項目

      説明

      Rest API用項目名

      execution_environment_name

      入力値

      レコード名

      項目タイプ

      文字列(単一行)

      最大バイト数

      255

    4. パラメータシート名を入力します。

      Tip

      Ansible共通 ▶ 実行環境管理実行環境定義名 に表示される情報について補足
      実行環境定義名 には下記情報が表示されます。
        ④パラメータシート名/③レコード名「Rest API用項目名:execution_environment_name」
    5. Ansible共通 ▶ 実行環境定義テンプレート管理 に登録したテンプレートファイル内の変数と同名の項目を容易して下さい。
      パラメータシートの項目名を変数名、設定値を変数値として、テンプレートファイルに埋め込みます。
      実行環境定義テンプレート管理で使用するテンプレートファイルと実行環境パラメータ定義で使用するパラメータシートの関連図
      実行環境定義テンプレート管理で使用するテンプレートファイルと実行環境パラメータ定義で使用するパラメータシートの関連図

1.6.2. BackYard contents

Ansible Automation Controller data synchronization

Fetches resources registered to Ansible Automation Controller if the Execution engine in Ansible common ▶ Interface information is set to "Ansible Automation Controller".
表 1.111 Resources fetched from Ansible Automation Controller

Resource

Application

Organization name

Used with the Organization name list selection in Ansible common ▶ Interface information.
Organizations can be seen by users who input the Ansible common ▶ Interface information's Authentication token.

Instance group

Used with the Instance group list selection in Ansible common ▶ Device list.
Instance groups can be seen by organizations selected in Ansible common ▶ Interface information's Organization name.

Execution environment

Used with the Execution environment list selection in Ansible mode ▶ Movement list.
Execution envrionments can be seen by organizations selected in Ansible common ▶ Interface information's Organization name.

1.6.3. Inventory files created by ITA.

This section explains inventory files created by ITA.
The inventory files created by ITA are as following.
all:
  children:
    hostgroups:
      hosts:
        Inventory_host:
          Inventory_host_parameters:
          Inventory_host_option_parameters:
Inventory_host has Ansible common ▶ Device list's Host name configured to it.
Inventory_host_option_parameters has Ansible common ▶ Device list's Inventory file additional option configured to it.
The parameters configured to Inventory_host_parameters are as following.
If the setting value items have empty parameters, they will not be configured to Inventory_host_parameters
表 1.112 Inventory_host_parameters parameter list

Parameter name

Ansible common ▶ Device list's Authentication method

Setting value

Certificate authentic| action |

(winrm) |

Password authentication

Key authentication

(No passphrase)

Key authentication

(With passphrase)

Key authentication

(Key changed)

Password authentication Authentication (winrm)

ansible_host

〇 | Ansible common ▶ Device list's DNS host or DNS host IP address.
Changes depending on the contents selected in Mode ▶ Movement list's :menuselection:`host specificatio
n format`.

ansible_user

Ansible common ▶ Device list's :menuselection:` login user`

ansible_password

Ansible common ▶ Device list's login password

ansible_ssh_private_key_file

Ansible common ▶ Device list's ssh secret key file

ansible_ssh_extra_args

Ansible common ▶ Device list's connection option

ansible_connection:

〇 | winrm

ansible_port

〇 | Ansible common ▶ Device list's WinRM connection information ▶ Port number

ansible_winrm_ca_trust_path

〇 | Ansible common ▶ Device list's WinRM connection information ▶ winrm public key file

ansible_winrm_cert_key_pem

〇 | Ansible common ▶ Device list's ' WinRM connection information ▶ winrm secret key file

Tip

〇: Setting target

1.6.4. Option parameter list

Ansible共通 ▶ インターフェース情報各モード ▶ Movement一覧オプションパラメータ について説明します。
ITAでは、以下の優先順位でオプションパラメータを設定します。単一の値しか許容していないパラメータを複数定義した場合、 各モード ▶ Movement一覧オプションパラメータ が有効になります。
  1. 各モード ▶ Movement一覧オプションパラメータ
  2. Ansible共通 ▶ インターフェース情報オプションパラメータ
Ansible共通 ▶ インターフェース情報実行エンジン が「Ansible Core」と「Ansible Execution Agent」の場合
  ansible-playbookコマンドのオプションパラメータを入力します。
  ansible-playbookコマンドのオプションパラメータの仕様については、以下のコマンドを実行して表示されたヘルプを参照してください。
ansible-playbook -h

Ansible共通 ▶ インターフェース情報実行エンジン が「Ansible Automation Controller」の場合に
  入力可能なオプションパラメータは以下のとおりです。

表 1.113 Ansible Automation Controllerの場合に指定可能なオプションパラメータ一覧

オプションパラメータ

指定方法

Ansible Automation Controllerの設定箇所

備考

-v
--verbose
-v
-vv
-vvv
-vvvv
-vvvvv
--verbose

テンプレート詳細 に v の数が設定される。

・vの合計値を適用
・--verboseは、-vと同様
例:--verbose -vvv の場合、-vvvvと同様
・vを6以上指定した場合 、vは5の指定となる
-f
--forks
-f FORKS
--forks=FORKS

テンプレートフォーク にFORKSの値が設定される。

・FORKSには数値を指定
・複数定義した場合、最後に定義したパラメータが有効
例:-f 1-forks=10の場合、--forks=10が有効となる
・数値以外が指定された場合、エラーとなる
-l
--limit
-l SUBSET
--limit=SUBSET

テンプレート制限 にSUBMITの値が設定される。

・SUBSET:機器一覧にあるホスト名
・複数定義した場合、最後に定義したパラメータが有効
-e
--extra-vars
-e EXTRA_VARS
--extra-vars=EXTRA_VARS

テンプレート追加変数 にEXTRA_VARSの値が設定される。

・EXTRA_VARS:変数名、具体値をjson形式またはyaml形式
e.g.) json形式の場合
 -extra-vars={"VAR_1":"directory"}
e.g.) yaml形式の場合
 -extra-vars=VAR_1:directory
・複数定義した場合、最後に定義したパラメータが有効
-t
--tags
-t TAGS
--tags=TAGS

テンプレートジョブタグ にTAGSの値が設定される。

・TAGS:タグ名
・複数個のパラメータを許容
-b
--become
-b
--become

テンプレート権限昇格の有効化 がチェックされる。

・少なくとも1つ指定すればパラメータが有効

-D
--diff
-D
--diff

テンプレート変更 の表示が有効化される。

・少なくとも1つ指定すればパラメータが有効

--skip-tags

--skip-tags=SKIP_TAGS

テンプレートスキップタグ にSKIP_TAGSの値が設定される。

・SKIP_TAGS:スキップタグ名
・複数個のパラメータを許容

--start-at-task

--start-at-task=START_AT_TASK

※Ansible Automation ControllerのWebUI には--start-at-taskの表示はありません。
ansible-playbookコマンドの--start-at-taskと同様の扱いになります。

・複数定義した場合、最後に定義したパラメータが有効

-ufc
--use _fact_cache
-ufc
--use_fact_cache

テンプレートファクトキャッシュの有効化 がチェックされる。

・少なくとも1つ指定すればパラメータが有効

-as
--allow_simultaneous
-as
--allow_simultaneous

テンプレート同時実行ジョブの有効化 がチェックされる。

・少なくとも1つ指定すればパラメータが有効

-jsc
--jobslice_count
-jsc ジョブスライス数
--job_slice_count=ジョブスライス数

テンプレートジョブスライス数 にジョブスライス数の値が設定される。

・ジョブスライス数には数値を指定
・複数定義した場合、最後に定義したパラメータが有効
※Ansible Automation Controllerのオプションパラメータの仕様については、Ansible Automation Controller公式マニュアルのユーザガイドのジョブテンプレートを参照してください。

1.6.5. Data resources deleted when executed

Ansible共通 ▶ インターフェース情報実行時データ削除 で「true」を選択した場合に、削除されるデータリソースは以下のとおりです。

Ansible共通 ▶ インターフェース情報実行エンジン が「Ansible Automation Controller」の場合

表 1.114 実行時データ削除で削除されるデータリソース一覧(Ansible Automation Controller側)

データリソース

リソースタイプ

備考

ITA作業用ディレクトリ

/var/lib/exastro/ita_<区分>_executions_作業番号

ディレクトリ

SCM管理ディレクトリ

/var/lib/awx/projects/ita_<区分>_executions_作業番号

ディレクトリ

※プロジェクトリソースの削除により削除される

インベントリ

リソース名: ita_<区分>_executions_inventory_作業番号_通番

リソース

認証情報

リソース名: ita_<区分>_executions_credential_作業番号_通番

      ita_<区分>_executions_vault_credential_作業番号

      ita_<区分>_executions_git_credential_作業番号

リソース

プロジェクト

リソース名: ita_<区分>_executions_project_作業番号

リソース

ジョブテンプレート

リソース名: ita_<区分>_executions_jobtpl_作業番号_通番

リソース

ワークフロージョブテンプレート

リソース名: ita_<区分>_executions_workflowtpl_作業番号

リソース

ジョブ

リソース名: Job番号—ita_<区分>_executions_workflowtpl_作業番号

      Job番号—ita_<区分>_executions_jobtpl_作業番号

リソース

注釈

<区分>: 作業実行したモード
     legacy: legacy
     legacy role: legacy_role
     pioneer: pioneer
表 1.115 実行時データ削除で削除されるデータリソース一覧(ITA側)

データリソース

リソースタイプ

備考

Git リポジトリ

/tmp/git_repositories/<区分>_作業番号

Gitリポジトリ

ディレクトリごと削除

実行時データ削除 の 設定値に関係なく削除される。

Ansible共通 ▶ インターフェース情報実行エンジン が「Ansible Execution Agent」の場合

表 1.116 実行時データ削除で削除されるデータリソース一覧(Ansible Execution Agent側)

データリソース

リソースタイプ

備考

ITA作業用ディレクトリ

<storage>/<org>/<ws>/driver/ag_ansible_execution/<区分>/作業番号

<storage>/<org>/<ws>/ag_ansible_execution/status

ディレクトリ

注釈

<storage>: Ansible Execution Agentインストール時にSpecify full path for the data storage locationで設定したバス
<org>:Ansible Execution Agentインストール時にInput ORGANIZATION_ID.で設定したORGANIZATION ID
<ws>:Ansible Execution Agentインストール時にInput WORKSPACE_ID.で設定したWORKSPACE ID

1.6.6. Using ITA original variables in Ansible Automation Controller