LINUX.ORG.RU

История изменений

Исправление i3wm, (текущая версия) :

Решил)
Благодарю за столь интересную задачу.

Screenshot: https://imgur.com/a/MxWHxCq

---
- name: User create
  hosts: localhost 
  gather_facts: yes
  become: yes
  become_method: sudo

  vars:
    users:
      - name: woozymasta
        enabled: yes
        sudoers: yes
        comment: 'Woozy Masta'
        shell: '/bin/bash'
        groups: [ wheel, sudo ]

      - name: woozy
        enabled: yes
        sudoers: yes
        comment: 'Woozy Masta'
        shell: '/bin/bash'
        groups: [ wheel, adm ]

      - name: masta
        enabled: yes
        sudoers: yes
        comment: 'Woozy Masta'
        shell: '/bin/bash'
        groups: [ sudo, wheel ]

  tasks:
  - name: Get available groups list
    getent:
      database: 'group'
      split: ':'
  
  - name: "This command will only run if {{ item }} is a non-empty group that exists"
    user:
      name: "{{ item.0.name }}"
      append: yes
      comment: "{{ item.0.comment }}"
      shell: "{{ item.0.shell }}"
      groups: "{{ item.1 }}"
    when: item.1 in getent_group
    with_subelements: 
     - "{{ users }}"
     - groups

Исправление i3wm, :

Решил)

Screenshot: https://imgur.com/a/MxWHxCq

---
- name: User create
  hosts: localhost 
  gather_facts: yes
  become: yes
  become_method: sudo

  vars:
    users:
      - name: woozymasta
        enabled: yes
        sudoers: yes
        comment: 'Woozy Masta'
        shell: '/bin/bash'
        groups: [ wheel, sudo ]

      - name: woozy
        enabled: yes
        sudoers: yes
        comment: 'Woozy Masta'
        shell: '/bin/bash'
        groups: [ wheel, adm ]

      - name: masta
        enabled: yes
        sudoers: yes
        comment: 'Woozy Masta'
        shell: '/bin/bash'
        groups: [ sudo, wheel ]

  tasks:
  - name: Get available groups list
    getent:
      database: 'group'
      split: ':'
  
  - name: "This command will only run if {{ item }} is a non-empty group that exists"
    user:
      name: "{{ item.0.name }}"
      append: yes
      comment: "{{ item.0.comment }}"
      shell: "{{ item.0.shell }}"
      groups: "{{ item.1 }}"
    when: item.1 in getent_group
    with_subelements: 
     - "{{ users }}"
     - groups

Исправление i3wm, :

Запускал только в Check Mode.
Негде протестировать. :(

Screenshot: https://imgur.com/a/MxWHxCq

---
- name: User create
  hosts: localhost 
  gather_facts: yes
  become: yes
  become_method: sudo

  vars:
    users:
      - name: woozymasta
        enabled: yes
        sudoers: yes
        comment: 'Woozy Masta'
        shell: '/bin/bash'
        groups: [ wheel, sudo ]

      - name: woozy
        enabled: yes
        sudoers: yes
        comment: 'Woozy Masta'
        shell: '/bin/bash'
        groups: [ wheel, adm ]

      - name: masta
        enabled: yes
        sudoers: yes
        comment: 'Woozy Masta'
        shell: '/bin/bash'
        groups: [ sudo, wheel ]

  tasks:
  - name: Get available groups list
    getent:
      database: 'group'
      split: ':'
  
  - name: "This command will only run if {{ item }} is a non-empty group that exists"
    user:
      name: "{{ item.0.name }}"
      append: yes
      comment: "{{ item.0.comment }}"
      shell: "{{ item.0.shell }}"
      groups: "{{ item.1 }}"
    when: item.1 in getent_group
    with_subelements: 
     - "{{ users }}"
     - groups

Исправление i3wm, :

Запускал только в Check Mode.
Негде протестировать. :(

Screenshot: https://imgur.com/a/JHig6E4

---
- name: User create
  hosts: localhost 
  gather_facts: yes
  become: yes
  become_method: sudo

  vars:
    users:
      - name: woozymasta
        enabled: yes
        sudoers: yes
        comment: 'Woozy Masta'
        shell: '/bin/bash'
        groups: [ wheel, sudo ]

      - name: woozy
        enabled: yes
        sudoers: yes
        comment: 'Woozy Masta'
        shell: '/bin/bash'
        groups: [ wheel, adm ]

      - name: masta
        enabled: yes
        sudoers: yes
        comment: 'Woozy Masta'
        shell: '/bin/bash'
        groups: [ sudo, wheel ]

  tasks:
  - name: Get available groups list
    getent:
      database: 'group'
      split: ':'
  
  - name: "This command will only run if {{ item }} is a non-empty group that exists"
    user:
      name: "{{ item.0.name }}"
      append: yes
      comment: "{{ item.0.comment }}"
      shell: "{{ item.0.shell }}"
      groups: "{{ item.1 }}"
    when: item.1 in getent_group
    with_subelements: 
     - "{{ users }}"
     - groups

Исходная версия i3wm, :

Запускал только в Check Mode.
Негде протестировать. :(

Screenshot: https://imgur.com/a/JHig6E4

---
- name: User create
  hosts: localhost 
  gather_facts: yes
  become: yes
  become_method: sudo

  vars:
    users:
      - name: woozymasta
        enabled: yes
        sudoers: yes
        comment: 'Woozy Masta'
        shell: '/bin/bash'
        groups: [ wheel, sudo ]

      - name: woozy
        enabled: yes
        sudoers: yes
        comment: 'Woozy Masta'
        shell: '/bin/bash'
        groups: [ wheel, adm ]

      - name: masta
        enabled: yes
        sudoers: yes
        comment: 'Woozy Masta'
        shell: '/bin/bash'
        groups: [ sudo, wheel ]

  tasks:
  - name: Get available groups list
    getent:
      database: 'group'
      split: ':'
  
  - name: "This command will only run if {{ item }} is a non-empty group that exists"
    user:
      name: "{{ item.0.name }}"
      comment: "{{ item.0.comment }}"
      shell: "{{ item.0.shell }}"
      groups: "{{ item.1 }}"
    when: item.1 in getent_group
    with_subelements: 
     - "{{ users }}"
     - groups