使用openssl生成一段加密密码
openssl passwd -1 123
$1$SeDgQgFX$QpKs2kIy7BO7EGk8ipoVM1
配置ansible-playbook
vi public.yml
– hosts: ‘{{ hosts }}’
gather_facts: false
tasks:
– name: useradd aaaa
user: name=aaaa shell=/bin/bash groups=wheel append=yes password=”$1$SeDgQgFX$QpKs2kIy7BO7EGk8ipoVM1″
tags:
– aaaa
– name: mkdir .ssh
file: path=/home/aaaa/.ssh state=directory
tags:
– aaaa
– name: copy key
copy: src=/ansible/user/files/aaaa/authorized_keys dest=/home/aaaa/.ssh/
tags:
– aaaa
– name: change owner
shell: chown -R aaaa.aaaa /home/aaaa/.ssh
tags:
– aaaa
– name: change mod keys
shell: chmod 600 /home/aaaa/.ssh/authorized_keys
tags:
– aaaa
– name: modify sudoers
lineinfile: dest=/etc/sudoer regexp=”^%wheel ALL=(ALL)” line=”%wheel ALL=(ALL) NOPASSWD: ALL”
这里真正的密码并不是$1$SeDgQgFX$QpKs2kIy7BO7EGk8ipoVM1,这是123加密之后的密码,这样既安全又方便