防止to_nice_yaml生成别名

时间:2019-01-10 16:23:08

标签: ansible yaml jinja2 ansible-2.x

是否可以强制函数<DataSearch placeholder="Search..." componentId="q" dataField={["firstname"]} className="autocomplete-search-bar" icon={(<i className="fa fa-search fa-lg search-icon"></i>)} showClear={false} iconPosition="right" style={{}} innerClass={{title: "text-title",input: "text-input",list: "text-item"}} react={{ "or": ["q"] }} onValueSelected={(value, cause, source) => { if (cause !== 'SUGGESTION_SELECT') { // use this query console.log('use this query - onValueSelected: ', this.query); this.setState({ redirect:true, value: value }); this.props.history.push(`/search?q="${value}"`); } else { this.valueSelected = true; this.setState({ value }); } }} onQueryChange = {(prevQuery, nextQuery) => { this.query = nextQuery; if (this.valueSelected) { // use this query console.log('use this query - onQueryChange: ', this.query); this.valueSelected = false; this.setState({ redirect: true }); } }} /> 避免生成别名?

Ansible模板中的以下行

to_nice_yaml

其中

scrape_configs:
    {{ scrape_configs | to_nice_yaml(indent=2) | indent(2,False) }}

使用别名扩展YAML文件(请参见下文),我不确定Prometheus的配置解析器是否支持该别名。显然,我想在不对每个条目进行common_relabeling: - stuff1 - stuff2 scrape_configs: - job_name: process_exporter relabel_configs: "{{ common_relabeling }}" - job_name: node_exporter relabel_configs: "{{ common_relabeling }}" 硬编码的情况下对其进行修复

common_relabeling

1 个答案:

答案 0 :(得分:1)

您可以仅保留锚点和别名。

Prometheus使用软件包gopkg.in/yaml.v2,如果您仔细阅读该软件包的文档,您会发现它基于libyaml,该软件包已经解析了锚点和别名十多年了。现在。 gopkg.in/yaml.v2的文档明确指出了anchors are supported

  

yaml软件包支持大多数YAML 1.1和1.2,包括对锚点,标签的支持...

相关问题