Ansible Module - Users and Groups

ansible-user-doc

  • expire user accout: expires

create a user named admin with group: admin and uid: 2048

- hosts: all
  gather_facts: no
  tasks:
    - group:
      name: admin
  - user:
      name: admin
      group: admin
      uid: 2048

Create a user account with username testman that would be expiring after 3 years. The expires option on the users module is in the epoch. So Sunday, December 31, 2023 11:59:59 PM GMT== 1704067199 as epoch time

- hosts: all
  gather_facts: no
  tasks:
    - user:
        name: 'testman'
        expires: 1704067199

사용자 계정, 그룹 삭제

- hosts: all
  gather_facts: no
  tasks:
    - user:
        name: 'admin'
        state: absent
    - group:
        name: 'admin'
        state: absent

좋은 웹페이지 즐겨찾기