我有一个用例,我需要做一个任务(重新发布ssl证书)。步骤如下:
这意味着我有一个看起来像这样的剧本:
- name: open port
hosts: caserver
become: yes
tasks:
- name: open firewall
iptables: chain=FWR protocol=tcp source={{ item }} destination_port=8888 jump=ACCEPT state=present
with_inventory_hostnames: WHAT IS HERE???
- name: generate ssl certificate
hosts: all:!caserver
become: yes
roles:
- sslcert
- name: close port
hosts: caserver
become: yes
tasks:
- name: close firewall
iptables: chain=FWR protocol=tcp source={{ item }} destination_port=8888 jump=ACCEPT state=absent
with_inventory_hostnames: WHAT IS HERE???
然后我会从命令行调用它来使用限制来控制重新发布的机器。
ansible-playbook -i hosts -l myserver,caserver -c ssh --ask-vault-pass -K generate_certs.yml
问题是我没有在caserver上打开那个端口。
我一直在尝试一些magic variables,但没有运气。
我想我必须在hosts
文件中创建一个组然后使用它。所以我创建一个小组,重新发布,然后从该小组中删除它们。
我不喜欢那种洗牌是否有更好的方式在ansible?
答案 0 :(得分:0)
您应该使用delegation。
https://spreadsheets.google.com/feeds/list/--KEY--/od6/public/values?alt=json-in-script