YAML
Yet Another Markup Language
See yq
A superset of [JSON], with comments! Also see [TOML] and HCL
- TODO: Document this
- LEARN: Because of [Ansible]. [Octopus Deploy] & [[azure_devops_pipelines]]
- Some questions have been raised about it’s (or it’s libraries) security.
Wouldn’t it be fun to use Google’s Protocol buffers for this Ansible use case?
Convert to & from JSON via yamljs
npm install -g yamljs
then manipulate with jq
yaml2json octopipe.yaml | jq '.variables[].name'
Example file
From Octopus
variables:
- name: variable1
value: value1
- name: variable2
values:
Dev: dev_value
Test: test_value
- name: variable3
value: octopusdeploy-account
type: AzureAccount
description: Account used for deployments
project:
name: OctopusProject
description: My Octopus Project
group: OctopusProjectGroup
lifecycle: OctopusProject.Lifecycle
process:
steps:
- name: Init
type: PowerShell
file: scripts/init.ps1
- name: Deploy VM
type: PowerShell
file: scripts/deploy.ps1
yaml2json octopus.yaml | jq > y.json && json2yaml -d 10 y.yaml && yq r y.yaml
{
"variables": [
{
"name": "variable1",
"value": "value1"
},
{
"name": "variable2",
"values": {
"Dev": "dev_value",
"Test": "test_value"
}
},
{
"name": "variable3",
"value": "octopusdeploy-account",
"type": "AzureAccount",
"description": "Account used for deployments"
}
],
"project": {
"name": "OctopusProject",
"description": "My Octopus Project",
"group": "OctopusProjectGroup",
"lifecycle": "OctopusProject.Lifecycle"
},
"process": {
"steps": [
{
"name": "Init",
"type": "PowerShell",
"file": "scripts/init.ps1"
},
{
"name": "Deploy VM",
"type": "PowerShell",
"file": "scripts/deploy.ps1"
}
]
}
}