Ansible:如何更改 Ansible Playbook 中的活动目录? [英] Ansible: How to change active directory in Ansible Playbook?

查看:23
本文介绍了Ansible:如何更改 Ansible Playbook 中的活动目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

- name: Go to the folder
  command: chdir=/opt/tools/temp

当我运行我的剧本时,我得到:

When I run my playbook, I get:

TASK: [Go to the folder] ***************************** 
failed: [host] => {"failed": true, "rc": 256}
msg: no command given

非常感谢任何帮助.

推荐答案

Ansible 中没有当前目录的概念.您可以为特定任务指定当前目录,就像您在剧本中所做的那样.唯一缺少的部分是要执行的实际命令.试试这个:

There's no concept of current directory in Ansible. You can specify current directory for specific task, like you did in your playbook. The only missing part was the actual command to execute. Try this:

- name: Go to the folder and execute command
  command: chdir=/opt/tools/temp ls

这篇关于Ansible:如何更改 Ansible Playbook 中的活动目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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