I have a task
- name: DELEGATED ADMIN ACCOUNTS - check, get and send to the file domain.list
shell: /opt/zimbra/bin/zmprov -l gaaa -v zimbraIsDelegatedAdminAccount
and after this task I got output
changed: [Shrrah] => {
"changed": true,
"cmd": [
"sh",
"/home/information_domain.sh"
],
"delta": "0:00:02.495922",
"end": "2022-03-29 10:25:16.936051",
"invocation": {
"module_args": {
"_raw_params": "sh /home/information_domain.sh",
"_uses_shell": false,
"argv": null,
"chdir": null,
"creates": null,
"executable": null,
"removes": null,
"stdin": null,
"stdin_add_newline": true,
"strip_empty_ends": true,
"warn": false
}
},
"msg": "",
"rc": 0,
"start": "2022-03-29 10:25:14.440129",
"stderr": "",
"stderr_lines": [],
"stdout": "# name [email protected]\nzimbraIsDelegatedAdminAccount: FALSE\n\n# name [email protected]\n\n# name [email protected]\nzimbraIsDelegatedAdminAccount: TRUE\n\n# name [email protected]",
"stdout_lines": [
"# name [email protected]",
"zimbraIsDelegatedAdminAccount: FALSE",
"",
"# name [email protected]",
"",
"# name [email protected]",
"zimbraIsDelegatedAdminAccount: TRUE",
"",
"# name [email protected]"
]
}
I need to get data with n# name [email protected]\nzimbraIsDelegatedAdminAccount: TRUE from "stdout" or from "stdout_lines" in format:
[email protected] zimbraIsDelegatedAdminAccount: TRUE
or
[email protected]
zimbraIsDelegatedAdminAccount: TRUE
and send it to the file.txt. Number of lines can be different (one o more users with domain).
I have no idea how I can do this, is this possible? If you know could you please help with advice? Thank you!
You may have a look into
debug– Print statements during execution, Using Variables and Return Values.resulting into an output only of
and if Ansible Callback plugin is configured to YAML instead of JSON.
To get lines containing certain strings only you may Loop over the list based on a Condition
resulting into an output of
Further Documenation
If you like to have the line before included, you could use an approach like
resulting into an output of
Further Documentation
Since you are using the
shellmodule, you could use also an approach likeand gather only result lines which are
truean the line before.Further Q&A
grepa file, but show several surrounding lines?Regarding
you may have a look into