gpt4 book ai didi

path - 在 Ansible 中获取父目录?

转载 作者:行者123 更新时间:2023-12-03 15:18:11 25 4
gpt4 key购买 nike

有没有办法在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com