commit 63e5df153de43789cf70bf1a1baf755f833ae048 Author: Joe Groocock Date: Sun Jul 12 09:50:30 2020 +0100 Add users and ssh service Signed-off-by: Joe Groocock diff --git a/states/sshd/init.sls b/states/sshd/init.sls new file mode 100644 index 0000000..5c100c5 --- /dev/null +++ b/states/sshd/init.sls @@ -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 diff --git a/states/top.sls b/states/top.sls new file mode 100644 index 0000000..a5c0bee --- /dev/null +++ b/states/top.sls @@ -0,0 +1,4 @@ +{{ saltenv }}: + '*': + - users + - sshd diff --git a/states/users/init.sls b/states/users/init.sls new file mode 100644 index 0000000..b28e39d --- /dev/null +++ b/states/users/init.sls @@ -0,0 +1,19 @@ +{%- import '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 %} diff --git a/states/users/users.jinja b/states/users/users.jinja new file mode 100644 index 0000000..9eb025f --- /dev/null +++ b/states/users/users.jinja @@ -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/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