{"id":21585391,"url":"https://github.com/sayems/ansible.resources","last_synced_at":"2026-05-10T05:50:06.787Z","repository":{"id":147284235,"uuid":"171972825","full_name":"sayems/ansible.resources","owner":"sayems","description":"Learn how to automate Raspberry Pi setup with Ansible.","archived":false,"fork":false,"pushed_at":"2019-03-16T17:17:24.000Z","size":46,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-24T15:33:51.013Z","etag":null,"topics":["ansible","ansible-inventory","ansible-playbook","ansible-playbooks","ansible-role","ansible-roles","raspberry","raspberry-pi","raspberry-pi-3","raspberrypi","raspbian","raspi"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sayems.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":"2019-02-22T01:28:49.000Z","updated_at":"2021-06-14T08:15:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"46a43d72-0266-4e78-aca1-a293fd12ed37","html_url":"https://github.com/sayems/ansible.resources","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/sayems%2Fansible.resources","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayems%2Fansible.resources/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayems%2Fansible.resources/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayems%2Fansible.resources/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sayems","download_url":"https://codeload.github.com/sayems/ansible.resources/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244189828,"owners_count":20412991,"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","ansible-playbooks","ansible-role","ansible-roles","raspberry","raspberry-pi","raspberry-pi-3","raspberrypi","raspbian","raspi"],"created_at":"2024-11-24T15:10:30.261Z","updated_at":"2026-05-10T05:50:06.754Z","avatar_url":"https://github.com/sayems.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ansible Resources\n\nLearn how to automate Raspberry Pi setup with Ansible. The Raspberry Pi is a tiny and affordable computer that you can use to learn, test and experiment concepts about distributed computing. The first challenge is always how to keep the Rasbperry Pi’s up to date. Having four Rasbperry Pi seems manageable, but If you have more than 4 Rasbperry Pi, you'll need an automation tool like ```Ansible``` to automate repetitive task like ```installing```, ```updating``` software on your Rasbperry Pi’s.\n\n\nIn this brief tutorial, I'll walk you through the basics of Ansible using a cluster of four Raspberry Pi.\n\n![alt text](https://github.com/sayems/ansible.resources/blob/master/imgages/architecture.png \"Logo Title Text 1\")\n\n\u0026nbsp;\n\n## Table of contents\n- [Ansible Installation](#installing-ansible-on-mac)\n    - [Install Ansible on Mac](#installing-ansible-on-mac)\n    - [Test Ansible on Localhost](#test-ansible)\n    - [Configure your macOS ```/etc/hosts``` for Ansible](#edit-your-macos-etchosts-for-ansible)\n    - [Enable Passwordless SSH access for ansible](#enable-passwordless-ssh-access-for-ansible)\n    - [Configure Ansible ```/etc/ansible/hosts```](#ansible-hosts-and-groups)\n        - [Ansible playbook to ping all server](#ansible-playbook-to-ping-all-server)\n        - [Check python version with ansible](#check-python-version-with-ansible)\n- [YAML Basics](https://github.com/sayems/ansible.resources/wiki/YAML-Basics)\n- [Ad hoc Commands](https://github.com/sayems/ansible.resources/wiki/Ad-hoc-Commands)\n- [Ansible Inventory](https://github.com/sayems/ansible.resources/wiki/Ansible-Inventory)\n- [Ansible Playbooks](https://github.com/sayems/ansible.resources/wiki/Ansible-Playbooks)\n- [Ansible Roles](https://github.com/sayems/ansible.resources/wiki/Ansible-Roles)\n- [Ansible Variables](https://github.com/sayems/ansible.resources/wiki/Ansible-Variables)\n- [Advanced Execution](https://github.com/sayems/ansible.resources/wiki/Advanced-Execution)\n- [Ansible Vault](https://github.com/sayems/ansible.resources/wiki/Ansible-Vault)\n- [Ansible Container](https://github.com/sayems/ansible.resources/wiki/Ansible-Container)\n- [Troubleshooting](https://github.com/sayems/ansible.resources/wiki/Troubleshooting)\n- [Ansible Books and courses](https://github.com/sayems/ansible.resources/wiki/Ansible-books-and-courses)\n- [Additional Resources](https://github.com/sayems/ansible.resources/wiki/Additional-Resources)\n\n\n\n\n[top](#table-of-contents)\n\u0026nbsp;\n\n\n\nInstalling Ansible on Mac\n--\n\nThe best way to get started on a macOS is to use [Homebrew](https://brew.sh/). If you already have [Homebrew](https://brew.sh/) installed, you can install ```ansible``` by running the following command\n```\nbrew install ansible\n```\n\nIf you don't already have [Homebrew](https://brew.sh/) installed, I would strongly recommend that you install it! It's incredibly useful for installing software dependencies like OpenSSL, MySQL, Postgres, Redis, SQLite, and more.\n\nYou can install it by running the following command:\n```\n/usr/bin/ruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\"\n```\n\n[top](#table-of-contents)\n\u0026nbsp;\n\nTest Ansible\n--\n\nRun the following command:\n```\nansible localhost -m ping\n```\n```\nlocalhost | SUCCESS =\u003e {\n    \"changed\": false,\n    \"ping\": \"pong\"\n}\n```\n\n[top](#table-of-contents)\n\u0026nbsp;\n\nEdit your macOS ```/etc/hosts``` for Ansible\n--\n1. Open your terminal, type this command:\n```\nsudo nano /etc/hosts\n```\n\n2. Add ```192.168.1.x``` to end of the ```/etc/hosts``` file.\n```\n# Raspberry Pi\n192.168.1.6\t\traspi1    \n192.168.1.7\t\traspi2\n192.168.1.8\t\traspi3\n192.168.1.9\t\traspi4\n```\n\n3. To save your changes, press ```Ctrl+x``` on your keyboard.\n\n\n[top](#table-of-contents)\n\u0026nbsp;\n\n\nEnable Passwordless SSH access for ansible\n--\n\nIn order to fully control a remote machine we need to be able to execute command on the remote machines as user ```root```. \n\nTo enable passwordless sudo:\n\n1. Log in to the Raspberry Pi command-line interface. The default user name and password of the Raspberry Pi hardware are ```pi``` and ```raspberry```, respectively.\n\n2. In the command-line interface, type this command:\n```\nsudo nano /etc/sudoers.d/010_pi-nopasswd\n```\n3. Enable passwordless sudo access by adding this line:\n```\n\u003cuser name\u003e ALL=(ALL) NOPASSWD: ALL\n```\nFor example, to provide passwordless sudo access to a user ```pi```, type:\n```\npi ALL=(ALL) NOPASSWD: ALL\n```\n\n4. To save your changes, press ```Ctrl+x``` on your keyboard.\n\n5. For these changes to take effect, restart Raspberry Pi by typing this command:\n```\nsudo reboot\n```\n\n[top](#table-of-contents)\n\u0026nbsp;\n\n\n### Ansible Hosts and Groups\n\n1. Open your terminal, type this command create ```/etc/ansible/hosts``` directory\n```\nsudo mkdir -p /etc/ansible\n```\n\n2. Add ```hostname``` to ```/etc/ansible/hosts``` file.\n```\n[gui]\nraspi1 \nraspi2 \n\n[nogui]\nraspi3 \nraspi4 \n```\n\nYou also can define ‘host list’ with ranges\n\n```\n[gui]\nraspi[1:2]\n\n[nogui]\nraspi[3:4]\n```\n\n[top](#table-of-contents)\n\u0026nbsp;\n\n##### Ansible playbook to ping all server\n\n```\nansible -m ping all\n```\n```\nraspi2 | SUCCESS =\u003e {\n    \"changed\": false,\n    \"ping\": \"pong\"\n}\nraspi1 | SUCCESS =\u003e {\n    \"changed\": false,\n    \"ping\": \"pong\"\n}\nraspi4 | SUCCESS =\u003e {\n    \"changed\": false,\n    \"ping\": \"pong\"\n}\nraspi3 | SUCCESS =\u003e {\n    \"changed\": false,\n    \"ping\": \"pong\"\n}\n```\n\n[top](#table-of-contents)\n\u0026nbsp;\n\n##### Check python version with ansible\n\n```\nansible -m shell -a 'python -V' gui\n\nraspi1 | CHANGED | rc=0 \u003e\u003e\nPython 2.7.13\n\nraspi2 | CHANGED | rc=0 \u003e\u003e\nPython 2.7.13\n```\n\n```\nansible -m shell -a 'python -V' all\n\nraspi3 | CHANGED | rc=0 \u003e\u003e\nPython 2.7.13\n\nraspi4 | CHANGED | rc=0 \u003e\u003e\nPython 2.7.13\n\nraspi1 | CHANGED | rc=0 \u003e\u003e\nPython 2.7.13\n\nraspi2 | CHANGED | rc=0 \u003e\u003e\nPython 2.7.13\n```\n\n[top](#table-of-contents)\n\u0026nbsp;\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsayems%2Fansible.resources","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsayems%2Fansible.resources","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsayems%2Fansible.resources/lists"}