ibmi_script_execute – Execute a cl/sql script file

Synopsis

  • The ibmi_script_execute module execute a cl/sql script file on a remote ibm i node.

  • Only support cl/sql script file by now.

  • For sql script, use RUNSQLSTM to process.

  • For non-cl/sql script, use the script plugin instead.

Parameters

asp_group

Specifies the name of the auxiliary storage pool (ASP) group to set for the current thread.

The ASP group name is the name of the primary ASP device within the ASP group.

required: false
type: str
default: *SYSBAS
become_user

The name of the user profile that the IBM i task will run under.

Use this option to set a user with desired privileges to run the task.

required: false
type: str
become_user_password

Use this option to set the password of the user specified in become_user.

required: false
type: str
parameters

The parameters that RUNSQLSTM command will take. All other parameters need to be specified here.

The default values of parameters for RUNSQLSTM will be taken if not specified.

Only works for sql script.

required: false
type: str
default:
severity_level

When run sql script, specifies whether the processing is successful, based on the severity of the messages generated by the processing of the SQL statements.

If errors that are greater than the value specified for this parameter occur during processing, no more statements are run and the statements are rolled back if they are running under commitmentcontrol.

Only works for sql script.

required: false
type: int
default: 10
src

Script file path on the remote ibm i node.

The path can be absolute or relative.

required: True
type: path
type

Specify the script file type.

Only support CL or SQL script by now.

required: True
type: str
choices: CL, SQL

Examples

- name: Execute test.cl on a remote IBM i node with become user.
  ibm.power_ibmi.ibmi_script_execute:
    src: '/home/test.cl'
    type: 'CL'
    become_user: 'USER1'
    become_user_password: 'yourpassword'

- name: Execute testsql.sql on a remote IBM i node.
  ibm.power_ibmi.ibmi_script_execute:
    src: '/home/testsql.sql'
    type: 'SQL'
    severity_level: 40
    parameters: 'DATFMT(*USA)'

Notes

Note

For cl script, the command supports line breaks.

When a command ends, add ‘:’ at the end of each command or empty the next line.

Otherwise program will not consider it is the end of a command.

Return Values

delta
The execution delta time.
returned: always
type: str
sample: 0:00:00.307534
stdout
The standard output.
returned: always
type: str
sample: Successfully execute script file /home/test.cl
stderr
The standard error.
returned: always
type: str
sample: Execute command %s failed.
rc
The action return code. 0 means success.
returned: always
type: int
sample: 255
stdout_lines
The standard output split in lines.
returned: always
type: list
sample:
["Successfully execute script file /home/test.cl"]
stderr_lines
The standard error split in lines.
returned: always
type: list
sample:
["Execute command %s failed."]
job_log
The IBM i job log of the task executed.
returned: always
type: list
sample:
[{"FROM_INSTRUCTION": "149", "FROM_LIBRARY": "QSHELL", "FROM_MODULE": "QZSHRUNC", "FROM_PROCEDURE": "main", "FROM_PROGRAM": "QZSHRUNC", "FROM_USER": "TESTER", "MESSAGE_FILE": "QZSHMSGF", "MESSAGE_ID": "QSH0005", "MESSAGE_LIBRARY": "QSHELL", "MESSAGE_SECOND_LEVEL_TEXT": "", "MESSAGE_SUBTYPE": "", "MESSAGE_TEXT": "Command ended normally with exit status 0.", "MESSAGE_TIMESTAMP": "2020-05-27-16.17.43.738571", "MESSAGE_TYPE": "COMPLETION", "ORDINAL_POSITION": "13", "SEVERITY": "0", "TO_INSTRUCTION": "5829", "TO_LIBRARY": "QXMLSERV", "TO_MODULE": "PLUGILE", "TO_PROCEDURE": "ILECMDEXC", "TO_PROGRAM": "XMLSTOREDP"}]