ansible 账号授权

---
- name: add libin sudo config
  hosts: task
  gather_facts: no
  tasks:
      - name: jiesuo
        shell: pam_tally2 -u libin -r
      - name: one
        user:
            name: "{{ item.user }}"
            password: "{{ item.passwd | password_hash('sha512') }}"
        with_items:
            - { user: '用户',passwd: '密码' }
            - { user: '用户',passwd: '密码' }
      - name: two
        user:
            name: libin
            groups: wheel
      - name: three
        lineinfile:
            path: /etc/sudoers
            regexp: '^libin'
            line: 'libin ALL=(ALL) NOPASSWD: /usr/sbin/useradd,/usr/sbin/userdel,/usr/sbin/usermod,/usr/sbin/groupadd,/usr/sbin/groupmod,/usr/sbin/groupdel,/usr/bin/chage,/usr/bin/useradd,/usr/bin/userdel,/usr/bin/usermod,/usr/bin/groupadd,/usr/bin/groupmod,/usr/bin/groupdel,/usr/sbin/chage,/usr/bin/passwd [a-zA-Z]*,!/usr/bin/passwd root,/sbin/pam_tally2,/usr/sbin/pam_tally2'

 

posted @ 2023-03-24 17:58  LB_运维技术  阅读(19)  评论(0编辑  收藏  举报