cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
109
Views
0
Helpful
1
Replies

Providing value to the parameter in yaml through CLI

o1
Cisco Employee
Cisco Employee

Hi Team,

This is the format of my yaml file:

testbed:

   name:

   servers:

   password:

   custom:

       version: "10.3.4"

Instead of providing the value to the version manually in the yaml, I want to provide this value with the CLI I am using for execution. Is it possible? I tried using this : version: %CLI{version}. But that dint help.

Is there any other way to do this?

1 Reply 1

Not sure on your project here, but you could do this by passing environment variables, you can define the version as an environment variable and reference it in your YAML file. For example

testbed:
  name:
  servers:
  password:
  custom:
    version: "${VERSION}"

set the VERSION environment variable before running your command

export VERSION=10.5.1
your_cli_tool your_file.yaml

You can also use a command-line argument parser to parse the version number from the CLI arguments and then use it to populate the version key in the YAML file using Python and click.

Hope this helps.

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io