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 3 - Variable at environnement level not found



  • Hello
    I have a small problem.
    If a variable is assigned at the environment level, it is not available for the Plan
    If the variable is moved at the Role level, the plan is working fine.

    • Otter 3.0.5 -

    Test Case:

    • Environment : INTEGRATION
    • Role: SQL
    • Variable:
    {
      "SQLInstanceParams": "%(BOFINT: %(RAM: 2048, StaticPorts: @(1451, 5022)))"
    }
    
    • Otter Plan: SQL-000-PrepDeploy
    ##AH:UseTextMode
    for role SQL
    {
        # Loop
        foreach $SQLInstance in @SQLInstances
        {
            Log-Debug $SQLInstance;
            # SQL - Firewall - Gestion des ports
            set @StaticPorts = %SQLInstanceParams[$SQLInstance].StaticPorts;
    
            # Loop
            foreach $Port in @StaticPorts
            {
                set $Name = FW-SQL-${SQLInstance}-${Port};
                {
                    Firewall::Ensure-NetFirewallRule
                    (
                        Name: $Name,
                        Profiles: "Domain,Private",
                        Port: $Port,
                        Protocol: TCP,
                        Inbound: true,
                        Allow: true,
                        Exists: true
                    );
                }
            }
        }
    }
    

    When the variable %SQLInstanceParams is defined in the Environnement INTEGRATION, I have this error msg:

    ....
    DEBUG: 2021-04-24 16:08:55Z - Beginning execution run...
    DEBUG: 2021-04-24 16:08:55Z - Looking for firewall rule "FW-SQL-Browser-1434"...
    DEBUG: 2021-04-24 16:08:55Z - Creating new "FW-SQL-Browser-1434" firewall rule...
    DEBUG: 2021-04-24 16:08:55Z - BOFINT
    ERROR: 2021-04-24 16:08:55Z - Could not resolve variable %SQLInstanceParams.
    ERROR: 2021-04-24 16:08:55Z - Execution run failed.
    ...
    

    whereas if the variable %SQLInstanceParams is defined in the role SQL, it is working fine

    DEBUG: 2021-04-24 16:09:58Z - Beginning execution run...
    DEBUG: 2021-04-24 16:09:58Z - Looking for firewall rule "FW-SQL-Browser-1434"...
    DEBUG: 2021-04-24 16:09:58Z - Deleting existing "FW-SQL-Browser-1434" firewall rule...
    DEBUG: 2021-04-24 16:09:58Z - Creating new "FW-SQL-Browser-1434" firewall rule...
    DEBUG: 2021-04-24 16:09:58Z - BOFINT
    DEBUG: 2021-04-24 16:09:58Z - Looking for firewall rule "FW-SQL-BOFINT-1451"...
    DEBUG: 2021-04-24 16:09:58Z - Creating new "FW-SQL-BOFINT-1451" firewall rule...
    DEBUG: 2021-04-24 16:09:58Z - Looking for firewall rule "FW-SQL-BOFINT-5022"...
    DEBUG: 2021-04-24 16:09:58Z - Deleting existing "FW-SQL-BOFINT-5022" firewall rule...
    DEBUG: 2021-04-24 16:09:58Z - Creating new "FW-SQL-BOFINT-5022" firewall rule...
    INFO : 2021-04-24 16:09:58Z - Execution run succeeded.
    

  • inedo-engineer

    Hmmm... I did a quick test for environment-scoped variable resolution, and it seems to work fine for me, but it seems like it can get a bit complex with nested environments and multiple so there might be a bug

    Is "INTEGRATION" a nested environment? How many environments is your server in?

    Thanks!



  • @atripp
    INTEGRATION is not a nested environment.
    I have only few environment withe 2 nested env (under DEVELOPPEMENT)
    |-INTEGRATION
    |-DEVELOPPEMENT
    |------RECETTE
    |----- PREPROD
    |-PRODUCTION


  • inedo-engineer

    @philippe-camelio_3885 thanks!

    How many environments are that server in? Just one environment, or multiple? Can you try it with just one environment, if mutliple?

    If it still doesn't work, then I'd like to try to reproduce it. Can you share your infrastructure json file (Admin > Export Infrastructure? If it's sensitive info, then don't worry -- you can just send to support at inedo dot com (instead of public post), with [QA-568] in the subject? I can fish it out of the box then, and attach to our internal tracker.



  • @atripp
    As I wrote, I have few environments and INTEGRATION is not a nested env.
    I send you the the json file.
    Cdt


  • inedo-engineer

    @philippe-camelio_3885 I had a chance to look at this a little more closely, but just can't get this to reproduce as a problem. At first, I want to point out that no variable is defined on INTEGRATION.

      "environments": [
        {
          "name": "INTEGRATION",
          "variables": {}
        },
        {
          "name": "PRODUCTION",
          "variables": {}
        },
        {
          "name": "DEVELOPPEMENT",
          "variables": {
            "SQLInstances": "@(BOFRCT, ITRRCT, XTRRCT)"
          }
        }
      ],
    

    Anyways, I imported your infrastructure (converted everything to localServer), deleted the variable from the role and added to the INTEGRATION.

    On VM008004 (in DEV), I got the expected error: Could not resolve variable %SQLInstanceParams. If I delete the variable (SQLInstances) on the server, that variable is resolved because it's defined in DEV, too.

    OP VM008007 (in INT), I got the (different) expected error: Key StaticPorts not present in the map.

    When I delete @SQLInstances (which is defined on the server), then I get the error "Could not resolve variable @SQLInstances." ecause it's not defined on the environment



  • @atripp
    Oups
    Sorry about that.
    I made other tests since I created the thread.
    The data I send you are not correct
    I will wait for the 3.0.6 to make a clean test case and update the thread.


Log in to reply
 

Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation