【发布时间】:2017-02-08 19:56:29
【问题描述】:
下面是我的名为 webserver 的 ansibel 角色的目录结构
本地主机角色#树
.
├── readme.md
├── site.yml
└── webserver
├── files
│ ├── createswap.sh
│ └── nginxkeyadd.sh
├── handlers
│ └── main.yml
├── tasks
│ └── main.yml
├── templates
│ ├── helloworld.conf.j2
│ └── index.html.j2
└── vars
└── main.yml
我的任务/main.yml 看起来像
- name: Create swap file 50MB
script: /etc/ansible/roles/webserver/files/createswap.sh
- name: add GPG key for nginx
script: /etc/ansible/roles/webserver/files/nginxkeyadd.sh
- name: Install nginx on target
apt: name={{ item }} state=latest
with_items:
- rsync
- git
- nginx
在 task/main.yml 中指定本地脚本文件的绝对路径,如
script: /etc/ansible/roles/webserver/files/nginxkeyadd.sh 和 script: /etc/ansible/roles/webserver/files/createswap.sh 。脚本没有任何 ansible 变量。
这是 ansible 的好习惯吗?
【问题讨论】:
标签: ansible ansible-2.x