Provision Raspberry Pi to Display a Web Dashboard
- Format your SD using Disk Utility ~ Format MS-DOS (FAT)
- Download Raspbian
- Unzip the download
- Burn the image to your SD Card Using Etcher
- Insert your SD and turn on your Pi.
- Open your Terminal
- Run
sudo raspi-config
- Select
3 Interfacing Options
- Select
P2 SSH
- Select Yes and Press Enter
- Select 35 Interfacing Options`
- Select
P3 VNC
- Select Yes and Press Enter
- Reboot your Pi
- Connect your Pi to the network through ethernet or WIFI.
- Open your Terminal
- Run the
ifconfig
command - Make note of the IP Address under
eth0
Setup the ansible script.
cd pi-dash
Edit the hosts
file by replacing host-ip
with your IP.
Update variables in vars/all.yml
:
host_name
host_ip
ssh_pub_key
Update variables in vars/secrets.yml
:
user_password
pi_password
Encyrpt vars/secrets.yml
using Ansible Vault:
ansible-vault edit vars/secrets.yml
Deploy using Ansible.
ansible-playbook playbook.yml -i hosts --ask-pass --become -c paramiko
Pi default password raspberry
.
Let Ansible do it's Magic :)
-
Config
- Generate locale and set it to en_US.UTF-8
- Update Timezone to America/New York
- Set hostname to the defined value -
host_name
- Add
127.0.0.1 host_name
to hosts file - Disables Screen Sleep
-
SSH
- Removes Root SSH Configuration
- Updates
sshd_config
Parameters
-
APT
- Installs Packages *
apt_install_packages
- Removes Packages *
apt_remove_packages
- APT Full System Update
- Reboot if required
- Installs Packages *
-
User
- Creates a new user -
user_name
- Adds user to groups -
user_groups
- Uploads
ssh_pub_key
to authorized_keys - If your key is not located in
~/.ssh/id_rsa.pub
updatessh_pub_key
- Enables password less sudo
- Sets
user_name
password touser_password
- Changes Pi's password to -
pi_password
- Have Ansible to use new
pi_password
- Changes AutoLogin to
user_name
- Restarts Pi
- Waits for SSH to come up
- Creates a new user -
-
Chromium
- Launches Chromium on Boot - Full Screen, Incognito, Geckoboard URL
- Restarts Pi
- Waits for SSH to come up
To use ansible-vault
you must have the file ./.vault_pass.txt
on your machine with the vault password inside. Do not upload it to Git!!
user_password
and pi_password
are stored in vars/secrets.yml
.
Encrypt:
ansible-vault edit vars/secrets.yml
Decrypt:
ansible-vault decrypt vars/secrets.yml
Edit or View:
ansible-vault edit vars/secrets.yml
Add Pi to ~/.ssh/config
Host $IP $Hostname
HostName $IP
User ops
IdentityFile ~/.ssh/$ssh-key
Change remote_user
to user_name
on playbook.yml
Edit main.yml
to include the tasks you want to run
Run the playbook:
ansible-playbook playbook.yml -i hosts