Add things
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +0,0 @@
|
|||||||
# ---> Ansible
|
|
||||||
*.retry
|
|
||||||
|
|
||||||
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
|||||||
MIT License Copyright (c) <year> <copyright holders>
|
MIT License Copyright (c) 2021 uumas
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
28
roles/docker/tasks/main.yml
Normal file
28
roles/docker/tasks/main.yml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
apt:
|
||||||
|
name:
|
||||||
|
- apt-transport-https
|
||||||
|
- ca-certificates
|
||||||
|
- curl
|
||||||
|
- gnupg
|
||||||
|
- lsb-release
|
||||||
|
update_cache: yes
|
||||||
|
|
||||||
|
- name: Add docker repo signing key
|
||||||
|
apt_key:
|
||||||
|
id: '9DC858229FC7DD38854AE2D88D81803C0EBFCD88'
|
||||||
|
url: 'https://download.docker.com/linux/debian/gpg'
|
||||||
|
- name: Add docker repo
|
||||||
|
apt_repository:
|
||||||
|
repo: "deb [arch=amd64] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable"
|
||||||
|
filename: 'docker'
|
||||||
|
mode: '644'
|
||||||
|
|
||||||
|
- name: Install docker
|
||||||
|
apt:
|
||||||
|
name:
|
||||||
|
- docker-ce
|
||||||
|
- docker-ce-cli
|
||||||
|
- containerd.io
|
||||||
5
roles/packages/tasks/main.yml
Normal file
5
roles/packages/tasks/main.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Install packages
|
||||||
|
apt:
|
||||||
|
name: "{{ install_packages }}"
|
||||||
6
roles/ssh/handlers/main.yml
Normal file
6
roles/ssh/handlers/main.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: restart ssh
|
||||||
|
systemd:
|
||||||
|
name: ssh
|
||||||
|
state: restarted
|
||||||
28
roles/ssh/tasks/main.yml
Normal file
28
roles/ssh/tasks/main.yml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Disable SSH root login without password
|
||||||
|
lineinfile:
|
||||||
|
path: /etc/ssh/sshd_config
|
||||||
|
regexp: '^#?PermitRootLogin .*$'
|
||||||
|
line: "PermitRootLogin prohibit-password"
|
||||||
|
state: present
|
||||||
|
validate: '/usr/sbin/sshd -t -f %s'
|
||||||
|
notify: restart ssh
|
||||||
|
|
||||||
|
- name: Disable PasswordAuthentication
|
||||||
|
lineinfile:
|
||||||
|
path: /etc/ssh/sshd_config
|
||||||
|
regexp: '^#PasswordAuthentication .*$'
|
||||||
|
line: "PasswordAuthentication no"
|
||||||
|
state: present
|
||||||
|
validate: '/usr/sbin/sshd -t -f %s'
|
||||||
|
notify: restart ssh
|
||||||
|
|
||||||
|
- name: Disable X11 forwarding
|
||||||
|
lineinfile:
|
||||||
|
path: /etc/ssh/sshd_config
|
||||||
|
regexp: '^#?X11Forwarding .*$'
|
||||||
|
line: "X11Forwarding no"
|
||||||
|
state: present
|
||||||
|
validate: '/usr/sbin/sshd -t -f %s'
|
||||||
|
notify: restart ssh
|
||||||
22
roles/users/tasks/main.yml
Normal file
22
roles/users/tasks/main.yml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Create users
|
||||||
|
user:
|
||||||
|
name: "{{ item.name }}"
|
||||||
|
password: "{{ item.password }}"
|
||||||
|
shell: "{{ item.shell | default('/bin/bash') }}"
|
||||||
|
groups:
|
||||||
|
- sudo
|
||||||
|
loop: "{{ users }}"
|
||||||
|
|
||||||
|
- name: Set ssh authorized keys for users
|
||||||
|
authorized_key:
|
||||||
|
user: "{{ item.name }}"
|
||||||
|
key: "{{ item.ssh_pubkey }}"
|
||||||
|
loop: "{{ users }}"
|
||||||
|
|
||||||
|
- name: Disable login as root with ssh key
|
||||||
|
file:
|
||||||
|
path: /root/.ssh/authorized_keys
|
||||||
|
state: absent
|
||||||
|
when: ansible_user | default('') != 'root'
|
||||||
Reference in New Issue
Block a user