ansible 变量优先级

ansible中变量的优先级

  • extra vars (-e 选项指定的变量)最高
  • inventory 主机清单中定义的变量(ansible_ssh_user等)
  • play剧本中vars、vars_files定义的变量
  • 系统的facts变量
  • 角色定义的默认变量 最低

从上到下优先级逐渐降低,高优先级会覆盖掉低优先级的变量

变量的优先级
变量的优先级指的是优先级越高的会覆盖优先级低的,下边的优先级由低到高进行排列:

  • role defaults [1]
  • inventory vars [2]
  • inventory group_vars
  • inventory host_vars
  • playbook group_vars
  • playbook host_vars
  • host facts
  • play vars
  • play vars_prompt
  • play vars_files
  • registered vars
  • set_facts
  • role and include vars
  • block vars (only for tasks in block)
  • task vars (only for the task)
  • extra vars (always win precedence)

你可能感兴趣的:(ansible 变量优先级)