path - 在 Ansible 中获取父目录?

标签 path yaml ansible

有没有办法在 Ansible 中评估相对路径?

tasks:
  - name: Run docker containers
    include: tasks/dockerup.yml src_code='..'

基本上我有兴趣将源代码路径传递给我的任务。恰好源代码是{{ansible_inventory}}的父路径但似乎没有任何东西可以开箱即用。

---- 更多信息 ----

项目结构:
myproj
  app
  deploy
    deploy.yml

所以我试图访问 app来自 deploy.yml .

最佳答案

您可以使用 dirname筛选:

{{ inventory_dir | dirname }}
引用 Managing file names and path names在文档中。

关于path - 在 Ansible 中获取父目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35271368/

相关文章:

yaml - 如何引用yaml文件中的值?

php - 如何修复 YAML 文件上的 "Circular reference"错误?

path - Ansible - 如何评估 role_path 变量

windows - 通过调用名称在 Windows 中调用 Ghostscript?

path - Inno Setup(如何动态获取文件路径)?

matlab - 通过矩形的随机路径

yaml - 在 conda YAML 文件中为 pytorch 指定 cpu-only

ansible - var_prompt 可以包含在角色中吗?

bash - 带有 pgrep 的 Ansible shell 任务不断失败,在普通 shell 中工作

c - C中二进制文件的路径