人偶XML augeas镜头

Puppet XML augeas lens

我正在尝试使用 Puppet 设置 Windows CFG 文件的配置。

augeas{ "bbdisplay_setting":
  incl => '/tmp/BBWin.cfg',
  lens => "Xml.lns",
  # How do I change the value of `value=1.1.1.1 to value=9.9.9.9
}

我找不到一个很好的例子来说明如何改变这个例子中第一个 bbdisplay 的值 XML 文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <bbwin>
    <setting name="bbdisplay" value="1.1.1.1" />
    <setting name="bbdisplay" value="2.2.2.2" />
  </bbwin>
</configuration>

Augtool 将配置列为:

/files
/files/tmp
/files/tmp/BBWin.cfg
/files/tmp/BBWin.cfg/#declaration
/files/tmp/BBWin.cfg/#declaration/#attribute
/files/tmp/BBWin.cfg/#declaration/#attribute/version = "1.0"
/files/tmp/BBWin.cfg/#declaration/#attribute/encoding = "utf-8"
/files/tmp/BBWin.cfg/configuration
/files/tmp/BBWin.cfg/configuration/#text = "\n  "
/files/tmp/BBWin.cfg/configuration/bbwin
/files/tmp/BBWin.cfg/configuration/bbwin/#text[1] = "\n"
/files/tmp/BBWin.cfg/configuration/bbwin/setting[1] = "#empty"
/files/tmp/BBWin.cfg/configuration/bbwin/setting[1]/#attribute
/files/tmp/BBWin.cfg/configuration/bbwin/setting[1]/#attribute/name = "bbdisplay"
/files/tmp/BBWin.cfg/configuration/bbwin/setting[1]/#attribute/value = "1.1.1.1"
/files/tmp/BBWin.cfg/configuration/bbwin/#text[2] = "    "
/files/tmp/BBWin.cfg/configuration/bbwin/setting[2] = "#empty"
/files/tmp/BBWin.cfg/configuration/bbwin/setting[2]/#attribute
/files/tmp/BBWin.cfg/configuration/bbwin/setting[2]/#attribute/name = "bbdisplay"
/files/tmp/BBWin.cfg/configuration/bbwin/setting[2]/#attribute/value = "2.2.2.2"
/files/tmp/BBWin.cfg/configuration/bbwin/#text[3] = "  "

如果你想首先 bb显示然后:

augeas{ "bbdisplay_setting":
  incl    => '/tmp/BBWin.cfg',
  lens    => "Xml.lns",
  changes => "set configuration/bbwin/setting[#attribute/name="bbdisplay"][1]/#attribute/value 9.9.9.9",
}

或另一个例子,用现有值改变它:

augeas{ "bbdisplay_setting":
  incl    => '/tmp/BBWin.cfg',
  lens    => "Xml.lns",
  changes => "set configuration/bbwin/setting[#attribute/value = "1.1.1.1"]/#attribute/value 9.9.9.9",
}