I run ipa migrate-ds command using Ansible.
When this command is finished I print out the result, which is similar to:
When group: is present in output:
...
"stdout_lines": [
"-----------",
"migrate-ds:",
"-----------",
"Migrated:",
" user: usr1,usr2, usr3, usr4, usr5",
" group: usr1, usr2, usr3, usr4, usr5",
"Failed user:",
" admin: This entry already exists",
...
]
When group: is not present in output:
"stdout_lines": [
"-----------",
"migrate-ds:",
"-----------",
"Migrated:",
"Failed user:",
" admin: This entry already exists",
...
]
I'm only interested in getting the groups under group: after Migrated, because I want to pass these to a script/template file.
It's important to note that sometimes group: is not even present in the stdout_lines, it all depends on the output of the command.
Usually, you get also stdout along with stdout_lines. Without the separators
-----------stdout would be a valid YAMLGet rid of the separators and convert the string to YAML
If you can't remove the separators from the output of the command use the filter regex_replace
gives