goss-org / goss

Quick and Easy server testing/validation
https://goss.rocks
Apache License 2.0
5.6k stars 472 forks source link

vars should override for existing packages using vars.yaml #442

Closed thatsk closed 4 years ago

thatsk commented 5 years ago

root@: ~# cat goss_package.yaml
package:
# Looping over a variables defined in a vars.yaml using $OS environment variable as a lookup key
{{range $name, $vers := index .Vars .Env.node_type "packages"}}
  {{$name}}:
    installed: true
    versions:
    {{range $vers}}
      - {{.}}
    {{end}}
{{end}}
root@: ~# cat test.yaml
package:
  PyYAML:
    installed: true
    versions:
    - 3.11-1.el7.x86_64
  acl:
    installed: true
    versions:
    - 2.2.51-14.el7.x86_64
  httpd:
    installed: true
    versions:
    - 2.2.17
root@: ~# cat vars.yaml
test:
  packages:
    httpd:
      - 2.2.15
root@: ~# node_type=test goss --vars vars.yaml -g goss.yaml render
package:
  PyYAML:
    installed: true
    versions:
    - 3.11-1.el7.x86_64
  acl:
    installed: true
    versions:
    - 2.2.51-14.el7.x86_64
  httpd:
    installed: true
    versions:
    - 2.2.17```

```root@: ~# cat goss.yaml
gossfile:
  /root/goss_package.yaml: {}
  /root/test.yaml: {}```

if its new packages it will override and render

```root@: ~# cat vars.yaml
test:
  packages:
    kunal:
      - 2.2.15```
```root@: ~# node_type=test goss --vars vars.yaml -g goss.yaml render
package:
  PyYAML:
    installed: true
    versions:
    - 3.11-1.el7.x86_64
  acl:
    installed: true
    versions:
    - 2.2.51-14.el7.x86_64
  httpd:
    installed: true
    versions:
    - 2.2.17
  kunal:
    installed: true
    versions:
    - 2.2.15```
aelsabbahy commented 4 years ago

I'm having a hard time understanding the question, bug, or feature request here.

Can you provide explanation text with small yaml examples?