{"id":22983014,"url":"https://github.com/yatingambhir85/ansible-practice","last_synced_at":"2025-07-07T01:33:10.695Z","repository":{"id":217474401,"uuid":"743936727","full_name":"Yatingambhir85/Ansible-Practice","owner":"Yatingambhir85","description":"Repository for Ansible includes Playbook and Inventory files","archived":false,"fork":false,"pushed_at":"2024-01-16T12:29:52.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-08T01:28:31.885Z","etag":null,"topics":["ansible","ansible-inventory","ansible-playbook","devops"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Yatingambhir85.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-16T09:56:07.000Z","updated_at":"2024-01-16T11:29:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"ba7146b9-6c44-43bc-8979-dfdcf4e40f1f","html_url":"https://github.com/Yatingambhir85/Ansible-Practice","commit_stats":null,"previous_names":["yatingambhir85/ansible-practice"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yatingambhir85%2FAnsible-Practice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yatingambhir85%2FAnsible-Practice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yatingambhir85%2FAnsible-Practice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yatingambhir85%2FAnsible-Practice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yatingambhir85","download_url":"https://codeload.github.com/Yatingambhir85/Ansible-Practice/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246794206,"owners_count":20834938,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","ansible-inventory","ansible-playbook","devops"],"created_at":"2024-12-15T02:34:30.608Z","updated_at":"2025-07-07T01:33:10.686Z","avatar_url":"https://github.com/Yatingambhir85.png","language":null,"readme":"#############################\n### Author: Yatin Gambhir\n### Date: 16 January 2024\n### Topic: Ansible Setup\n################################\n\nStep 1 - To install Ansible on your machine, launch two EC2 instances one with \"ansible-master\" \u0026 \"ansible-server1\" and SSH into the \"ansible-master\" server by opening Command Prompt and using the below commands.\n- ssh -i \"private-key-path.pem\" 'username'@'public-ip-address' #To login into the server\n\nOn successful logging in update the packages and install ansible:\n\n- sudo apt update\n- sudo apt install ansible \n\nUpon successful installation of Ansible verify it using the: \n- ansible --version\n\nStep 2 - Your ansible is successfully installed on the master node. Now we have ssh into the other server, so for that do the below steps:\n - Open the private key file in your Master Node and copy the content of your private key file\n - Now in the Agent node do \"cd  ~/.ssh\" where your private key file will be stored\n - Create a new file using \"nano ansible_key\" and copy the content of the private key and save the file\n - Give the permissions to the \"~/.ssh\" folder and the \"ansible_key\" file using \"chmod 700 ~/.ssh\" \u0026 \"chmod 600 ~/.ssh/ansible_key\"\n - Now move to the home directory using the \"cd\" command and try to login into the target server using \"ssh -i ~/.ssh/ansible_key 'username'@'public_ip'\". You will see that you are connected with the target server.\n - Logout from the target server to go to the master server\n\n Step 3 - Now we will use the Ansible to test the connection. Follow the below steps and create an inventory file that includes all the target servers.\n  - mkdir ansible\n  - nano hosts (The sample of hosts file is included in my Github repository)\n\nStep 4 - To check whether my host file (according to the GitHub repo) is correct use the below command:\n\n - ansible-inventory server -m ping -i inventory_file (/home/ubuntu/ansible/hosts) --private-key=ansible_ssh_private_key (~/.ssh/ansible_key)\n () - for your reference\n\nYOU SHOULD SEE THAT THE RESULT IS SUCCESS AND OUTPUT IS 'ping':'pong'.\n\n--OUR CONNECTION TO THE TARGET SERVER is SUCCESSFULLY CONFIGURED.--\n\nNow we will understand the Playbook\n\nStep 1 - I have pushed the three playbooks files where we will see the automation to \"create a file\", \"add a user\" \u0026 \"install docker\" on each server\n\nYOU CAN CHECK THE PLAYBOOK FILES FOR YOUR REFERENCE\n\nStep 2 - After creating the playbook.yaml file enter the below command\n\n- ansible-playbook 'file-name.yaml' -i inventory_file --private-key=ansible_ssh_private_key\n\nThis will do the task you have written inside your playbook file.\n\nStep 3 - To verify if the task is performed connect with the target server and check whether the required task is performed or not.\n\n\nTERMINATE THE INSTANCE AFTER TASK IS PERFORMED\n-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyatingambhir85%2Fansible-practice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyatingambhir85%2Fansible-practice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyatingambhir85%2Fansible-practice/lists"}