This Ansible project is designed to automate the configuration and management of servers running Oracle Linux and Ubuntu. It includes roles and plays for updating local repositories, performing system updates, and configuring different types of servers such as web servers, database servers, and file servers.
Author: Stanley Chinedu Ogada
-
roles/base/: Role for updating the public key of theogauser.web_servers/: Role for configuring web servers.db_servers/: Role for configuring database servers.file_servers/: Role for configuring file servers.
-
sys_config.yml: Main Ansible playbook containing plays for updating repositories, updating all servers, and configuring specific server types. -
bootstrap.yml: Create theogauser, add him to sudoers, and finally make him run sudo commands with a password, thus eliminating the-Kin ansible ad-hoc commands
Before running the playbooks, ensure the following prerequisites are met:
-
User Setup:
- Create a user named
zeroon all target servers with sudo access. - Ensure that the password for the
zerouser is the same across all servers.
- Create a user named
-
SSH Public Key Authentication:
- Set up SSH public key authentication from the control host to each server for the
zerouser. - Make sure that the control host can SSH into each server without entering a password.
- Set up SSH public key authentication from the control host to each server for the
-
Ad-Hoc Command Password:
- When using Ansible ad-hoc commands, provide the
--ask-becomeor-Koption to enter the sudo password for thezerouser.
ansible-playbook bootstrap.yml ays_config.yml -K
- Run the above ad-hoc once hence the name bootstrap
- After a successful run you may remove the
-Kas the user calledogais now the active remote user and doesn’t require a password to use sudo
- When using Ansible ad-hoc commands, provide the
-
Ensure Ansible is installed on the control machine.
apt install ansible
-
Clone the repository.
git clone https://github.com/stanleyogada/ingryd-ansible-project/.git cd ingryd-ansible-project -
Edit the inventory file (
inventory.ini) to specify your target servers and their groups (web_servers, db_servers, file_servers). -
Review and customize the variables in the roles based on your server configurations.
-
Run the playbook.
ansible-playbook sys_config.yml
- Description: This play updates the local repositories for Oracle Linux and Ubuntu servers.
- Description: This play installs updates for all servers.
- Description: This play configures servers designated as web servers using the
web_serversrole.
- Description: This play configures servers designated as database servers using the
db_serversrole.
- Description: This play configures servers designated as file servers using the
file_serversrole.
update: Used for plays related to updating servers.oracleLinux: Used for tasks specific to Oracle Linux.ubuntu: Used for tasks specific to Ubuntu.
- Ensure you have the necessary permissions to perform system updates and configurations on the target servers.
- Monitor the playbook execution for any errors or warnings.
- Customize variables and configurations in roles based on your specific requirements.
Feel free to contribute to this Ansible project or raise issues if you encounter any problems. Happy automating!
Note: This documentation was authored by Stanley Chinedu Ogada. If you have any questions or encounter issues, feel free to reach out for personalized assistance.