Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Questions tagged [yaml]

YAML is a data serialisation format designed for human readability, supporting data with self references. YAML 1.2 is a superset of JSON, so its tools can be used to process JSON. Use this tag for question that involve features specific to the YAML format.

Filter by
Sorted by
Tagged with
0 votes
0 answers
23 views

Add IP addresses using lineinfile

I have a container.yml file, and I need to add a lineinfile task to add the IP addresses of three hosts. Ex: 101.101.101.10 k1 101.101.101.11 k2 101.101.101.12 k3 This is how I went on ...
user avatar
  • 1
0 votes
1 answer
41 views

Need help Formatting a file having key: value [duplicate]

I have a file having the below values: cat data.txt server1: 'calv' server2: 'anot' log: '/u/log/1' server3: 'calv' server4: 'anot' server5: 'secd' server6: 'calv' LIB_TRGT_calv,anot: '/tmp/hello.txt' ...
user avatar
  • 297
3 votes
1 answer
158 views

ignore whitespace at the beginning of a search pattern

This sed expression works, but is there a better way to represent the white space in both the search pattern and replace string? BRANCHTAG=7.17.9-main-5ee3e99d5ff002862d93728d821461033de1186d ...
user avatar
0 votes
0 answers
23 views

Convert puppet manifest config to hiera

I installed corosync-pacemaker cluster via puppet. Now I would to like keep my data into hiera file. How should I convert cs_primitive section into yaml file? cs_primitive { 'nfsshare_fs': ...
user avatar
3 votes
5 answers
321 views

find duplicate 1st field and concat its values in single line

I have a file that has entries in key: value format like the below: cat data.txt name: 'tom' tom_age: '31' status_tom_mar: 'yes' school: 'anne' fd_year_anne: '1987' name: 'hmz' hmz_age: '21' ...
user avatar
  • 297
3 votes
2 answers
667 views

How to extract a few IP addresses from a YAML file

I have this file, and I'd like to select all the IP addresses under the masters/hosts section if their line is not commented. I tried this sed 's/.*\ \([0-9\.]\+\).*/\1/g', but it did not work. metal: ...
user avatar
  • 205
0 votes
0 answers
27 views

What does ${var//,/ } mean? [duplicate]

I noticed it being used in pipeline as code where var is a yaml object containing multiple key: value and bash/script task is used to convert it to array. I couldn't find it's use in documentation ...
user avatar
0 votes
2 answers
102 views

sed command to replace pattern including newline pattern with blank

I have a yaml file which include text: - name: flexvol-driver-host hostPath: type: DirectoryOrCreate path: /usr/libexec/kubernetes/kubelet-plugins/volume/exec ...
user avatar
  • 13
-1 votes
1 answer
32 views

How to replace a pattern permanently in a file using pipe Unix command

I have following lines, so I just want to replace particularly client_encryption_options: enabled: true to client_encryption_options: enabled: false ...
user avatar
  • 107
1 vote
3 answers
605 views

Generate templates in yaml from a CSV file

I am trying to create yaml files from a template using my variables. My yaml template look like this number: {{NUMBER}} name: {{NAME}} region: {{REGION}} storenum: {{STORENUM}} clients: {{...
user avatar
  • 11
-2 votes
1 answer
45 views

File Comparison

I have two files with FILE1 containing lots of lines and FILE2 with KEY VALUE parms. I need to compare FILE2 with FILE1 and if there is match the corresponding word in FILE1 should be replace with ...
user avatar
  • 313
1 vote
1 answer
114 views

Generate full paths from nested (for example yaml) directory structure

I try to write script in shell/bash that will convert yaml directory structure to full paths (for further mkdir -p it). Yaml is my choice because of human-editability. Structure example is: - ...
user avatar
0 votes
3 answers
1k views

Shell script to find the list of a keys inside a key in Yaml file

I have a yaml file info: description: Api contact: name: Api tags: - name: "" description: "" paths: /data1/1: post: tags: - "tag1" /...
user avatar
2 votes
2 answers
2k views

Modify yaml file in bash without any external dependency

I've multiple configurations in YAML file and I need to change some paramaters using a Bash script. Is it possible? I want to avoid using any external dependency. My YAML Looks like %YAML 1.2 --- name:...
user avatar
-1 votes
2 answers
113 views

Append new webhook to alertmanager config file using shell

I am using alertmanager for notification purpose and by default alertmanager only has one webhook. As per my requirement one more webhook is required. Existing config global: resolve_timeout: 5m ...
user avatar
0 votes
0 answers
42 views

Can't fold YAML block in Vim after commenting it out

I have a YAML file, and configured the folding of different sections for the document in the Vim editor. However, when I comment out a section, it remains unfolded, and trying to "re-fold" ...
user avatar
0 votes
1 answer
379 views

Ansible facts output in one line

I need some information from Ansible facts, hence created below YAML. but its giving error. My requirement is to get the output in one line. So that we can filter it using CSV or spreadsheet. --- - ...
user avatar
  • 2,953
0 votes
1 answer
247 views

Is it possible to make a YAML use ISO 8601 date format?

I am using a tool called organize in order to sort folders with a lot of stuff in them and was wondering if it was possible to tell it to create, sort, or rename using ISO 8601 date format. The config ...
user avatar
  • 776
4 votes
4 answers
2k views

How do I remove all specifc sub-sections of a specifc header in a YAML file?

I'm using bash shell. I have a YAML file from which I want to remove certain blocks of text. /image-content: post: operationId: createEventPublic summary: Process events ...
user avatar
  • 1,810
0 votes
2 answers
1k views

Struggling using sed command with variables

So I have the following variables defined in a bash script: new_commit="back:h3912kk" old_commit="back:1.0.1" file = docker-compose.yml Then I have this yml $file: version: '...
user avatar
3 votes
6 answers
633 views

Passing variable to AWK not working inside a loop

I have this awk statement that reads a YAML file and outputs a particular value. I need to loop this awk inside a loop where I read a key value from a list of values and pass that key to awk. The YAML ...
user avatar
-3 votes
2 answers
122 views

deduplicate mostly negated awk

do not repeat yourself!, lol, ok, I'm trying to see if I can consolidate my 2 github workflows awk sources into 1. I tried a few things, but for some reason I kept ending up with weird column stuff. ...
user avatar
0 votes
4 answers
890 views

How do I get a multiline awk script running in bash

To start this script is running it a Github workflow, using shell bash, yaml truncated for readability. I've tried a number of things to make it work as multiline, so I can have comments. set -x ...
user avatar
0 votes
2 answers
378 views

Using sed to match a dynamic, multi-line string and append to it

I have an Ansible yaml file that I want to append on a new line after state: present in the example matches below with use: package_manager using sed. # Example 1 - name: Package X Install package: ...
user avatar
5 votes
5 answers
1k views

Replace value in "key: value" statement, but only on first occurence of the key in the file

I have a yml file spring: datasource: url: url username:test password: testpwd api: security: username:foo password: foopwd I want to update only the first occurrence or ...
user avatar
  • 75
0 votes
3 answers
663 views

Parse yaml file without using outside tool [duplicate]

I am new to bash, dragged into a problem where I need to update some dynamic parameters in a yaml file Based on query (search4.subsearch1.name), i need to update name: old_name into name: new_name ...
user avatar
  • 19
-2 votes
1 answer
396 views

Is JSON and YAML considered Markup languages? [closed]

I have my Comp Tia Linux+ (XK0-004) exam tomorrow. I purchased the "Compt Tia Linux+ All in one Exam Guide) book off Amazon and this book is contradicting what Google searches are saying ...
user avatar
0 votes
1 answer
2k views

Ansible: Could not locate file in lookup

I wrote a playbook to deploy my ssh keys across multiple instances. This my playbook, but I am experiencing some problems with it. I already created my ssh keys from my local instance. Please see ...
user avatar
0 votes
2 answers
230 views

grep in limiting

I have a YAML file: - name: scheduler-configuration - name: scheduler I'm grepping some thing like grep "scheduler" file.txt The output it is showing both lines, but I want only single ...
user avatar
-1 votes
3 answers
4k views

SED replace in next line in yaml

I am trying to replace the tag value but having no luck with sed Here is the file looks like and i would like to replace the tag value uniquely app1: tag: "dev-0.114" repository: kafka ...
user avatar
0 votes
2 answers
991 views

using yq to base64 encode k8s secret values

I have a simple secret.yaml file: env: USERNAME: user PASSWORD: pass i'm trying to use yq / jq to encode the values for creating k8s secret, so my final result should be: apiVersion: v1 kind: ...
user avatar
1 vote
3 answers
7k views

Parse a YAML section using shell

I have a YAML that looks like something: - whatever: - something - toc: 4 - body: assets/footer.html pkg: - pkg_a_1: - Shass - AJh55 - ASH7 - pkg_b_1: - Kjs6 - opsaa other: ...
user avatar
0 votes
1 answer
63 views

AWK - Substraction of a number after a keyphrase

I have a file where a pattern string repeats like ABC:10, what I'm looking for it's every time in the file there is this ABC:10 must always transform it into XYZ:5 The trick part is that the number ...
user avatar
  • 1
1 vote
2 answers
3k views

Find a string and replace another string on a following line after the first string is found

Given a file with the following content: pkg1: replicaCount: 1 image: tag: latest pullPolicy: Always pkg2: replicaCount: 2 image: tag: latest pullPolicy: Always I want to ...
user avatar
1 vote
1 answer
543 views

How to use xargs to set and change variables on the fly?

I'm trying to perform docker save -o on all images in a docker-compose.yaml file in one command. what I've managed to do is: cat docker-compose.yaml | grep image and this will give: image: hub....
user avatar
0 votes
0 answers
993 views

Shell script : Reading yml with dynamic property key

Help taken to read the yml(parser code) : https://gist.github.com/pkuczynski/8665367 My YML file is: marketVal: envVal: hostVal: ipValue And in .sh file I am reading it as market $1 env $2 ...
user avatar
  • 101
0 votes
1 answer
294 views

Docker-compose.yml file format problem

I'm just testing the construction of a Moodle/Mariadb installation using docker-compose, a lot of information around is conflicting and the differences between versions doesn't help, but I've managed ...
user avatar
  • 1
0 votes
2 answers
3k views

How to edit yaml file in Dockerfile or in shell?

In Dockerfile, I upload one configuration file from curl, which I then need to edit a little, here is an example structure: client: ... server: applicationConnectors: - type: http port: ...
user avatar
  • 167
0 votes
2 answers
5k views

Ansible lineinfile (white spaces and state changes)

We have a unique issue and we've spent some time understanding the problem but we are unsure with whether the approach we are taking is in fact correct. Our objective is to validate specific UNIX ...
user avatar
  • 1
0 votes
1 answer
258 views

How to remove a top-level entry and all of the nodes below it from a YAML file?

My file contains the below entries: cat /tmp/test.yaml --- 10.8.8.26: /tmp/win5835113081224811756.jar: hash: e6df90d38fa86f0e289f73d79cd2cfd2a29954eb /tmp/win03745991442278706.jar: hash: ...
user avatar
  • 297
0 votes
1 answer
28k views

error converting YAML to JSON: yaml: line 10: did not find expected key

I have the following yaml file: --- apiVersion: v1 kind: pod metadata: name: Tesing_for_Image_pull -----------> 1 spec: containers: - name: mysql ------------------------&...
user avatar
  • 10.2k
3 votes
1 answer
4k views

Tool for manipulating yaml files?

We want to implement a workflow that includes having YAML configuration files where we wish to change some of the contents before actually using them, and we are looking for a good command line tool ...
user avatar
2 votes
0 answers
229 views

Tool to convert multi-document YAML to XML

Are there any command-line tools to convert YAML to XML? I've seen that there are several websites that offer YAML to XML conversions, however none of them seem to support YAML files containing ...
user avatar
1 vote
2 answers
967 views

Meaning of 'wait $${!}' in docker-compose.yaml?

I am doing some docker with letsencrypt and nginx. In the tutorial I am following there is this command for the certbot container which allows for the sertificate to be checked for validity every 12h. ...
user avatar
  • 225
0 votes
1 answer
7k views

Export environment variables parsed from YAML text file [duplicate]

I have some environment variables declared in a YAML file like: runtime: python37 env_variables: API_URL: 'https://fake.api.com/' API_USERNAME: 'fake@email.com' API_PASSWORD: 'Passwooord' I ...
user avatar
  • 1,767
0 votes
0 answers
1k views

Replace variable with the value in sed - special case

I have a kubernetes yaml file and there are 351 yaml. So, i got the pattern, after [space][space][space]annotations: i want to add another key/value. before metadata: annotations: release: '{{....
user avatar
3 votes
4 answers
6k views

Filter YAML file content using sed/awk

I have a text file with the following content in it. $ cat hosts.yml [prod_env] foo.example.com bar.example.com [stage_env] foo_stage.example.com bar_stage.example.com [dev_env] foo_dev1.example.com ...
user avatar
  • 531
0 votes
2 answers
844 views

Recommendations for editing same file on different machines

Our Rails app is scaled at multiple machines, from time to time, we need to change settings at production.yml , right now we have to ssh into each server and do the editing at each machine ...
user avatar
  • 115
1 vote
1 answer
3k views

Ansible, docker_container and depends_on

I am using ansible and docker_container module. But when I start my playbook, I have error like: "'depends_on' is not a valid attribute for a Task" This is my playbook: - name: Docker-compose ...
user avatar
2 votes
1 answer
253 views

Finding incorrect YAML headers

I am trying to identify which files in my project have incorrect headers. The files all starts like this --- header: . . . title: some header: . . . more headers: level: . . . --- Where . . . only ...
user avatar