Compare commits
2 Commits
b40a5826fe
...
22d968e1a6
Author | SHA1 | Date | |
---|---|---|---|
![]() |
22d968e1a6 | ||
![]() |
3ed66111cf |
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) <year> <copyright holders>
|
||||
Copyright (c) 2022 Oleg "Zmey!" Vasiliev
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
43
tasks/main.yml
Normal file
43
tasks/main.yml
Normal file
@@ -0,0 +1,43 @@
|
||||
---
|
||||
|
||||
- name: Users | Install sudo package
|
||||
package:
|
||||
name: sudo
|
||||
state: present
|
||||
|
||||
- name: Users | Deploy /etc/sudoers
|
||||
template:
|
||||
src: sudoers.j2
|
||||
dest: /etc/sudoers
|
||||
mode: 0440
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: Users | Create groups
|
||||
group:
|
||||
name: "{{ item.name }}"
|
||||
state: present
|
||||
with_items: "{{ os_groups | default([]) }}"
|
||||
|
||||
- name: Users | Create users
|
||||
user:
|
||||
name: "{{ item.name }}"
|
||||
state: "{{ item.state | default(omit) }}"
|
||||
home: "{{ item.home | default(omit) }}"
|
||||
move_home: yes
|
||||
shell: "{{ item.shell | default(omit) }}"
|
||||
password: "{{ item.password | default(omit) }}"
|
||||
groups: "{{ item.groups | default(omit) }}"
|
||||
append: no
|
||||
system: "{{ item.system | default(omit) }}"
|
||||
with_items: "{{ os_users }}"
|
||||
|
||||
- name: Users | Deploy ssh public keys
|
||||
authorized_key:
|
||||
exclusive: yes
|
||||
user: "{{ item.name }}"
|
||||
key: "{{ lookup(item.lookup, item.keys_source) }}"
|
||||
with_items: "{{ os_users }}"
|
||||
when:
|
||||
- item.lookup is defined
|
||||
- item.keys_source is defined
|
11
templates/sudoers.j2
Normal file
11
templates/sudoers.j2
Normal file
@@ -0,0 +1,11 @@
|
||||
# {{ ansible_managed }}
|
||||
|
||||
root ALL=(ALL) ALL
|
||||
|
||||
%sudo ALL=(ALL) NOPASSWD: ALL
|
||||
|
||||
{% for user in managed_users %}
|
||||
{% if user.sudoer %}
|
||||
{{ user.name }} ALL=(ALL) NOPASSWD: ALL
|
||||
{% endif %}
|
||||
{% endfor %}
|
Reference in New Issue
Block a user