- hosts: localhost
gather_facts: false
tasks:
- name: add a host to a group in memory #这个模块只能往内存里添加,palybook执行完就失效了
add_host:
hostname: 172.16.128.199
groups: windows
test: 22

- name: add a host to windows in file
ini_file:
allow_no_value: yes #开启此选项可以向组块里添加没有值和=号的键原来需要key=value现在只需要key就行了
dest: /etc/ansible/hosts
section: windows #往[windows]组块里添加
option: 172.16.128.199 #向组块中添加的key