cat roles/createuser.yaml
---
- hosts: test
tasks:
- name: create user
user:
name: "{{item.user}}"
password: "{{ item.pass | password_hash('sha512') }}"
createhome: yes
state: present
shell: "/bin/bash"
loop:
- { user: ops,pass:ops }
- name: Config /etc/sudoers
lineinfile: dest=/etc/sudoers state=present line='{{item}}' validate='visudo -cf %s'
with_items:
- "ops ALL=(ALL) ALL "
- "Defaults: ops !requiretty"
- 我的微信
- 这是我的微信扫一扫
- 我的微信公众号
- 我的微信公众号扫一扫