{"id":20179055,"url":"https://github.com/pratikshinde55/ansible-setup-onaws","last_synced_at":"2026-05-28T23:31:02.456Z","repository":{"id":225328769,"uuid":"765682800","full_name":"Pratikshinde55/Ansible-setup-onAWS","owner":"Pratikshinde55","description":"Ansible-Master \u0026 Target node Configuration on AWS Cloud using ssh-key Authentication. Latest version of ansible","archived":false,"fork":false,"pushed_at":"2025-02-13T11:07:38.000Z","size":175,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-03T05:41:51.095Z","etag":null,"topics":["ansible","ansible-setup","aws-ec2"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Pratikshinde55.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-03-01T12:10:30.000Z","updated_at":"2025-02-14T08:56:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"5f19020a-168e-40ee-a609-a2e9f098a122","html_url":"https://github.com/Pratikshinde55/Ansible-setup-onAWS","commit_stats":null,"previous_names":["pratikshinde55/ansible-setup-onaws"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Pratikshinde55/Ansible-setup-onAWS","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pratikshinde55%2FAnsible-setup-onAWS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pratikshinde55%2FAnsible-setup-onAWS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pratikshinde55%2FAnsible-setup-onAWS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pratikshinde55%2FAnsible-setup-onAWS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Pratikshinde55","download_url":"https://codeload.github.com/Pratikshinde55/Ansible-setup-onAWS/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pratikshinde55%2FAnsible-setup-onAWS/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33630999,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-setup","aws-ec2"],"created_at":"2024-11-14T02:24:45.982Z","updated_at":"2026-05-28T23:31:02.418Z","avatar_url":"https://github.com/Pratikshinde55.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ansible-Master and target node configuration on AWS cloud using ssh-key Authentication\n![Ansible-Master and target node configuration on AWS cloud using ssh-key Authentication (1)](https://github.com/user-attachments/assets/4d193546-e2a7-4b5f-afc4-6937c62f0bb6)\n\n- About set-up:\n\nI have installed ansible on the top of AWS Cloud EC2 Insatnce, Setup is like I take Three EC2 amazon linux Instances, One of these make Master-node(Ansible-master) and other remaining Two make \nTarget-node.\n(Ansible-node-1,Ansible-node-2).\n\n## On Three(Master \u0026 Target) Instances Following set-up do as it is:\n\n![Screenshot 2024-03-01 153246](https://github.com/Pratikshinde55/Ansible-setup-onAWS/assets/145910708/a96622a1-f8a6-46f4-a850-23ceb89e8ecb)\n\n### Step-1: [Create New/General User I create \"psadmin\" general user for Master-node \u0026 set password]\nCommand for create new user:\n\n    useradd psadmin\n\nCommand for Set password to user:\n    \n    passwd psadmin\n   \n### Step-2: [Give Sudo power to general user \"psadmin\"]\nThe general user don't have so much power like root, So I give the root level power/permission to the general user. The file location is **/etc/sudoers**.\n    \n    vi /etc/sudoers\n\n![Screenshot 2024-03-01 153326](https://github.com/Pratikshinde55/Ansible-setup-onAWS/assets/145910708/3678c115-aa28-406f-827c-3df34969b7e2)\n\n\n### Step-3: [Allow Authentication in sshd config file]\nTo access the EC2 by SSH then we need to change some settings in SSH Config file, The Location of SSH Config file is **/etc/ssh/sshd_config**.\n    \n    vi /etc/ssh/sshd_config\n\n![11](https://github.com/Pratikshinde55/Ansible-setup-onAWS/assets/145910708/b26c3367-0e18-42aa-9031-4adb254a8142)\n\n### Step-4: [Restart sshd service] \nAfter change in the ssh config file then we need to restart that file to apply the new changes.\n\n    systemctl restart sshd\n\n- NOTE: for Target-node 1 \u0026 2 i use general user is \"pratik\" after created user above four steps do as it is in each target nodes.\n\n## On Ansible Master-Node:-\nAfter do 1st four steps then create Key in general user in my case psadmin is general user of my Ansible master node\n\n      su - psadmin\n\nGo inside general user (psadmin) and create key for ssh Authentication:\n \n      ssh-keygen\n\n- Note: **Create ssh key at general user on which we want run ansible command.**\n  \n\n![12](https://github.com/Pratikshinde55/Ansible-setup-onAWS/assets/145910708/c33efb1a-fdff-4d34-8475-e6d4de217dd9)\n\nssh-key created in **.ssh/** folder:\n    \n     cd .ssh/\n     \nShow hidden file:\n\n     ls -l\n\nAfter Key created then need to copy my \"psadmin\" key to host nodes , use follw command to copy key to Target node:\nFormat of ssh key copy to the target:\n\n    ssh-copy-id  \u003cUser_name\u003e@\u003cpublic_ip_of_target_ec2Instance\u003e\n\nCommand for Copy ssh key:\n\n    ssh-copy-id pratik@172.31.44.192\n     \n\n![13](https://github.com/Pratikshinde55/Ansible-setup-onAWS/assets/145910708/4147ebd7-fdc5-4f0f-bee2-e57754dafafb)\n     \n- After key add we also check bye using following Command:\n\nTo add EC2 1st time with SSH we need to do manual, While adding they ask password.\n   \n    ssh pratik@172.31.44.192\n\n- NOTE: Do same Key-copy method to all target nodes .\n\n**........Here our instances is successfully connected by \"ssh\"........**\n\n\n## On master node: [Install Ansible on master node for different version]\nHere i give Steo by step how to download ansible different versions latest/older on AWS Cloud:\n\n### For Amazon-linux2:-  [AMI with python3.8 latest version of \"Ansible-core\" (Latest version of Ansible-core in 2025)]\nWe Install ansible-core latest version with the help of python3.8 because latest version Ansible-core support from python3.8 version.\n![Ansible-version](https://github.com/user-attachments/assets/a88cdc90-bc89-4fbc-b9ab-0222d6190ddc)\n\n1. **Step-1 [Install Python 3.8 Using Amazon Linux Extras]**\n   \n   - Amazon Linux 2 provides an easy way to install newer versions of Python through the Amazon Linux Extras repository.\n\n   - Enable the Python 3.8 repository:\n\n          sudo amazon-linux-extras enable python3.8\n\n   - Install Python 3.8:\n   \n          sudo yum install python3.8\n\n   - Check Install:\n\n          python3.8 --version\n\n2. **Step-2 [Install/Upgrade Ansible-Core Using pip for Python 3.8]**\n   \n   - Now that pip3 for Python 3.8 is installed, we can use it to install or upgrade Ansible-Core.\n\n   - Run the following command to install Ansible using Python 3.8's pip:\n\n          sudo python3.8 -m pip install --upgrade ansible-core\n\n   - Check Ansible Version:\n\n          ansible --version\n\n3. **Step-3 [Create the Configuration File Directory(/etc/ansible/ansible.cfg)]**\n   \n   - Create the `/etc/ansible/` directory: (The -p flag ensures that the directory is created only if it doesn't exist. If it already exists, no error will be thrown.)\n\n          sudo mkdir -p /etc/ansible\n     \n   - Create the ansible.cfg file:\n\n          sudo vim /etc/ansible/ansible.cfg\n   \n   - If you want to create the ansible.cfg file with the default configuration, you can use the ansible-config command:\n\n          sudo ansible-config init --disabled \u003e /etc/ansible/ansible.cfg\n\n   - This will generate a default ansible.cfg file with all options commented out (disabled).\n   \n4. **[Optional- If path is not set of ansible \u0026 ansible cmd not work then use]**\n\n    - Check the Installation Path:\n  \n          which ansible\n\n    - path to the executable have been set correctly: (`~/.bash_profile` is the file where user-specific shell configurations are stored (for bash shell users).)\n  \n           echo 'export PATH=$PATH:/usr/local/bin' \u003e\u003e ~/.bash_profile\n           source ~/.bash_profile\n\n5. **[Optinal- To remove older version of ansible if new version not configure]**\n\n   - Remove Ansible:\n\n          sudo yum remove ansible\n\n6. **sshpass install: [If we don't want share manual public key by using aah-copy-id cmd then use this method]**\n\n   - Install the `epel-release` package:(This is for amazon linux2 AMI to enable to download sshpass)\n\n   - Enable amazon-linux-extras epel :\n     \n          sudo amazon-linux-extras enable epel\n     \n   - install epel-release:\n\n          sudo yum install epel-release\n\n   - After enabling the EPEL repository, install sshpass:\n  \n          sudo yum install sshpass\n\n### For Amazon-linux2:- Download older ansible using python2(Older Ansible-version)\n- If Amazon linux 2 ami use then use following command for download Ansible (/etc/ansible/ansible.cfg this config file provide).\n\n        sudo amazon-linux-extras install ansible2\n\n### Method 3:-  for Install Ansible: (AMI- Amazon-linux) \n- Install ansible-core, but in this ansible do not provide config file, generally ansible-config file loaction = **/etc/ansible/ansible.cfg**\n\n       sudo yum install ansible-core -y\n\n- Command for check ansible version:\n\n       ansible --version\n![14](https://github.com/Pratikshinde55/Ansible-setup-onAWS/assets/145910708/1f99f21c-cf32-48b3-a85b-7547308fd0c9)\n\n- We can create ansible config file manually:\n\nNOTE: Fom General user we can't create config file so we need to go root or use sudo.\n\n    exit \u003c\u003c-- this helps to exit from General user\n\n- On master Root user:\n- Go inside **/etc/ansible** folder and create config file(ansible.cfg) use follw commands:\n\n       cd /etc/ansible\n    \n- Create ansible.cfg file:\n\n       touch ansible.cfg\n\n- After we created ansible config file it is empty, So we pull file and copy in it for this use following command:\n\n      ansible-config init\n    \n- Copy to destination **/etc/ansible/ansible.cfg**:\n\n      ansible-config init --disabled \u003e /etc/ansible/ansible.cfg\n\n![15](https://github.com/Pratikshinde55/Ansible-setup-onAWS/assets/145910708/c9f71123-d97f-47a8-bab4-da549e18b596)\n\n### Method 4th:--  [Installing Ansible with download extra package for yum:(AMI- Amazon-linux-2/Amazon-linux)]\n \n      sudo yum update -y\n    \n      sudo amazon-linux-extras install epel -y\n\n      sudo yum install ansible -y\n\n- Command for check ansible version and /etc/ansible/ansible.cfg location:\n\n      ansible --version\n\n- **In this way we give pre-created ansible config file**\n![image](https://github.com/user-attachments/assets/115c887d-9b18-4d02-9b33-17dbf6887303)\n\n## Ansible Config file settings: [ansible.cfg] \n- This Step is very important to run in every ansible version \n- Ansible config file location-\u003e /etc/ansible/ansible.cfg\n \nCommand for open ansible.cfg\n        \n     vi /etc/ansible/ansible.cfg\n\n1. **In this file we Add privilege escalation this give become method:** \n\n![16](https://github.com/Pratikshinde55/Ansible-setup-onAWS/assets/145910708/90c2ee3b-3e5b-409a-b233-e4093b7af8f0)\n\n2. **In this file we also uncomment ansible Inventory (remove semi colon):**\n\n![17](https://github.com/Pratikshinde55/Ansible-setup-onAWS/assets/145910708/6c6377c9-f853-4cbe-91d8-986037f3cb05)\n\n3. **Making host_key_checking is False:** (This is because while connecting to target by ssh the target node password ask, So deactive Host_key_checking)\n\n![18](https://github.com/Pratikshinde55/Ansible-setup-onAWS/assets/145910708/b6af24e1-3d8a-4e2b-8bef-b1b080c8df14)\n\n   - become=True: Enables privilege escalation (e.g., running tasks as root).\n\n   - become_method=sudo: Specifies that the sudo command is used for privilege escalation.\n\n   - become_user=root: Defines that the tasks will be executed as the root user (or any other user you specify).\n\n   - become_ask_pass=False: Prevents Ansible from prompting for the password when escalating privileges (assuming passwordless sudo or other configuration).\n\n- Now  ansible config file set-up:\n\n- Create ansible inventory, Location is **/etc/ansible/host**:\n\n      vi /etc/ansible/host\n\n- On \"psadmin\" general user (Master Node):\n\n- Command for checking all hosts are connected or not:\n\n      ansible all -m ping\n\n![19](https://github.com/Pratikshinde55/Ansible-setup-onAWS/assets/145910708/d7357644-e6d0-40c5-90fb-40e2dd826647)\n\n- Create \u0026 Run Ansible-Playbook:\n    \n       vi web.yml\n- Command for Run ansible-playbook:\n\n       ansible-playbook web.yml\n\n![20](https://github.com/Pratikshinde55/Ansible-setup-onAWS/assets/145910708/0df1a5b2-9049-4242-986d-e22dc662297f)\n\n- Check on target node httpd install or not:\n\n       rpm -q httpd\n    \n![21](https://github.com/Pratikshinde55/Ansible-setup-onAWS/assets/145910708/35e67fef-7fd1-480f-90b9-a1079f81c696)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpratikshinde55%2Fansible-setup-onaws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpratikshinde55%2Fansible-setup-onaws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpratikshinde55%2Fansible-setup-onaws/lists"}