InfraOps is an infrastructure automation project using Ansible to provision and manage services such as:
- Nginx (Web server & reverse proxy)
- Docker (Container management)
- PostgreSQL (Database)
- Grafana (Monitoring & visualization)
- Prometheus (Metrics collection & alerting)
Ensure you have the following installed:
- Ansible (>=2.9)
- SSH access to target servers
- Python (>=3.6)
You can install this role from Ansible Galaxy:
ansible-galaxy install nguyentuan1696.infra-ops
More details at: Ansible Galaxy - InfraOps
- Clone the repository:
git clone https://github.com/nguyentuan1696/infraops.git
cd infraops
- Configure your inventory in inventory.yml:
all:
hosts:
web:
ansible_host: 127.0.0.1
ansible_user: root
- Run the Ansible playbook
ansible-playbook -i inventory.yml playbook.yml
infra-ops/
├── group_vars/
├── meta/
├── roles/
│ ├── docker/
│ ├── grafana/
│ ├── nginx/
│ ├── postgresql/
│ └── prometheus/
├── .DS_Store
├── .gitignore
├── Makefile
├── README.md
├── inventory.yml
└── playbook.yml
Notes:
- group_vars/: Contains group variables used in Ansible.
- meta/: Contains metadata information for Ansible.
- roles/: Contains Ansible roles for each service:
- docker/: Role for installing and configuring Docker.
- grafana/: Role for installing and configuring Grafana.
- nginx/: Role for installing and configuring Nginx.
- postgresql/: Role for installing and configuring PostgreSQL.
- prometheus/: Role for installing and configuring Prometheus.
- .gitignore: File that specifies files and directories Git should ignore.
- Makefile: File containing automation commands.
- README.md: File with instructions and information about the project.
- inventory.yml: Inventory file defining target servers for Ansible.
- playbook.yml: Main playbook file to execute roles.
Once deployed, access Grafana at: http://your-server-ip:9090
-
Access the Server: Log in to your server and create an SSH key.
ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa_ansible -N ""
-
Add the Public Key: Append the contents of
id_rsa_ansible.pub
to theauthorized_keys
file to allow SSH access.cat ~/.ssh/id_rsa_ansible.pub >> ~/.ssh/authorized_keys
-
Set Correct Permissions: Ensure that the permissions for the
authorized_keys
file and the.ssh
directory are set correctly to enhance security.chmod 600 ~/.ssh/authorized_keys chmod 700 ~/.ssh
-
Copy the Private Key: Make sure to securely copy the contents of
~/.ssh/id_rsa_ansible
to your local machine or wherever you need to use it.cat ~/.ssh/id_rsa_ansible
- Keep your private key secure and do not share it publicly.
- Ensure that the SSH service is running on your server to allow connections.
- If you encounter any issues, check the SSH configuration and firewall settings.
To completely remove PostgreSQL from your system, follow these steps:
sudo systemctl stop postgresql
sudo apt remove --purge postgresql postgresql-*
sudo rm -rf /var/lib/postgresql/
sudo rm -rf /etc/postgresql/
sudo rm -rf /etc/postgresql-common/
sudo rm -rf /var/log/postgresql/
sudo deluser postgres
sudo delgroup postgres
sudo apt autoremove
sudo apt autoclean
Check if any PostgreSQL-related services or files are still present:
psql --version
or
dpkg -l | grep postgresql
Feel free to open issues and pull requests
MIT License
For any inquiries, reach out via email: nguyentuan1696@gmail.com or telegram: @nguyentuan1696