0
我是新來的廚師,我有一些問題,以獲取data_bags與嵌套屬性的值。廚師嵌套Databag
{
"id": "bareos-fd",
"description": "Client resource of the Director itself.",
"address": "localhost",
"job": {
"backup-bareos-fd": {
"jobdefs": "DefaultJob"
},
"BackupCatalog": {
"description": "Backup the catalog database (after the nightly save)",
"jobdefs": "DefaultJob",
"level": "Full",
"fileset": "Catalog",
"schedule": "WeeklyCycleAfterBackup",
"run_before": "/usr/lib/bareos/scripts/make_catalog_backup.pl MyCatalog",
"run_after": "/usr/lib/bareos/scripts/delete_catalog_backup",
"bootstrap": "|/usr/bin/bsmtp -h localhost -f \\\"\\(Bareos\\) \\\" -s \\\"Bootstrap for Job %j\\\" [email protected]",
"priority": "11"
},
"RestoreFiles": {
"type": "Restore",
"fileset": "LinuxAll",
"storage": "File",
"pool": "Incremental",
"messages": "Standard",
"where": "/tmp/bareos-restores"
}
}
}
我如何寫一個foreach得到嵌套值
的工作重點是動態。我想要做的是創建一個文件,其中包含鍵名和內部值。 此數據包是默認配置文件的示例,BackupCatalog僅用於此特定客戶端。我的問題是引用動態kv。這可能是像 ' 「工作」:{ 「another_job」:{ 「類型」: 「其他」 } }' 我有內部的所有客戶一個名爲bareos_clients data_bag。我能夠閱讀所有內容,但我不知道如何循環處理作業條目。 –
這一切都只是Ruby代碼是我的觀點。查看Ruby'Hash'和'Array'類,你會發現任何你需要的方法。 – coderanger