Yes。你可以做這樣的事情(如果你提供你的問題的更多信息,我們可以提供更多的特異性自己):
- add_host:
hostname: 1.1.1.1
groups: SET
- add_host:
hostname: 1.1.1.2
groups: SET1
這將動態地添加1.1.1.1到庫存爲SET
組和1.1的一部分。 1.2庫存作爲SET1
組的一部分。有在規定步驟一對夫婦這樣做的很好的例子爲rackspace
任務:
- name: Provision a set of instances
local_action:
module: rax
name: "{{ rax_name }}"
flavor: "{{ rax_flavor }}"
image: "{{ rax_image }}"
count: "{{ rax_count }}"
group: "{{ group }}"
wait: yes
register: rax
- name: Add the instances we created (by public IP) to the group 'raxhosts'
local_action:
module: add_host
hostname: "{{ item.name }}"
ansible_host: "{{ item.rax_accessipv4 }}"
ansible_ssh_pass: "{{ item.rax_adminpass }}"
groups: raxhosts
with_items: "{{ rax.success }}"
when: rax.action == 'create'
來源
2016-12-18 05:23:06
2ps
你所說的「部署任務」是什麼意思? – techraf