template 模块问题
来源:3-7 Ansible playbooks常用模块案例操作

慕侠2486442
2022-05-14
老师,我有个疑问,案例中是先拷贝的nginx 配置文件到 远程主机 nginx 目录下,如果远程主机不存在nginx 目录,那么nginx.conf.j2 配置文件是拷贝不过去的,为什么不先执行yum 安装nginx 呢,这样远程主机上的nginx 目录肯定是存在的,就不会出现拷贝不过去的现象。
- name: wirte the nginx config file
template: src=roles/testbox/templates/nginx.conf.j2 dest=/etc/nginx/nginx.conf - name: ensure nginx is at the stable
yum: pkg=nginx state=latest
写回答
1回答
-
一路向北
2022-05-14
如果目录不存在 ansible会创建此目录,你可以试一下
012022-05-15
相似问题