These are the list of resource, one will need to start a Penetration Testing Course..
Hello everyone, welcome to my Blog, This is Tchize Matias a confessed and Graduated Ethical Hacker turned into DevSecOps Engineer. If sort of thing even exist. I am writing this blog as mean to keep track of my journey into becoming a professional Ethical Hacker ..
This is an exciting experiment of mine as DevOps. As I am experimenting with the Tools available ... So, the quest is to "Vagrantfile which creates 3 instances of Centos 8 servers, each server shall be able to connect on the same network for easy communication"
Here is what we want to achieve:
- Build 3 servers to use Ansible
Jumped into via ChatGPT via Bing Copilot and created the following prompt.
"Hi Copilot, can you write a Vagrantfile which creates 3 instances of Centos 8 servers, each server shall be able to connect on the same network for easy communication, these instance serves are to be used as Ansible Lab environments comprised of one Ansible Tower and two deployments environments, please"
The output:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# Define the base box
config.vm.box = "centos/8"
# Ansible Tower Server
config.vm.define "ansible_tower" do |ansible_tower|
ansible_tower.vm.hostname = "ansible-tower"
ansible_tower.vm.network "private_network", ip: "192.168.56.10"
end
# Deployment Environment 1
config.vm.define "deploy_env1" do |deploy_env1|
deploy_env1.vm.hostname = "deploy-env1"
deploy_env1.vm.network "private_network", ip: "192.168.56.11"
end
# Deployment Environment 2
config.vm.define "deploy_env2" do |deploy_env2|
deploy_env2.vm.hostname = "deploy-env2"
deploy_env2.vm.network "private_network", ip: "192.168.56.12"
end
# Provisioning with Ansible (Optional)
# config.vm.provision "ansible" do |ansible|
# ansible.playbook = "playbook.yml"
# end
end
Save the above code into a file named Vagrantfile.
Open a terminal and navigate to the directory containing the Vagrantfile.
Run vagrant up to create the VMs.
This Vagrantfile configures each CentOS 8 server with a static IP on a private network, allowing them to communicate with each other. You can uncomment and adjust the Ansible provisioning block to run your Ansible playbooks automatically.
You’ll have three CentOS 8 servers (server1, server2, and server3) along with an Ansible Tower instance (ansible-tower) for your lab environment. Adjust memory and CPU settings as needed based on your system resources.
Happy Ansible-ing! 🚀
Next -
To test the Ansible connection to the three CentOS 8 servers you've set up, you can use a simple Ansible playbook that employs the ping module. This module is specifically designed for connection testing and doesn't actually send ICMP pings but attempts an SSH connection and returns pong on success.
Here's an example playbook, test_connection.yml, that you can use:
Before running the playbook, ensure you have an inventory file (inventory.ini or your preferred name) that lists the IPs or hostnames of your servers under a group [servers] or individually. Here's an example:
This command will attempt to connect to each server listed in inventory.ini and report back whether the connection was successful. ....
Nice !! Now, let us push this code further .. I have tested the script on my machine and Made all 3 instances up and running. Further improved the code and stored in Github source code here