├── .gitignore ├── README.md ├── ansible-pi.jpg ├── hosts.example ├── playbook.yml ├── roles └── pi │ └── tasks │ └── main.yml └── wpa_supplicant.conf.example /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | hosts 3 | wpa_supplicant.conf 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Donate](http://www.opensourcecitizen.org/badge)](http://www.opensourcecitizen.org/project?url=github.com/motdotla/ansible-pi) 2 | 3 | If you found this library useful, donate some CPU cycles to this project by clicking above. Thank you! 😇 4 | 5 | # ansible-pi 6 | 7 | ![](https://raw.github.com/motdotla/ansible-pi/master/ansible-pi.jpg) 8 | 9 | Quickly setup your Raspberry Pi - particularly WIFI settings. 10 | 11 | There is a [complete guide to setting up your raspberry pi without a keyboard and mouse](http://sendgrid.com/blog/complete-guide-set-raspberry-pi-without-keyboard-mouse/) that goes along with this repo. 12 | 13 | ## Installation 14 | 15 | Clone and setup the ansible script. 16 | 17 | ``` 18 | git clone https://github.com/motdotla/ansible-pi.git 19 | cd ansible-pi 20 | cp hosts.example hosts 21 | cp wpa_supplicant.conf.example wpa_supplicant.conf 22 | ``` 23 | 24 | Edit the `wpa_supplicant.conf` and `hosts` files. 25 | 26 | Deploy using [ansible](http://www.ansible.com) (install instructions for ansible are in [requirements](#requirements) below). 27 | 28 | ``` 29 | ansible-playbook playbook.yml -i hosts --ask-pass --become -c paramiko 30 | ``` 31 | 32 | ## Requirements 33 | 34 | [Ansible](http://www.ansible.com/) is required. 35 | 36 | ### Installing Ansible on Mac 37 | 38 | ``` 39 | cd /tmp 40 | git clone git://github.com/ansible/ansible.git 41 | cd ./ansible 42 | git checkout v1.4.3 43 | sudo make install 44 | sudo easy_install jinja2 45 | sudo easy_install pyyaml 46 | sudo easy_install paramiko 47 | ``` 48 | 49 | ## History 50 | 51 | This project was originally built when trying out my first Raspberry Pi. The setup process was not as easy as I wanted. 52 | -------------------------------------------------------------------------------- /ansible-pi.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/motdotla/ansible-pi/f4d0808605139daf449acbaa06e5641e6a2ec673/ansible-pi.jpg -------------------------------------------------------------------------------- /hosts.example: -------------------------------------------------------------------------------- 1 | [webservers] 2 | 192.168.1.200 3 | -------------------------------------------------------------------------------- /playbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Ansible Playbook for configuring brand new Raspberry Pi 4 | 5 | hosts: webservers 6 | roles: 7 | - pi 8 | remote_user: pi 9 | become: yes 10 | -------------------------------------------------------------------------------- /roles/pi/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - set_fact: 3 | real_ansible_host: "{{ ansible_host }}" 4 | 5 | - name: 'Configure WIFI' 6 | copy: src=./wpa_supplicant.conf dest=/etc/wpa_supplicant/wpa_supplicant.conf mode=0600 7 | 8 | - name: 'Update APT package cache' 9 | action: apt update_cache=yes 10 | 11 | - name: 'Upgrade APT to the lastest packages' 12 | action: apt upgrade=safe 13 | 14 | - name: 'Reboot' 15 | shell: sleep 2 && reboot 16 | async: 1 17 | poll: 0 18 | ignore_errors: true 19 | 20 | - name: "Wait for Raspberry PI to come back" 21 | local_action: wait_for host={{ real_ansible_host }} port=22 state=started delay=10 22 | become: false 23 | -------------------------------------------------------------------------------- /wpa_supplicant.conf.example: -------------------------------------------------------------------------------- 1 | ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev 2 | update_config=1 3 | network={ 4 | ssid="your_wifi_sid" 5 | psk="your_wifi_password" 6 | # Protocol type can be: RSN (for WPA2) and WPA (for WPA1) 7 | proto=RSN 8 | 9 | # Key management type can be: WPA-PSK or WPA-EAP (Pre-Shared or Enterprise) 10 | key_mgmt=WPA-PSK 11 | 12 | # Pairwise can be CCMP or TKIP (for WPA2 or WPA1) 13 | pairwise=CCMP 14 | 15 | #Authorization option should be OPEN for both WPA1/WPA2 (in less commonly used are SHARED and LEAP) 16 | auth_alg=OPEN 17 | } 18 | --------------------------------------------------------------------------------