ansible部署
清单文件的优先级
ANSIBLE_CONFIG环境变量指定的任何文件将覆盖所有其他配置文件。如果没有设置该变量,则接下来检查运行ansible命令的目录中是否有ansible.cfg文件。如果不存在该文件,则检查用户的家目录是否有.ansible.cfg文件。只有在找不到其他配置文件时,才使用全局/etc/ansible/ansible.cfg文件。如果/etc/ansible/ansible.cfg配置文件不存在,Ansible包含它使用的默认值。
-
ansible配置文件使用优先级
- ANSIBLE_CONFIG > 当前目录下的ansible.cfg > ~/.ansible.cfg > /etc/ansible/ansible.cfg
user模块演示
创建用户
[root@localhost ansible]# ansible all -m user -a 'name=hehe uid=2000 state=present'
[root@localhost ~]# id hehe
uid=2000(hehe) gid=2000(hehe) 组=2000(hehe)
修改uid
[root@localhost ~]# ansible all -m user -a 'name=hehe uid=2001 state=present'
[root@localhost ~]# id hehe
uid=2001(hehe) gid=2000(hehe) 组=2000(hehe)
删除用户