📦 NEW: Ansible.md Help File

This commit is contained in:
Yuri Lima
2023-09-07 15:08:07 +01:00
parent e8e1699485
commit 4549d7ccf2

73
ansible.md Normal file
View File

@@ -0,0 +1,73 @@
# Server SetUp for Ansible
## Create ssh key ed25519
```bash
ssh-keygen -t ed25519 -C "any-name"
```
## Copy ssh key to server
```bash
ssh-copy-id -i ~/.ssh/id_ed25519.pub user@hostIP
```
## Create Server on Hetzner [details]
1. Machine was created CX21 with SSH Private and Public Key Ed25519 by OnePassword
2. Get private key from OnePassword and save it to ~/.ssh/id_ed25519
3. Get public key from OnePassword and save it to ~/.ssh/id_ed25519.pub
4. Add private key to ~/.ssh/config [Optional]
## Disabling Password Authentication on our Server
1. Open the SSH configuration file
```bash
sudo nano /etc/ssh/sshd_config
```
2. Find the line that specifies PasswordAuthentication, uncomment it and set its value to no
```bash
PasswordAuthentication no
```
3. Save and close the file
4. Restart the SSH service
```bash
sudo systemctl restart ssh
```
## Given Permission to use SSH Key
Change the permissions to 700:
The keys need to be read-writable by the owner only:
```bash
chmod 700 ~/.ssh/[KEY_NAME]
```
## Accesing the server with SSH Key Specifiing the ley Path Directly=
```bash
ssh -i ~/.ssh/[KEY_NAME] [USER]@[HOST]
```
## Helpfull Links
- [How to Create SSH Keys with Ed25519](https://phoenixnap.com/kb/ssh-with-key)
- [How To Configure SSH Key-Based Authentication on a Linux Server](https://www.digitalocean.com/community/tutorials/how-to-configure-ssh-key-based-authentication-on-a-linux-server)
# Ansible
## Ansible Steps
1. Create Inventory
2. Create Playbook
3. Create Roles
4. Create Tasks
5. Create Handlers
6. Create Templates
7. Create Vars
## Inventory
- Invetory is a file that contains a list of hosts that we want to manage with Ansible
## Playbook
- Playbook is a file that contains a list of plays
- Play is a file that contains a list of tasks
- Task is a file that contains a list of modules
- Module is a file that contains a list of commands
## Roles
- Roles is a folder that contains a list of tasks, handlers, templates, vars, defaults, files, meta, and tests