Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

OTTER - Capture Logs from block execution and assign to variables ?



  • Hello

    I am looking a way to get catch values from the log of a block execution in order and assign to variables for a second block / module.

    Exemple:
    Otter Orchestration to create VM.
    The name and its IP adress are dynamically created by the ansible script.

    ##AH:UseTextMode
    ##AH:Description Deploiement d'une VM à partird'un template
    set $octet2=100;
    set $octet3=4;
    set $YML=linux.yml;
    set $template=GI-DCS-UBUNTU-20.04.1-20210121
    
    for server ANSIBLE-MASTER
    {
        # Loop
        foreach $VM in @Range(1, 2)
        {
            call ANSIBLE::BM-AnsiblePlayBook
            (
                PLAYBOOK: vmware,
                EXTRAVARS: %(octet2:$octet2,octet3:$octet3,template:$template,annotation:$annotation'),
                YML: $YML,
                Role: NON
            );
        }
    }
    

    The ANSIBLE::BM-Playbook module returns the log:

    PLAY [127.0.0.1] ***************************************************************
    TASK [Definition du nom de la VM et de son IP] *********************************
    changed: [127.0.0.1]
    TASK [set_fact] ****************************************************************
    ok: [127.0.0.1]
    TASK [set_fact] ****************************************************************
    ok: [127.0.0.1]
    TASK [set_fact] ****************************************************************
    ok: [127.0.0.1]
    TASK [set_fact] ****************************************************************
    ok: [127.0.0.1]
    TASK [set_fact] ****************************************************************
    ok: [127.0.0.1]
    TASK [Creation de la VM VM004011 avec IP 10.100.4.11] **************************
    changed: [127.0.0.1]
    PLAY RECAP *********************************************************************
    127.0.0.1                  : ok=7    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
    

    Is it possible to get the VM Name (VM004001) and the IP (10.100.4.11) to pass them to some module in the same Otter Orchestration Job ?

    call ANSIBLE::BM-AnsiblePlayBook
    call SomeOtterModule ($VM,$IP)
    

    Thanks
    Philippe


  • inedo-engineer

    @philippe-camelio_3885 said in OTTER - Capture Logs from block execution and assign to variables ?:

    The ANSIBLE::BM-Playbook module returns the log:

    By this, I assume you mean, writes to the Otter execution log, either via Log-Information or an execute process? You might have to do this via PSExec, write the logs to text, and parse it out that way using a regular expression...

    At this time, there's no way to read entries from the log during a live execution.

    Best,
    Alana



  • OK
    I understand I have to manage this at the script level (SHExec ou PSExec).
    I hoped I could do it inside Otter Script, something like :

    SHExec >>
    Some command
    >>
    (
      OutputLog: $MyOutput
    );
    

    Thanks you @atripp


  • inedo-engineer

    @philippe-camelio_3885 oh i see; you mean, capture the output of a process or script execution into a variable or something.

    Definitely something to consider as an enhancement, I think. That wouldnt' be too bad (though the variable could get huge, and rutnime variables raen't realy designed for large amounts of text like that)


Log in to reply
 

Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation