ansible批量创建用户赋予sudo权限

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"
  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin
avatar

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: