Skip to content

Raspberry Pi setup and configuration via Ansible.

License

Notifications You must be signed in to change notification settings

fedejaure/raspberry-pi

Repository files navigation

Raspberry Pi

GitHub release (latest SemVer) tests License

pre-commit Contributor Covenant

Setup and configuration of my own Raspberry Pi fleet via Ansible Collection (use by your own risk).

Fleet Members (Metal Gear Characters)

  • Otacon

    Pi-hole DNS sinkhole instance.

    • services:

    • variables:

      • rpi_locale: Raspberry Pi locale config. (Default: en_US.UTF-8)

      • rpi_layout: Raspberry Pi keyboard layout config. (Default: us)

      • rpi_dist_upgrade: If Raspberry Pi should do a dist-upgrade. (Default: no)

      • rpi_tz: Raspberry Pi Time Zone config. (Default: 'Europe/Amsterdam')

      • rpi_wifi_country: Raspberry Pi Wifi Country config. (Default: NL)

      • rpi_pihole_password: pihole.otacon.local Admin password. (Default: random)

      • rpi_swap_config: Raspberry Pi swap config. (Default: CONF_SWAPSIZE: 100)

      • rpi_open_weather_map_key: An API key for Open Weather Map, LATLONG (below) must also be defined.

      • rpi_latlong: A latitude and longitude for the default location. (Default: 51.9812,5.6584)

  • Ocelot (Revolver Ocelot)

    OctoPrint an snappy web interface for my 3D printer.

    • services:

    • variables:

      • rpi_locale: Raspberry Pi locale config. (Default: en_US.UTF-8)

      • rpi_layout: Raspberry Pi keyboard layout config. (Default: us)

      • rpi_dist_upgrade: If Raspberry Pi should do a dist-upgrade. (Default: no)

      • rpi_tz: Raspberry Pi Time Zone config. (Default: 'Europe/Amsterdam')

      • rpi_wifi_country: Raspberry Pi Wifi Country config. (Default: NL)

      • rpi_swap_config: Raspberry Pi swap config. (Default: CONF_SWAPSIZE: 100)

      • rpi_open_weather_map_key: An API key for Open Weather Map, LATLONG (below) must also be defined.

      • rpi_latlong: A latitude and longitude for the default location. (Default: 51.9812,5.6584)

  • more coming ...

Quickstart

  1. Clone this repository.

  2. Install dependencies:

    $ poetry install --no-root
    Creating virtualenv raspberry-pi in .venv
    Using virtualenv: .venv
    Installing dependencies from lock file
    
    Package operations: 95 installs, 0 updates, 0 removals
    
    ...
  3. Activate the virtual environment:

    $ poetry shell
    Spawning shell within .venv
    (raspberry-pi)$
  4. Install required Ansible roles:

    (raspberry-pi)$ ansible-galaxy install -r requirements.yml

    or

    (raspberry-pi)$ inv galaxy-install
  5. Configure the inventory file, e.g.:

    [otacon]
    127.0.0.1 ansible_python_interpreter=/usr/bin/python3 ansible_user=pi ansible_password=somepassword ansible_become_password=somepassword
    
  6. Run the playbook:

    (raspberry-pi)$ ansible-playbook main.yml -i inventory

    or

    (raspberry-pi)$ inv playbook
  7. Enjoy!

Running a specific set of tagged tasks

The tags available are:

  • always
  • docker
  • firewall
  • git
  • init
  • lcd
  • mdns-beacon
  • pip
  • security
  • services
  • ssh
  • supervisor

Overriding Defaults

You can override the defaults configured in default.<fleet-member>.config.yml by creating a <fleet-member>.config.yml file and setting the overrides in that file. e.g.:

security_ssh_password_authentication: "yes"
security_ssh_permit_root_login: "yes"
security_autoupdate_mail_to: example@example.com

Any variable can be overridden in <fleet-member>.config.yml; see the supporting roles documentation for a complete list of available variables.

Development

To display available tasks run:

(raspberry-pi)$ inv --list
Available tasks:

  ansible-lint     Run ansible linter.
  galaxy-install   Install ansible-galaxy requirements.
  hooks            Run pre-commit hooks.
  install-hooks    Install pre-commit hooks.
  lint             Run all linting.
  playbook         Runs Ansible playbooks, executing the defined tasks on the targeted hosts.
  version          Bump version.
  yamllint         Run yamllint, a linter for YAML files.

License

MIT / BSD

Author Information

This playbook was created in 2020 by Federico Jaureguialzo.