initial bootstrapping workflow
parent
f2f99a932d
commit
5ad30d3343
22
README.md
22
README.md
|
@ -1,10 +1,20 @@
|
||||||
# Raspberry Pi NAS
|
# Raspberry Pi NAS
|
||||||
|
|
||||||
This repository contains all configuration I use to set up a Raspberry Pi 4B as
|
Ansible configuration repository for my Raspberry Pi's.
|
||||||
a NAS and media storage server. This repository will most likely evolve a lot.
|
|
||||||
|
|
||||||
The Pi is used to host the following:
|
## Initial setup for new systems
|
||||||
|
|
||||||
* Samba network share for access to family pictures
|
1. Flash [Debian Raspberry Pi](https://raspi.debian.net/) on the SD card.
|
||||||
* [Photoview](https://photoview.github.io/) instance for accessing image over the internet
|
2. Configure `/boot/firmware/sysconf.txt`
|
||||||
* [Jellyfin](https://jellyfin.org/) for accessing media library as well
|
1. Set `hostname` to the desired name
|
||||||
|
2. Set `root_authorized_key` to the contents of the current computer's
|
||||||
|
public SSH key
|
||||||
|
3. Put SD card in Pi and boot
|
||||||
|
4. Connect Pi to wired internet
|
||||||
|
5. Determine IP address given to the new Pi
|
||||||
|
6. Add this IP address to the `initial-hosts.ini` file, along with the
|
||||||
|
`static_ip` host var set to the desired static IP address
|
||||||
|
8. Comment out `ansible_ssh_user` in `group_vars/all/vars.yml`, as this
|
||||||
|
overwrites the one set in the hosts file
|
||||||
|
9. Run `ansible-playbook -i initial-hosts.ini first_run.yml`. This command will
|
||||||
|
hang at the `restart networking` step; at this point you can Ctrl-C.
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
- name: Install Python
|
||||||
|
hosts: all
|
||||||
|
gather_facts: no
|
||||||
|
roles:
|
||||||
|
- install-python
|
||||||
|
|
||||||
|
- name: Configure base system.
|
||||||
|
hosts: all
|
||||||
|
roles:
|
||||||
|
- base
|
|
@ -1,14 +1,13 @@
|
||||||
---
|
---
|
||||||
ansible_ssh_user: !vault |
|
ansible_ssh_user: debian
|
||||||
$ANSIBLE_VAULT;1.1;AES256
|
|
||||||
63363333613666383765643633393735396439386662346364643730373138333931303833393339
|
|
||||||
6430306434646562396134373433343439316133303931640a343536383539666132633636303031
|
|
||||||
65643735333839613636613963303433623933366532623037323963646462366464623739393461
|
|
||||||
3233613932616531360a326235346464333566633466633864343261663831336166313230306635
|
|
||||||
3265
|
|
||||||
|
|
||||||
ansible_ssh_port: 22
|
ansible_ssh_port: 22
|
||||||
|
|
||||||
|
# Values for static IP configuration
|
||||||
|
broadcast_ip: 192.168.0.255
|
||||||
|
router_ip: 192.168.0.1
|
||||||
|
|
||||||
|
debian_pass: "{{ vault_debian_pass }}"
|
||||||
|
|
||||||
ansible_become_pass: !vault |
|
ansible_become_pass: !vault |
|
||||||
$ANSIBLE_VAULT;1.1;AES256
|
$ANSIBLE_VAULT;1.1;AES256
|
||||||
38306565386265383731653936353766396630626163316335643261613561363030653561346239
|
38306565386265383731653936353766396630626163316335643261613561363030653561346239
|
||||||
|
@ -28,3 +27,4 @@ lambroek_password: !vault |
|
||||||
36386632303939646632393362373838663337663063326338623534326561656561633131376138
|
36386632303939646632393362373838663337663063326338623534326561656561633131376138
|
||||||
64376237373133333761313635346266306638383038663333366139303437323562303733373764
|
64376237373133333761313635346266306638383038663333366139303437323562303733373764
|
||||||
63316564393763643834643232663462333633373639633938663035633063356530
|
63316564393763643834643232663462333633373639633938663035633063356530
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
$ANSIBLE_VAULT;1.1;AES256
|
||||||
|
37303338366435366664333235623930303461666537326463613536303263353233303631653061
|
||||||
|
3365613139333035616434376464386436653863366338650a366363336438313364646432626335
|
||||||
|
32396334643064326531393930666263643163636163316430616434363139316665323262616538
|
||||||
|
3665633530616432350a326439636231383765666365386433313432373432373938656638373636
|
||||||
|
34323166343965616330366265353462626132356565316637313430343462363163
|
|
@ -0,0 +1,5 @@
|
||||||
|
192.168.0.216 static_ip=192.168.0.3
|
||||||
|
|
||||||
|
[all:vars]
|
||||||
|
# These are expected to be the same
|
||||||
|
ansible_ssh_user=root
|
|
@ -0,0 +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h1Bm1/u+3J2IVbRgeG1iTJdDVeIxBGmA1wMLvrBtBRIS0MaKa1Xabo3QTgYPHNGrf2w+GMnuoQ6/tdD6omPWGTHXqtHKEeIW1JrlDyhOo86oCl+l2aveMwhFFGW4nQmW7sfrowyLHdU3BpGl4m7pGa+5sTsHiOGEqEN/a7xikztXkuKacQ8E/y1C8gDXgaX8zFl6VOwR5EfMEMX390tz+R+ErDU81h47tSkwbY3KhunSKwPT8jSMldBttnCIexd+QuQgOlSwXkYVPPmXtPUkfp+4VzWSWeGKAa9k3HtVMIvKdVk9eXDVNnVdaAL+EkHyXOyFVVGa9gJ3ZOWhHMNi2/kHAwWMI9CwRxj7AVk30KGBhPN0wdS9Dt8/0Aa33hWuY2p9DxtNaiNw== roosensjef@gmail.com
|
||||||
|
|
||||||
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINkcCTP0IE/ANIXJJIMWEg4f5riS8uv3KuypkzQC47XN roosensjef@gmail.com
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
- name: restart networking
|
||||||
|
service:
|
||||||
|
name: networking
|
||||||
|
state: restarted
|
|
@ -1,25 +1,37 @@
|
||||||
- name: Install packages
|
---
|
||||||
|
- name: Install sudo.
|
||||||
apt:
|
apt:
|
||||||
name:
|
name: sudo
|
||||||
# Needed for handling GPG keys for repositories
|
|
||||||
- debian-keyring
|
|
||||||
- debian-archive-keyring
|
|
||||||
- apt-transport-https
|
|
||||||
|
|
||||||
# Easy to edit files
|
|
||||||
- vim
|
|
||||||
- tmux
|
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Install Vim config
|
- name: Create debian user.
|
||||||
get_url:
|
user:
|
||||||
url: 'https://r8r.be/vim'
|
name: debian
|
||||||
dest: '{{ item.dest }}'
|
groups: sudo
|
||||||
owner: "{{ item.user }}"
|
append: true
|
||||||
group: "{{ item.user }}"
|
create_home: yes
|
||||||
mode: '644'
|
shell: /bin/bash
|
||||||
with_items:
|
password: "{{ vault_debian_pass | password_hash('sha512') }}"
|
||||||
- user: debian
|
update_password: on_create
|
||||||
dest: "/home/debian/.vimrc"
|
|
||||||
- user: root
|
- name: Create SSH directory.
|
||||||
dest: "/root/.vimrc"
|
file:
|
||||||
|
path: /home/debian/.ssh/
|
||||||
|
state: directory
|
||||||
|
owner: debian
|
||||||
|
group: debian
|
||||||
|
mode: '700'
|
||||||
|
|
||||||
|
- name: Add authorized SSH keys.
|
||||||
|
copy:
|
||||||
|
src: authorized_keys
|
||||||
|
dest: /home/debian/.ssh/authorized_keys
|
||||||
|
owner: debian
|
||||||
|
group: debian
|
||||||
|
mode: '600'
|
||||||
|
|
||||||
|
- name: Install networking config file.
|
||||||
|
template:
|
||||||
|
src: interfaces.j2
|
||||||
|
dest: /etc/network/interfaces.d/eth0
|
||||||
|
notify: restart networking
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
auto eth0
|
||||||
|
iface eth0 inet static
|
||||||
|
address {{ static_ip }}
|
||||||
|
broadcast {{ broadcast_ip }}
|
||||||
|
netmask 255.255.255.0
|
||||||
|
gateway {{ router_ip }}
|
||||||
|
dns-nameservers {{ router_ip }} 8.8.8.8
|
|
@ -0,0 +1,26 @@
|
||||||
|
- name: Install packages
|
||||||
|
apt:
|
||||||
|
name:
|
||||||
|
# Needed for handling GPG keys for repositories
|
||||||
|
- debian-keyring
|
||||||
|
- debian-archive-keyring
|
||||||
|
- apt-transport-https
|
||||||
|
|
||||||
|
# Easy to edit files
|
||||||
|
- vim
|
||||||
|
- tmux
|
||||||
|
- htop
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Install Vim config
|
||||||
|
get_url:
|
||||||
|
url: 'https://r8r.be/vim'
|
||||||
|
dest: '{{ item.dest }}'
|
||||||
|
owner: "{{ item.user }}"
|
||||||
|
group: "{{ item.user }}"
|
||||||
|
mode: '644'
|
||||||
|
with_items:
|
||||||
|
- user: debian
|
||||||
|
dest: "/home/debian/.vimrc"
|
||||||
|
- user: root
|
||||||
|
dest: "/root/.vimrc"
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
- name: Update package database
|
||||||
|
raw: apt update
|
||||||
|
|
||||||
|
- name: Install Python
|
||||||
|
raw: apt install -y python3
|
Loading…
Reference in New Issue