yum install ansible
修改ansible的默认host配置,在这个配置里面就可以配置上用户名和密码,例如:
vim /etc/ansible/hosts
[local]
localhost ansible_connection=local
[itop]
192.168.168.203 ansible_connection=ssh ansible_ssh_port=22 ansible_user=root ansible_ssh_pass=passw0rd
[all]
localhost ansible_connection=local
192.168.168.203 ansible_connection=ssh ansible_ssh_port=22 ansible_user=root ansible_ssh_pass=passw0rd
ansible all -m user -a ‘name=admin shell=/bin/bash home=/home/admin state=present password=passw0rd’
http://docs.ansible.com/ansible/faq.html#how-do-i-generate-crypted-passwords-for-the-user-module