local scope merge

Demo dvars merge in local scope in execution time

Merging sequence

The merging rule follows the same chain from top down in sequence of:

  1. exec profile: env vars setup
  2. global group vars
  3. global group dvars
  4. group vars
  5. group dvars
  6. instance vars
  7. instance dvars
  8. runtime global vard
  9. runtime global dvard
  10. func local vars
  11. func local dvars
  12. callee func local vars … | module stack (1 - 12)
  13. callee func local dvars …| module stack (1 - 12)

Demo

source

Main task yaml file
    scopes:
    - name: global
      vars:
        student:
          name: Tom
          gender: Male
          address:
            suburb:
              name: sydney
              postcode: 2000
              CBD: yes
            school: Sydney Grammar
    - name: nonprod
      members:
      - dev
      - staging
      vars:
        a: non-prod-a
        b: non-prod-b
        c: non-prod-c
        d: non-prod-d
      dvars:
      - name: school
        value: |
          address:
            suburb:
              name: {{.student.address.suburb.name}}
              postcode: 2000
              CBD: yes
            school: {{.student.address.school}}
        flags: [toObj]
    - name: dev
      vars:
        a: dev-a
        b: dev-b
      dvars:
      - name: school
        value: |
          address:
            suburb:
              name: {{.student.address.suburb.name}}
              postcode: 2000
              CBD: no
            school: {{.student.address.school}}
          principal: Mr Peter
        flags: [toObj]
    tasks:
    - name: task
      task:
      - func: shell
        vars:
          a: local-a
          b: local-b
        dvars:
        - name: school
          value: |
            address:
              state: NSW
              city: sydney
              suburb:
                name: {{.student.address.suburb.name}}
                postcode: 2000
                CBD: LOCAL
              school: {{.student.address.school}}
            principal: Mr Right
          flags: [toObj]
        do:
        - echo """1.school -> {{.school}}"""
        - echo """2.school object CBD -> {{.school_object.address.suburb.CBD}}"""
        - echo """3.school object-> {{.school_object.address.school}}"""
        - echo """4.school object-> {{.school_object.principal}}"""
    
Main log file
    loading [Config]:  ./tests/functests/upconfig.yml
    Main config:
                 Version -> 1.0.0
                  RefDir -> ./tests/functests
                 WorkDir -> cwd
              AbsWorkDir -> /up_project/up
                TaskFile -> c0033
                 Verbose -> vvv
              ModuleName -> self
               ShellType -> /bin/sh
           MaxCallLayers -> 8
                 Timeout -> 3600000
     MaxModuelCallLayers -> 256
               EntryTask -> task
      ModRepoUsernameRef -> 
      ModRepoPasswordRef -> 
    work dir: /up_project/up
    -exec task: task
    loading [Task]:  ./tests/functests/c0033
    module: [self], instance id: [dev], exec profile: []
    profile -  envVars:
    
    (*core.Cache)({
    })
    
    Task1: [task ==> task:  ]
    -Step1:
    self: final context exec vars:
    
    (*core.Cache)({
      "b": "local-b",
      "c": "non-prod-c",
      "student": {
        "address": {
          "suburb": {
            "CBD": true,
            "name": "sydney",
            "postcode": 2000
          },
          "school": "Sydney Grammar"
        },
        "name": "Tom",
        "gender": "Male"
      },
      "d": "non-prod-d",
      "school": "address:\n  state: NSW\n  city: sydney\n  suburb:\n    name: sydney\n    postcode: 2000\n    CBD: LOCAL\n  school: Sydney Grammar\nprincipal: Mr Right\n",
      "school_object": {
        "address": {
          "suburb": {
            "postcode": 2000,
            "CBD": "LOCAL",
            "name": "sydney"
          },
          "school": "Sydney Grammar",
          "city": "sydney",
          "state": "NSW"
        },
        "principal": "Mr Right"
      },
      "a": "local-a",
      "up_runtime_task_layer_number": 0
    })
    
    cmd( 1):
    echo """1.school -> {{.school}}"""
    
    -
    1.school -> address:
      state: NSW
      city: sydney
      suburb:
        name: sydney
        postcode: 2000
        CBD: LOCAL
      school: Sydney Grammar
    principal: Mr Right
    
    
    -
     .. ok
    cmd( 2):
    echo """2.school object CBD -> {{.school_object.address.suburb.CBD}}"""
    
    -
    2.school object CBD -> LOCAL
    
    -
     .. ok
    cmd( 3):
    echo """3.school object-> {{.school_object.address.school}}"""
    
    -
    3.school object-> Sydney Grammar
    
    -
     .. ok
    cmd( 4):
    echo """4.school object-> {{.school_object.principal}}"""
    
    -
    4.school object-> Mr Right
    
    -
     .. ok
    . ok
    
Logs with different verbose level
Raw logs with different verbose level