{"id":26035750,"url":"https://github.com/ranjithdb/ansible-01","last_synced_at":"2025-06-18T10:36:03.517Z","repository":{"id":280965006,"uuid":"943752756","full_name":"ranjithdb/ansible-01","owner":"ranjithdb","description":"Basic Inventory \u0026 Ad-Hoc Commands","archived":false,"fork":false,"pushed_at":"2025-03-06T08:30:08.000Z","size":71,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-06T09:36:18.581Z","etag":null,"topics":["ansible"],"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/ranjithdb.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":"2025-03-06T07:59:43.000Z","updated_at":"2025-03-06T08:33:39.000Z","dependencies_parsed_at":"2025-03-06T09:46:41.847Z","dependency_job_id":null,"html_url":"https://github.com/ranjithdb/ansible-01","commit_stats":null,"previous_names":["ranjithdb/ansible-01"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ranjithdb%2Fansible-01","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ranjithdb%2Fansible-01/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ranjithdb%2Fansible-01/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ranjithdb%2Fansible-01/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ranjithdb","download_url":"https://codeload.github.com/ranjithdb/ansible-01/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242338994,"owners_count":20111502,"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"],"created_at":"2025-03-07T05:55:09.203Z","updated_at":"2025-03-07T05:55:09.743Z","avatar_url":"https://github.com/ranjithdb.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# ansible-01\n\n## Basic Inventory \u0026 Ad-Hoc Commands\n\n## **Project Overview**\n\nThis project sets up an Ansible inventory file and demonstrates running ad-hoc commands on remote Linux Mint machines.\n\n---\n\n## **Step 1: Setting Up SSH Key Authentication**\n\nTo enable password-less SSH access, follow these steps:\n\n### **1. Generate an SSH Key on WSL**\n\n```bash\nssh-keygen -t rsa -b 4096 -C \"ansible@wsl\"\n```\n\nPress **Enter** to accept the default file location (`~/.ssh/id_rsa`).\nDo **not** set a passphrase (press Enter twice).\n\n### **2. Copy the Key to the Managed Nodes**\n\nReplace `user` and `ip_address` with your actual details:\n\n```bash\nssh-copy-id user@ip_address\n```\n\nRepeat this for each Linux Mint machine.\n\nIf `ssh-copy-id` is unavailable, manually copy the key:\n\n```bash\ncat ~/.ssh/id_rsa.pub\n```\n\nOn the remote machine, add the key to `~/.ssh/authorized_keys`:\n\n```bash\necho \"PASTE_THE_KEY_HERE\" \u003e\u003e ~/.ssh/authorized_keys\nchmod 600 ~/.ssh/authorized_keys\n```\n\n### **3. Test SSH Access**\n\n```bash\nssh user@ip_address\n```\n\nIf the login works without a password, SSH key authentication is set up.\n\n---\n\n## **Step 2: Create an Ansible Inventory File**\n\nCreate an `inventory.ini` file in the project directory:\n\n```ini\n[linux_mint]\nmint-desktop ansible_host=192.168.1.10 ansible_user=user\nmint-vm ansible_host=192.168.1.20 ansible_user=user\n```\n\nReplace IP addresses and usernames with your actual setup.\n\n---\n\n## **Step 3: Test Ansible Connection**\n\nRun the following command to check connectivity:\n\n```bash\nansible all -i inventory.ini -m ping\n```\n\nIf successful, each host will return a `pong` response.\n\n![ansible pong response](ss/01.png \"ansible pong response\")\n\n---\n\n## **Step 4: Running Ad-Hoc Commands**\n\nExecute remote commands without writing a playbook:\n\n1.**Check system uptime:**\n\n```bash\nansible linux_mint -i inventory.ini -m shell -a \"uptime\"\n```\n\n2.**Check disk usage:**\n\n```bash\nansible linux_mint -i inventory.ini -m shell -a \"df -h\"\n```\n\n3.**List logged-in users:**\n\n```bash\nansible linux_mint -i inventory.ini -m shell -a \"who\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Franjithdb%2Fansible-01","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Franjithdb%2Fansible-01","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Franjithdb%2Fansible-01/lists"}