{"id":20053199,"url":"https://github.com/irezaul/ansible","last_synced_at":"2026-03-06T17:01:52.384Z","repository":{"id":140057353,"uuid":"384444467","full_name":"irezaul/Ansible","owner":"irezaul","description":null,"archived":false,"fork":false,"pushed_at":"2021-08-01T16:47:48.000Z","size":1496,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-12T21:12:30.293Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/irezaul.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":"2021-07-09T13:24:39.000Z","updated_at":"2021-08-01T16:47:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"0dc252fa-33d3-43ee-8752-4f66133dbb79","html_url":"https://github.com/irezaul/Ansible","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irezaul%2FAnsible","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irezaul%2FAnsible/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irezaul%2FAnsible/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irezaul%2FAnsible/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/irezaul","download_url":"https://codeload.github.com/irezaul/Ansible/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241482109,"owners_count":19969850,"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":[],"created_at":"2024-11-13T12:23:29.930Z","updated_at":"2026-03-06T17:01:52.305Z","avatar_url":"https://github.com/irezaul.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# `Ansible` How to install on your VM machine ubuntu \n\n#### 1. update first your apt\n```python\nsudo apt-get update\n```\n#### 2. `Ansible` use this command for install ( `It only needs to be installed on the master-PC `)\n``` phython\nsudo apt-get install ansible\n```\n#### 3. Next need to configure password less SSH: First need to create a `SSH key pair` on AnsibleMaster\n```bash\nssh-keygen\n```\n#### this keyfile generate on `root` folder \n```bash\ncd root/.ssh\n```\n![rsa_key](https://user-images.githubusercontent.com/77927449/125205038-18961380-e2a2-11eb-8aef-57a7c89cef60.png)\n\u003e (press enter for all options)\n#### 4. To copy the public key type command\n```bash\ncat .ssh/id_rsa.pub\n```\n\n![rsa_pub](https://user-images.githubusercontent.com/77927449/125205063-3794a580-e2a2-11eb-9c46-a2058bb5b088.png)\n\n\n#### 5. and select the key to copy In all the host nodes type command\n```bash\nvim .ssh/authorized_keys\n```\n\u003e and paste by right clicking From AnsibleServer ssh to all the nodes once then logout: ssh 19X.16X.1.1 \n\n### * Configuring Host File\n\u003e As root user the host file is under `/etc/ansible/hosts`\n\u003e Now you can edit and save the file using vim or nano ( text editor)\n`vim /etc/ansible/hosts`\n#### 6. Write here your `IP addresses` of the hosts at the bottom of the file in this format and save and exit vim\n![ip insert](https://user-images.githubusercontent.com/77927449/125205280-4760b980-e2a3-11eb-8a38-7fe8dd3ff3e6.png)\n\n#### 7. `Ad-hoc` Commands \u0026 Modules in Ansible\n\u003e Example 1: Use the ping module to check if a host can be pinged\n```bash\nansible ip-192.168.x-x -m ping\n```\n![ansible_ip](https://user-images.githubusercontent.com/77927449/125313677-49845000-e357-11eb-8729-0313d0c7c2bc.png)\n\u003e Example 2: Create a new user by using the user module\n```bash\nansible ip-172-31-12-148 -m user -a \"name=demouser state=present\"\n```\n![ansible demo user](https://user-images.githubusercontent.com/77927449/125313717-56a13f00-e357-11eb-8c7e-2776c4de1196.png)\n\n#### 8. `Ad-hoc` Commands \u0026 Modules in Ansible (cont)\n\u003e Check if demouser has been created in host\n```bash\nid demouser\n```\n#### 9. Install a package on the host machine using apt module\n```bash \nansible ip-172-31-12-148 -m apt -a \"name=finger state=present update_cache=true\"\n```\n\n#### 10. Check on the host machine if `finger` was installed by typing finger To run a module on all the hosts use “all” instead of IP address\n```bash\nansible all -m apt -a \"name=finger state=present update_cache=true\"\n```\n##### * Create and Execute a Playbook\n\n#### 11. Change directory to /etc/ansible: \n```bash\ncd /etc/ansible\n```\n#### 12. Use vim editor to write a playbook: \n```bash\nvim demoplaybook.yaml\n```\n#### 13. Type this command to execute the play: \n```bash\nansible-playbook demoplaybook.yaml\n```\n### * if you get any `error` like this don't panic just follow the instruction-\n\u003e E: Could not get lock /var/lib/dpkg/lock – open (11: Resource temporarily unavailable)\nE: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?\n\n##### check the process (package manager for handling software). Use this command:\n```bash \nps aux | grep -i apt\n```\n\u003e If you see that apt is being used by a program like `apt.systemd.daily update`,\n#### Method 1\n```bash\nsudo killall apt apt-get\n```\n#### Method 2 \n```bash \nsudo lsof /var/lib/dpkg/lock\nsudo lsof /var/lib/apt/lists/lock\nsudo lsof /var/cache/apt/archives/lock\n```\n#### You can now safely remove the lock files using the commands below:\n```bash\nsudo rm /var/lib/apt/lists/lock\nsudo rm /var/cache/apt/archives/lock\nsudo rm /var/lib/dpkg/lock\n```\n#### [ ] now install your any packages \n\n### * Here a demo install java by playbook -\n![Java playbook](https://user-images.githubusercontent.com/77927449/126518037-f4664e0a-0079-468d-bb33-2c9494a848ab.png)\n\n\u003e install process done\n![Install java by playbook_yaml](https://user-images.githubusercontent.com/77927449/126518122-0f9ff347-be00-40f1-bb73-df161ecb7b73.png)\n![Java install done on host](https://user-images.githubusercontent.com/77927449/126518439-3b8ff114-3554-40ce-b178-ab00b4b1f3fa.png)\n\n\n\n[install tomcat apache](https://github.com/irezaul/Ansible/tree/main/Tomcat%20install%20task)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firezaul%2Fansible","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Firezaul%2Fansible","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firezaul%2Fansible/lists"}