|
7 months ago | |
---|---|---|
bin | 9 months ago | |
inventory | 9 months ago | |
roles | 9 months ago | |
ssh | 7 months ago | |
.gitignore | 7 months ago | |
LICENSE | 1 year ago | |
README.md | 8 months ago | |
site.yml | 9 months ago |
README.md
Ansible — Basic Setup for Ubuntu 20.04/Debian 11
The Ansible playbook in this repository performs the following tasks,
- Update apt repositories
- Install and configure fail2ban for SSH
- Install daily rootkit detection scripts using chkrootkit and rkhunter
- Install and configure swap space equal to total memory
- Disable snapd on Ubuntu for lower memory consumption
- Install weekly script to update and reboot the system
Code Mirrors
- GitHub: github.com/k3karthic/ansible__ubuntu-basic
- Codeberg: codeberg.org/k3karthic/ansible__ubuntu-basic
Local Instance
Configuration
The file roles/swap/vars/main.yml
contains the following variables that you can change,
- swap_file_path: File path for the swapfile. (Default: /swapfile.swap)
- swap_swappiness: Kernel parameter to change how often it will use swap. (Default: 60)
Deployment
Run the playbook using the following command,
$ ./bin/apply_local.sh
Oracle Cloud Instance
Assumption: The instance runs in Oracle Cloud using either of the scripts below,
- terraform__oci-instance-1
- terraform__oci-instance-2
Requirements
Install the following before running the playbook,
$ pip install oci
$ ansible-galaxy collection install oracle.oci
Dynamic Inventory
The Oracle Ansible Inventory Plugin populates public Ubuntu instances.
All target Ubuntu instances must have the freeform tag os: ubuntu
.
Configuration
- Update
inventory/oracle.oci.yml
,- Specify the region where you have deployed your server on Oracle Cloud. List of regions are at docs.oracle.com/en-us/iaas/Content/General/Concepts/regions.htm.
- Configure the authentication as per the Oracle Guide
- Set username and ssh authentication in
inventory/group_vars/
To use more than a single SSH keypair (with passphrases), use ssh-agent to store them.
Run the following command to start ssh-agent
,
$ eval "$(ssh-agent -s)"
Add each keypair using the following command,
$ ssh-add <path to keypair>
Swap
The file roles/swap/vars/main.yml
contains the following variables that you can change,
- swap_file_path: File path for the swapfile. (Default: /swapfile.swap)
- swap_swappiness: Kernel parameter to change how often it will use swap. (Default: 60)
Deployment
Run the playbook using the following command,
$ ./bin/apply.sh
Encryption
Encrypt sensitive files (SSH private keys) before saving them. .gitignore
must contain the unencrypted file paths.
Use the following command to decrypt the files after cloning the repository,
$ ./bin/decrypt.sh
Use the following command after running terraform to update the encrypted files,
$ ./bin/encrypt.sh <gpg key id>