Ansible search and cut from stdout_lines in variable

44 views
Skip to first unread message

Dbibi Amine

unread,
Dec 16, 2022, 5:07:11 AM12/16/22
to Ansible Project
Hello,

I didnt find a solution to get this line /opt/bea/cfgtoollogs/opatch/opatch2022-12-16_10-44-20AM_1.log",  from stdout_lines

thanks :)

Capture.PNG

stdout_lines": [
            "Programme d'installation des patches temporaires Oracle version 13.9.4.2.8",
            "Copyright (c) 2022, Oracle Corporation. Tous droits réservés.",
            "",
            "",
            "Répertoire de base Oracle       : /opt/bea",
            "Inventaire central : /appli/weblogic/oraInventory",
            "   à partir de           : /opt/bea/oraInst.loc",
            "Version d'OPatch    : 13.9.4.2.8",
            "Version d'OUI       : 13.9.4.0.0",
            "Emplacement du fichier journal : /opt/bea/cfgtoollogs/opatch/opatch2022-12-16_10-44-20AM_1.log",
            "",
            "",
            "OPatch detects the Middleware Home as \"/opt/bea_12.2.1.3.0\"",
            "",
            "",
            "Patches will be rolled back in the following order: ",
            "   32148634",
            "The following patch(es) will be rolled back: 32148634  ",
            "",
            "Arrêtez les instances Oracle exécutées depuis ce répertoire de base ORACLE_HOME sur le système local.",
            "(Répertoire de base Oracle = '/opt/bea')",
            "",
            "",
            "Le système local est-il prêt pour l'application du patch ? [y|n]",
            "Y (auto-answered by -silent)",
            "User Responded with: Y",
            "",
            "Rolling back patch 32148634...",
            "",
            "RollbackSession : annulation (rollback) du patch temporaire '32148634' dans le répertoire de base Oracle '/opt/bea'",
            "",
            "Application d'un patch au composant oracle.wls.core.app.server, 12.2.1.3.0...",
            "RollbackSession : suppression du patch temporaire '32148634' de l'inventaire",
            "Log file location: /opt/bea/cfgtoollogs/opatch/opatch2022-12-16_10-44-20AM_1.log",
            "",
            "OPatch succeeded."
        ]

Rowe, Walter P. (Fed)

unread,
Dec 16, 2022, 8:22:10 AM12/16/22
to ansible...@googlegroups.com

On this page https://www.tailored.cloud/devops/how-to-filter-and-map-lists-in-ansible/

use "select" filter to filter a list and "match" to combine it with reg expressions, like:

"{{ ansible_interfaces | select('match', '^(eth|wlan)[0-9]+') | list }}"


In your case maybe this will work:

- debug:
    msg: "{{ rollbacks.stdout_lines | select('match', '/opt/bea/cfgtoollogs/opatch') | list }}"

Walter

Dbibi Amine

unread,
Dec 19, 2022, 10:00:24 AM12/19/22
to Ansible Project
Résolved :
   link: "{{ rollbackspu.stdout_lines | select('match','Log file location:') | list }}"

thank you Walter 

Reply all
Reply to author
Forward
0 new messages