如何使Ansible变量为强制性 [英] How to Make Ansible variable mandatory

查看:80
本文介绍了如何使Ansible变量为强制性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方式来使Ansible在运行Playbook执行之前分析Playbook的必需变量和必需变量,

I'm looking for the way how to make Ansible to analyze playbooks for required and mandatory variables before run playbook's execution like:

- name: create remote app directory hierarchy
  file:
    path: "/opt/{{ app_name | required }}/"
    state: directory
    owner: "{{ app_user | required }}"
    group: "{{ app_user_group | required }}"
  ...

如果未定义变量,则会出现错误消息,例如:

and rise error message if variable is undefined, like:

please set "app_name" variable before run (file XXX/main.yml:99)

推荐答案

您可以使用 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆