{"id":16089701,"url":"https://github.com/leonelgalan/ansible-pi","last_synced_at":"2026-01-11T03:44:47.801Z","repository":{"id":46814195,"uuid":"257744692","full_name":"leonelgalan/ansible-pi","owner":"leonelgalan","description":"My personal raspberry-pi ansible setup","archived":false,"fork":false,"pushed_at":"2021-09-23T23:36:07.000Z","size":50,"stargazers_count":0,"open_issues_count":6,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-08T00:32:12.371Z","etag":null,"topics":["ansible","ansible-role","personal-project","python3","raspberry-pi"],"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/leonelgalan.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}},"created_at":"2020-04-22T00:01:55.000Z","updated_at":"2020-04-24T21:27:15.000Z","dependencies_parsed_at":"2022-07-22T21:02:31.389Z","dependency_job_id":null,"html_url":"https://github.com/leonelgalan/ansible-pi","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/leonelgalan%2Fansible-pi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonelgalan%2Fansible-pi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonelgalan%2Fansible-pi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonelgalan%2Fansible-pi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leonelgalan","download_url":"https://codeload.github.com/leonelgalan/ansible-pi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246786501,"owners_count":20833702,"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-role","personal-project","python3","raspberry-pi"],"created_at":"2024-10-09T14:05:17.712Z","updated_at":"2026-01-11T03:44:47.731Z","avatar_url":"https://github.com/leonelgalan.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"## Raspberry PI Setup\n\nClone this project and edit the playbooks before running. Follow this _README_ for additional details.\n\n### Network Configuration\n\nI prefer to setup my Raspberry Pi headless, without a monitor and preferably, without a mouse and keyboard. For those Pis with wireless connectivity, We can have them connect to a wireless network on its first boot by adding a _wpa_supplicant.conf_ to the SD card before. For those Pis with wireless connectivity, We can have them connect to a wireless network on its first boot by adding a _wpa_supplicant.conf_ to the SD card before.\n\nMake a copy of [_wpa_supplicant.conf_](https://github.com/leonelgalan/ansible-pi/blob/master/wpa_supplicant.conf.example) and fill in your network's name (ssid) and pre-shared key (psk), configure other properties as needed (e.g. country):\n\n```sh\ncp wpa_supplicant.conf.example wpa_supplicant.conf\ncode wpa_supplicant.conf\n```\n\n```conf\nctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev\nupdate_config=1\ncountry=US\n\nnetwork={\n  ssid=\"\"\n  psk=\"\"\n  key_mgmt=WPA-PSK\n}\n```\n\n### Prepare your SD Card\n\nAll the code in this section should be run on the same terminal session. Just make sure you edit the `IMAGE_NANE` and `DISK` variables before.\n\n#### Download Raspian\n\nChoose the Raspian image of your choice and download it from [https://www.raspberrypi.org/downloads/raspbian/](https://www.raspberrypi.org/downloads/raspbian/). Modify `IMAGE_NAME` before running.\n\n```sh\n# Options: raspbian (Desktop), raspbian_full (Desktop with recommended software), raspbian_lite (Lite)\nIMAGE_NANE=raspbian_lite\ncurl --location --remote-name \"https://downloads.raspberrypi.org/${IMAGE_NANE}_latest\"\nunzip *.zip\nrm *.zip\nIMAGE=$(ls *.img)\n```\n\n### Copy Raspbian and Setup the Network\n\nInsert your card and find the disk's name: `diskN`, where `N` is a number. Identify the disk (not the partition) of your SD card (`disk2`, not `disk2s1`) by looking at its size  (for example, a 16GB SD card might show as *15.5 GB\n\n```sh\ndiskutil list\n```\n\n**Make sure you modify `DISK` before.** Copy raspbian to the card and setup the network to:\n\n1. Connect to a wireless network.\n2. Accept incoming SSH connections.\n\n```sh\nDISK=disk2\ndiskutil unmountDisk /dev/$DISK\nsudo dd bs=1m if=$IMAGE of=/dev/r$DISK conv=sync\n# Between few seconds and a couple of minutes, Ctrl+T to view Progress\n\n# Copy the wpa_supplicant.conf you created above\ncp wpa_supplicant.conf /Volumes/boot/\n# Enable incoming SSH connections by creating an empty ssh file.\ntouch /Volumes/boot/ssh\n\n# Eject the SD card properly\nsudo diskutil eject /dev/r$DISK\n```\n\n### Find your Raspberry Pi's IP Address\n\nInsert the SD card on the and turn on your Pi; Wait about 1 minute for it to boot.\n\nFind your Raspberry Pi's IP address by searching for part of its MAC Address:\n\n```sh\n$ sudo nmap -sP 192.168.1.0/24 | awk '/^Nmap/{ip=$NF}/B8:27:EB/{print ip}\n192.168.1.11\n```\n\nYou might need to install _nmap_ before. See additional details in this [Stack Exchange's post](https://raspberrypi.stackexchange.com/a/13937). Copy this IP address to the [_hosts_](https://github.com/leonelgalan/ansible-pi/blob/master/hosts) file under `[pi]`:\n\n```\n[pi]\n192.168.1.11\n```\n\n### Install Ansible's requirements and Run _step01.yml_\n\n#### A note about Ansible\n\n\u003e Ansible is an open-source software provisioning, configuration management, and application-deployment tool. - [Wikipedia: Ansible (software)](https://en.wikipedia.org/wiki/Ansible_(software))\n\n##### What You Need to Know?\n\n* _hosts_ define the list of hosts, playbooks say in which hosts they run. We are saying there is host _pi_ and its IP Address.\n* The playbooks, defines in which hosts are going to run or \"all\", as who (what user) and what roles to run and their configuration.\n* Roles are groupings of functionality, which facilitates sharing and there are plenty hosted in the Ansible Galaxy. This \"project\" has one local role and uses two from the Ansible Galaxy, listed in the [_requirements.yml_](https://github.com/leonelgalan/ansible-pi/blob/master/requirements.yml) and installed by calling the `ansible-galaxy` command below.\n* A project might have local roles, in this case [_pip3_](https://github.com/leonelgalan/ansible-pi/tree/master/pip3). Inside of it the folders are named appropriately, you should explore its contents to peek inside of how Ansible works.\n* Each role's documentation should tell you what the role can do and how to set it up.\n\n#### [_step01.yml_](https://github.com/leonelgalan/ansible-pi/blob/master/step01.yml)\n\nThis is the minimum configuration I do on my Raspberry Pi's before using them. It adds a single role: _raspi_config_ which does some configuration by default, but allows me to override those to better suit my needs.\n\n##### Implicit (default)\n\n* Update and Upgrade\n* Expand filesystem to fill the SD card\n* Setup the Locale: `en_US.UTF-8`\n\n##### Explicit\n\n* Setup my timezone to `America/New_York`, default is `UTC`\n* Enable the camera, if that's my intended use for this particular Pi\n* Replace the default **pi** user with myself (`whoami`) and copy my public ssh key, so I can ssh in without specifying a user or typing a password.\n\nFind the defaults and additional settings on the [role's README](https://github.com/mikolak-net/ansible-raspi-config). **Edit _step01.yml_ as needed before running** the following lines:\n\n```sh\nansible-galaxy install -r requirements.yml\nansible-playbook _initial.yml -i hosts --ask-pass\n```\n\n### Run [_step02.yml_](https://github.com/leonelgalan/ansible-pi/blob/master/step02.yml)\n\nNow connected as the user you just created (`remote_user: leonelgalan`, **REMEMBER** to change this), install the packages you might need, **edit step02.yml_** based on your desire setup:\n\n* Packages:\n  * `python3-pip`\n  * `sense-hat`\n  * `python-smbus`\n  * `i2c-tools`\n  * `python-setuptools`\n* Python Packages\n  * Upgrade `setuptools`\n  * `RPI.GPIO`\n  * `adafruit-circuitpython-htu21d`\n\n```sh\nansible-playbook step02.yml -i hosts --ask-pass\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleonelgalan%2Fansible-pi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleonelgalan%2Fansible-pi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleonelgalan%2Fansible-pi/lists"}