繁体   English   中英

厨师模板问题,陈旧变量

[英]Chef template issues, stale variables

我在运行我的厨师食谱时看到一个奇怪的问题,即使在修改json env文件之后,它几乎看起来在运行之间有一些陈旧的变量名称。 请参阅下面的详细信息。 我已经粘贴了我的模板和环境文件的摘录。 还显示了我所看到的所需输出和当前奇怪的输出。 它可能是我的红宝石循环(原谅我的红宝石,noob在这里),但我已多次检查它,并没有看到任何问题的构造。

任何帮助表示赞赏......现在已经搞乱了近24小时,为了提高工作效率,我正在向其他人伸出援助之手。

这是我在这里的第一篇文章,我不允许在内容中发布超过2个链接。 我不得不从我的示例输出中删除'http'和'https',并重命名我的域名以绕过。

模板:

gatewaymappings: |  
  {  
    <% @gatewaymappings.each_with_index do |mapping, index| %>      
       "<%= mapping.incomingFQDN %>" : "<%= mapping.upstreamProtocol %>://<%= mapping.upstreamFQDN %>  
          <% if (mapping.upstreamPort.length > 0) %>  
            :<%= mapping.upstreamPort %>"  
         <% end %>  
          <% if (index+1 != @gatewaymappings.count) %>  
            ,  
         <% end %>  
   <% end %>  
  }

厨师模板变量:
:gatewaymappings => node[app_name]['gatewaymappings']

示例JSON:

"gatewaymappings": [  
  {  
    "incomingFQDN": "host1",  
    "upstreamProtocol": "http",  
    "upstreamFQDN": "upstream1",  
    "upstreamPort": "8000"  
  },  
  {  
    "incomingFQDN": "host2",  
    "upstreamProtocol": "https",  
    "upstreamFQDN": "upstream2",  
    "upstreamPort": "8001"  
  }  
]  

期望的输出:(在yml文件中)

 gatewaymappings: |  
  {  
      "host1" : "upstream1:8000",  
      "host2" : "upstream2:8001"  
  }  

当前输出:
(第一个元素来自之前的示例env运行,它甚至不存在于我当前的示例json中,我尝试清除缓存等,但它仍然会一直显示)

gatewaymappings: |  
  {  
      "localhost" : "upstream",  
      "host1" : "upstream1:8000",  
      "host2" : "upstream2:8001",  
      "host1" : "upstream1:8000",  
      "host2" : "upstream2:8001"  
  }  

我想我能解决这个问题。 这是由于我的节点配置被破坏。 我应该提到我正在使用厨师零。 事实证明,节点配置被保存回nodes目录中的json文件,即使对于chef-zero也是如此,所以无论我在~/.chef和我的安装目录中删除了多少次本地模式缓存,过时的值仍然存在背部。 感谢gitter聊天室,有人给了我一个温和的提醒,检查节点的配置。 这照顾了这个问题,我现在看到了我的预期输出。 谢谢!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM