fel*_*ixc 3 ansible ansible-2.x
我试图使用Python API运行一些剧本,因为我想将其与Flash集成以启用基于Web的控件。这是我的剧本(crondis.yaml):
- hosts: "{{app_name}}-server"
tasks:
- name: disable cron
cron:
name: "{{app_name|upper}}_MONITOR"
job: "/{{app_name}}/monitor.sh"
disabled: yes
Run Code Online (Sandbox Code Playgroud)
从cml可以这样:
ansible-playbook --extra-vars="{'app_name': 'newapp'}" crondis.yaml
Run Code Online (Sandbox Code Playgroud)
但是在Python API中,我看不到将vars添加到剧本的任何地方。我检查了Variable_Manager,DataLoader和PlaybookExecutor,但没有发现任何函数可以将vars添加到播放中。如果您有任何想法,请为我提供一点启示。
您可以通过设置.extra_vars属性来定义其他变量,请参见ansible-playbookcli 代码:
# create the variable manager, which will be shared throughout
# the code, ensuring a consistent view of global variables
variable_manager = VariableManager()
variable_manager.extra_vars = load_extra_vars(loader=loader, options=self.options)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2193 次 |
| 最近记录: |