4. Ansible-LegacyRole¶
4.1. Introduction¶
4.2. Ansible-LegacyRole overview¶
4.4. Ansible-LegacyRole procedure¶
4.4.1. Ansible-LegacyRole workflow¶
Workflow details and references
- Register connection information for the targetFrom themenu, register connection information for the target.For more information, see Device list.
- Register operation nameFrom themenu, register an Operation list.For more information, see Operation list.
- **Register Ansible Automation Controller host information (if needed) **From themenu, Register information for the Ansible Automation Controller host.For more information, see Ansible Automation Controller host list.
- Register Interface informationFrom themenu, select Ansible Core, Ansible Automation Controller or Ansible Execution Agent for the execution engine and register connection information for the execution engine serverFor more information, see Interface information.
- Register Execution environment definition template management(If needed)From themenu, Register the template file for the Execution environment definition file (execution-environment.yml) which is used to build the Execution environment by the ansible-builder within the Ansible Execution Agent.For more information, see ansible_execution_environment_definition_template_list and Using the Template file registered to Ansible common ▶ Execution environment definition template ` and :menuselection:"Execution Environment Parameter Definition" Parameter sheet`.Installing ITA registers a template file that allows users to add python module and ansible galaxy collections.
- Register "Execution environment parameter definition" parameter sheet. sheet(If needed)Register Parameters that will be embedded to the execution environment definition file (execution-environment.yml) template file registered in.For more information, see Using the Template file registered to Ansible common ▶ Execution environment definition template ` and :menuselection:"Execution Environment Parameter Definition" Parameter sheet`.Installing ITA registers , thewith the parameters that embeds to the execution environment definition template file (execution-environment.yml) file is registered.
- Register Execution environment management (If needed)Register a link between theand the template file for the execution environment definition file (execution-environment.yml) registered inFor more information, see Execution environment management.Installing ITA registers a link between theand .
- Register Role packageFrom themenu, register a Role package.For more information, see Role package management console.
- **Register Global variables (if needed) **From themenu, register global variables to be used in the Playbook.For more information, see Global variable management.
- **Register Template files (if needed) **From themenu, register template files and template embedded variables to be used in the Playbooks.For more information, see Template management.
- **Register File material (if needed) **From themenu, register file materials and file embedded variables to be used in the Playbooks.For more information, see File management.
- **Register Unmanaged variables (if needed) **From themenu, register extracted variables which will not be displayed in 's .For more information, see Unmanaged target variable list.
- Register Role package to MovementFrom themenu, register a link between the registered Movement and the Role package.For more information, see Movement-Role link.
- Register Multistage variable maximum repetitions(if needed)From theregister maximum repetitions for the Member variable array defined in the Multistage variable arrays.For more information, see Variable nest management.
- Create parameter sheetFrom themenu, create a Parameter sheet which will have data registered to it that can configure settings for the target.For more information, see Parameter sheet creation function.
- Register data to Parameter sheetRegister data to the parameter sheet created in the previous step.For more information, see Parameter sheet creation function.
- Substitute value auto registration settingsFrom themenu, link the Movement variables with the Parameter sheet's item's setting values.For more information, see Substitute value auto registration settings.
- ExecuteFrom themenu, select the desired Movement and Operation and execute them.For more information, see Execute.
- Confirm execution statusFrom themenu,the status of all previously executed operations will be updated in realtime. Users can also monitor error logs and execution logs as well as stop them with an emergency stop.For more information, see Confirm execution status.
- Confirm execution historyFrom themenu, users can check the history of all previously executed operations..For more information, see Execution management.
4.6. Describing Structure code¶
4.6.1. Writing Role packages¶
(Upper directory)
│
├─── site.yml ・・・・・・・・・・・・・・・・・・・・・・・・ (1)
│
├─── hosts ・・・・・・・・・・・・・・・・・・・・・・・・ (2)
│
├─── group_vars ・・・・・・・・・・・・・・・・・・・・・・・・ (3)
│
├─── host_vars ・・・・・・・・・・・・・・・・・・・・・・・・ (4)
│
├─── ITA readme ・・・・・・・・・・・・・・・・・・・・・・・・ (5)
│
└─── roles ・・・・・・・・・・・・・・・・・・・・・・・・ (6)
│
├─ [role name①] ・・・・・・・・・・・・・・・・・・・・・・・・ (7)
│ │
│ ├── readme.md ・・・・・・・・・・・・・・・・・・・・・・・・ (8)
│ │
│ ├── tasks ・・・・・・・・・・・・・・・・・・・・・・・・ (9)
│ │ ├── main.yml
│ │ └── user_files
│ │ └── user.yml
│ │
│ ├── handlers ・・・・・・・・・・・・・・・・・・・・・・・・ (10)
│ │ ├── main.yml
│ │ └── user_files
│ │ └── user.yml
│ │
│ ├── templates ・・・・・・・・・・・・・・・・・・・・・・・・ (11)
│ │ ├── hosts.j2
│ │ └── user_files
│ │ └── user.j2
│ │
│ ├── files ・・・・・・・・・・・・・・・・・・・・・・・・ (12)
│ │ └── sudoers
│ │
│ ├── vars ・・・・・・・・・・・・・・・・・・・・・・・・ (13)
│ │ └─ main.yml
│ │
│ ├── defaults ・・・・・・・・・・・・・・・・・・・・・・・・ (14)
│ │ ├── main.yml
│ │ └── user_files
│ │ └── user.yml
│ │
│ ├── meta ・・・・・・・・・・・・・・・・・・・・・・・・ (15)
│ │ └── main.yml
│ │
│ If there are other directories and files, ITA will not recognize them.
│
└─ [role name②] roles have no specific limits.
Should include
〇 :Required
△ :Optional
|
Handled by ITA |
|
---|---|---|
(1) site.yml (Master Playbook) |
△ |
Created by ITA. Will be overwritten if exists. |
(2) hosts |
△ |
Created by ITA. Will be overwritten if exists. |
(3) group_vars |
△ |
Not handled by ITA. Will be deleted if exists |
(4) host_vars |
△ |
Created by ITA. Will be overwritten if exists. |
(5) ITA readme |
△ |
ITA readme is defined for every role. Error doesn't occur even if the file deosn't exist.
ITA readme character code should be UTF-8 without BOM.
For more information, see "Writing ITAreadme"
|
(6) roles |
〇 |
An Upload error will occur if the roles directory does not exist. |
(7) roles/[role name①] |
〇 |
An Upload error will occur if the role name directory does not exist.
Handles directories (tasks directory included) as role.
Directory hierarchy can be deep.
|
(8) roles/[role name①]/readme.md |
△ |
Not recognized by ITA. |
(9) roles/[role name①]/tasks |
〇 |
tasks directory is required.
playbook character code should be UTF-8 without BOM.
An Upload error will occur if main.yml does not exist.
Can contain other files than main.yml
Can deploy other files than main.yml in the sub-directory.
|
(10) roles/[role name①]/handlers |
△ |
handlers directory is not recognized.
playbook character code should be UTF-8 without BOM.
main.yml is not recognized.
Can contain other files than main.yml
Can deploy files into the sub-directory.
|
(11) roles/[role name①]/templates |
△ |
templates directory is not recognized.
The file character code should be UTF-8 without BOM.
Can deploy files into the sub-directory.
|
(12) roles/[role name①]/files |
△ |
files directory is not recognized.
File or sub-directory is not recognized.
File contents are not recognized.
|
(13) roles/[role name①]/vars |
△ |
vars directory is not recognized.
playbook character code should be UTF-8 without BOM.
File or sub-directory is not recognized.
File contents are not recognized.
|
(14) roles/[role name①]/defaults |
△ |
defaults directory is not recognized.
playbook character code should be UTF-8 without BOM.
main.yml is not recognized.
Can contain other files than main.yml
Can deploy other files than main.yml in the subdirectory.
|
(15) roles/[role name①]/meta |
△ |
meta directory is not recognized.
playbook character code should be UTF-8 without BOM.
File or sub-directory is not recognized.
File contents are not recognized.
|
Master Playbook¶
- Header sectionHeader sections have default values, but users can change them by using's .▼Header section default value
- hosts: all remote_user: "{{ __loginuser__ }}" gather_facts: no become: yes # For winrm connections, "become: yes" is ommited.
- roles sectionRoles from uploaded role packages are executed according to thein .
Points to note when the role name in the role package is set to the directory hierarchy.¶
└── roles
├── parent
│ ├── sample_role1
│ │ ├── defaults
│ │ └── tasks
│ └── sample_role2
│ ├── defaults
│ ├── sample_role3
│ │ ├── defaults
│ │ └── tasks
│ ├── sample_role4
│ │ ├── defaults
│ │ └── tasks
│ └── tasks
├── sample_role5
│ └── defaults
└── sample_role6
├── defaults
└── tasks
- he directory recognized as a role is the directory containing the tasks directory.In this example. There are three directory hierarchies (role names) to be handled by roles.
parent/sample_role1
parent/sample_role2
sample_role6
- Exclude directory hierarchies with multiple tasks directoriesThere are tasks directories in parent/sample_role2/sample_role3 and parent/sample_role2/sample_role4, but parent/sample_role2 has a tasks directories and recognizes them as roles, meaning they are not handaled as a role.
4.6.2. Writing ITAreadme¶
ITA readme file naming convention¶
Role name |
File name |
---|---|
mysql |
ita_readme_mysql.yml |
mysql/install |
ita_readme_mysql%install.yml |
警告
ITA readme format¶
Tip
表 4.27 Variable adoption rule¶ defaults variable definition file
ITA readme
Variable structure destination
Defined
Not defined
Default variable definition file
Not defined
Defined
ITA readme
Defined
Defined
ITA readme
The ITA readme is cut of from the Role package when executed.Variables and specific values written in the ITA readme file will not be given to Ansible.
"ita_readme" use example

図 4.30 Overall image¶
No. |
Case |
---|---|
1 |
Using externally fetched Ansible-LegacyRole without editing it. |
2 |
"ita_readme" role |
3 |
Variable definitions and default values described in the "defaults/main.yml" file. |
4 |
"host_vars" files and "ITA Parameter sheet" |
5 |
Adding variables to “defaults/main.yml” |
6 |
Applying Playbook Length evaluation |
7 |
Applying Playbook Defined evaluation |
- Case 1:Using externally fetched Ansible-LegacyRole without editing itUsers can use Ansible-Legacy Role (roles directory) acquired from anexternal source without modifying it.Therefore, users can put the ita_readme file and/or substitute table in the “roles” directory and assign parameters to the variables used inside the directory.

図 4.31 Case 1 figure¶
- Case 2:"ita_readme" roleThe ita_readme file is used to send variables/variable types to ITA.In other words, they are not used to define specific values (Parameters).ITA will not be able to read any specific values written in them.Please see the other cases below for information on how to assign specific values.

図 4.32 Case 2 figure¶
- Case 3:Variable definitions and default values described in the "defaults/main.yml" fileThe "defaults/main.yml" file stored under "roles" is automatically passed to ansible.The file will be automatically sent as long only if no variables or default values are defined in host_vars.(E.g: "VAR_A:aaa").

図 4.33 Case 3 figure¶
- Case 4:"host_vars" files and "ITA Parameter sheet"Host_vars files are automatically created everytime ITA parameter sheets executes something.

図 4.34 Case 4 figure¶
- Case 5:Adding variables to “defaults/main.yml”In order to add any changes to Ansible-Legacy Role ("roles" directory), users can describe variable names/types in the "ita_readme" file.Users do not have to define any variables in the ita_readme file that are already defined in the "defaults/main.yml" file.If there are different definitions for the same variables in the files, the ones in the "ita_readme" file will be prioritized.※The figure below illustrates that it is possible to add variables by describing a variable(VAR_H) in the ita_readme file

図 4.35 Case 5 figure¶
- Case 6:Applying Playbook Length evaluationDepending on whether a variable has a concrete value or not, it can be used as a conditional branch for length evaluation.For example if "VAR_C:[]" is written in "defaults/main.yml", the length will equal 0 if the operation is executed with no specific value set to "VAR_C".On the other hand, doing the same with a specific value set will have length be <0 (length<0). (E.g.: VAR_X:sss)

図 4.36 Case 6 figure¶
- Case 7:Applying Playbook Defined evaluationDepending on whether a variable has a concrete value or not, it can be used as a conditional branch for defined valuation.For example, first write a definition for the variables "VAR_G" and "VAR_H" in the "ita_readme" file. By doing so, they can be used by ITA parameter sheets.Running an operation without giving a specific value to "VAR_G" while it is not defined in "defaults/main.yml" or "host_vars" will turn "defined" to "false".On the other hand, if the specific value "kkk" is added to "VAR_H", "defined" will turn into "true".

図 4.37 Case 7 figure¶
4.7. Appendix¶
4.7.2. Result data created when executing Ansible¶
Ansible-LegacyRole result data File list¶
File name |
Recorded contents |
Ansible Core |
Ansible Automation Controller |
Ansible Execution Agent |
---|---|---|---|---|
result.txt |
Records Ansible execution result's execution results |
〇 |
||
error.log |
Error output file with Executing.
Ansible-playbbok command standard error output file.
Contents displayed in the Execute confirmation error log.
|
〇 |
〇 |
〇 |
exec.log.org |
xecution log output by Ansible-playbook |
〇 |
〇 |
〇 |
exec.log |
Edited Aexec.log.org
Contents displayed to the Execution confirmation execution log
|
〇 |
〇 |
〇 |
exec_<Execution number>_<group number> |
Divided execution log file
For more information regarding file name conventions, see the execution log in Confirm execution status .
|
〇 |
||
forced.txt |
Text file if stopped with Emergency stop |
〇 |
〇 |
|
user_files |
A directory where files are recorded when some file is output to ITA's original variable "__workflowdir__" in the playbook executed. |
〇 |
〇 |
〇 |
child_exec.log
child_error.log
|
ansible-builder execution log |
〇 |