Add users and ssh service
Signed-off-by: Joe Groocock <me@frebib.net>
This commit is contained in:
commit
7677dd6df4
14
states/sshd/init.sls
Normal file
14
states/sshd/init.sls
Normal file
@ -0,0 +1,14 @@
|
||||
include:
|
||||
- users
|
||||
|
||||
openssh-client:
|
||||
pkg.installed:
|
||||
- version: latest
|
||||
|
||||
sshd-service:
|
||||
service.running:
|
||||
- name: ssh
|
||||
- enable: true
|
||||
- require:
|
||||
- sls: users
|
||||
- pkg: openssh-client
|
4
states/top.sls
Normal file
4
states/top.sls
Normal file
@ -0,0 +1,4 @@
|
||||
{{ saltenv }}:
|
||||
'*':
|
||||
- users
|
||||
- sshd
|
19
states/users/init.sls
Normal file
19
states/users/init.sls
Normal file
@ -0,0 +1,19 @@
|
||||
{%- import_yaml 'users/users.jinja' as users %}
|
||||
|
||||
{%- if users is not mapping %}
|
||||
{%- do raise('users/users.jinja is malformed') %}
|
||||
{%- endif %}
|
||||
|
||||
{%- for name, user in users %}
|
||||
{{ name|json }}:
|
||||
user.present:
|
||||
usergroup: true
|
||||
createhome: true
|
||||
groups: {{ user.get('groups', [])|json }}
|
||||
{%- if user.password is defined %}
|
||||
password: {{ user.password|json }}
|
||||
{%- endif %}
|
||||
{%- if user.shell is defined %}
|
||||
shell: {{ user.shell }}
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
17
states/users/users.jinja
Normal file
17
states/users/users.jinja
Normal file
@ -0,0 +1,17 @@
|
||||
{%- set sudo_group = 'sudo' if grains.os|lower == 'debian' else 'wheel' %}
|
||||
|
||||
frebib:
|
||||
groups:
|
||||
- {{ sudo_group }}
|
||||
ssh-keys:
|
||||
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINk+sOUEXKsGqITyMhna9v77ADGagkr3YMpgZFkrvqcd frebib@frebib-PC
|
||||
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBIGxhZPQM/3Ck+DNNM0CoIZTsvKqQLKq8fqQoO6fXzX frebib@frebib-OnePlus3
|
||||
|
||||
adam:
|
||||
groups:
|
||||
- {{ sudo_group }}
|
||||
ssh-keys:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAiF/WxxMOOE/r8I/anF8gKarjNFmeoPuXNMYE0Hwo/NMqbJ9qKVONn+4fa5T99yhhAnYy92PBPxjmSsOqex28XZFh4I4GBGKh+Su1tJKLXsts1rbJmB1gSpKGbbjsiZcta4FqbiLKyUGL1wiV6GWucKdkC9lfTfocmH20tLbqSTryTAfy62oaEyEUSSATcwnl6ITF6BaQVGT8e78O4DpMYvYXFDa0nre0GlBigI0bAIHknmo+5JuL9i6RbnLr/zHMBiT3lnqQ8IO0JLNJD3ML/X/vgo3Htd6ovKe28YBi+LV+olpcFlQGSpNj+gE67UYb+Hw4mMTjzG4RhNHfQZCrNw== adampc
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDYo04d3a7J22F0NlAM1MeqmZrbF7iaF9p9whLQmq/gYgZnFKtW7G/rQCUUG5X8yEn5LXkc9SYdRceyaleNDAe0/uEJIbbm+VPgkShV+pyA8AbP4+OF95JKgCS6/B59IStF8GrVnX9krjYLYVwS3FqwvYt/ZkYriX4hkaTkf3FslLU7eEwrDec3RuGXhTDTdLdFyq6wXsI/bITX2C0b8D5obNNkyPJFVV1zshy9mQ5/5wjHYLyZhUSRzcY6xDOlxWmTSHseYG1U5espgba7t6ZaL/n44IrXzFsuXRIA74rx3ESAtCEesM3TaPI/Q8dHOYsCdDquTyccP/nEkDCxxhl3 adam-laptop
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC1V9+YmjPyOVdN4tj0MvyyZ4ZMZWkkTeQqEmRRNN0JcogunG97vo32UiZnt2gSPLZjutK5ql1SGTdgbaoSU4ci5vkKjhB8FpozupzvIy2qZ35v2K3eMsU43bLNY23R+ixDpXWkDgXQSVXTZdK3v/zNtDU3RE8vOqa9GFNl9DCGr+ppGfGxWOR6SMcuHu26dZf8pges3D23465kVz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