我的剧本中有2个主机,并且我想在其中包含用户项。
##remote servers
- hosts: test
remote_user: ansible
vars:
users:
- username: "user1"
groups: "users,wheel"
- username: "user2"
groups: "users,wheel"
tasks:
- name: "Create user accounts"
user:
name: "{{ item.username }}"
groups: "{{ item.groups }}"
with_items: "{{ users }}"
##local ansible server
- hosts: 127.0.0.1
vars:
users:
- username: "user1"
groups: "users,wheel"
- username: "user2"
groups: "users,wheel"
tasks:
- name: "Create user accounts"
user:
name: "{{ item.username }}"
groups: "{{ item.groups }}"
with_items: "{{ users }}"
是否有某种语法可以避免重复项目列表?
我试图将项目放入一个新文件(users.yml) 我尝试使用此代码/ include:
-hosts:test
remote_user: ansible
include_vars:
file: users.yml
tasks:
-name: "create user accounts"
但是我得到一个错误!冲突的操作语句:include_vars,用户
是否有某种语法可以避免重复项目列表?
答案 0 :(得分:0)
这应该是一个任务。
app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin','*');
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
res.header('Access-Control-Allow-Credentials', true);
res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, PATCH');
next();
});