We can read yaml
file within Runspace
using code given in below post
How to read remote yaml file present in Azure VM from local machine using C# Runspace
But how to update existing remotely located yaml
file.
I want to use code using YamlDotnet
similar to one given in below post to create some new data to be updated into existing yaml
file.
Build a Yaml document dynamically from c#
Update:
I have inventory yaml file with its contents as below
targets:
- uri: 80.587.459.478
config:
transport: ssh
ssh:
user: testlinuxuname
private-key: ~/ssh-key/SSH-PrivateKey.txt
host-key-check: false
run-as: root
- uri: targetwindows123
config:
transport: winrm
winrm:
user: testusername
password: testpwd
ssl-verify: false
Yaml file is located in remote Azure VM.
Requirement: I want to read
yaml
file which is present in remote azure vm fromC#
and check if particularuri
value exists or not. If particularuri
value doesn't exist, then I need to append newuri
data toyaml
file. So new record will be appended next to existing data inyaml
file.New record will be something like below.
- uri: targetwindows567 config: transport: winrm winrm: user: testusername1 password: testpwd1 ssl-verify: false
I want to check if
uri
valuetargetwindows567
exists or not inyaml
file. If it don't exist, then add above records into the remoteyaml
file.