Commit 2d0be32c authored by bbguimaraes's avatar bbguimaraes
Browse files

ansible: bbb

parent dc44e5c3
beaglebone black
================
https://archlinuxarm.org/platforms/armv7/ti/beaglebone-black
Start by adapting `vars.yaml` to the particular setup.
Execute `sd.yaml` to install and setup SD card as boot device.
$ ansible-playbook \
--inventory localhost, --connection local \
--extra-vars @ansible/bbb/vars.yaml \
--become \
ansible/bbb/sd.yaml
The initial setup has to be done on the device, unless another ARM computer is
available. Transfer the SD card to the device, initialize it, and update
packages:
# pacman-key --init
# pacman-key --populate archlinuxarm
# pacman -Syyu
Install the LVM package so the VG can be mounted during initialization and the
Ansible pre-requisites:
# pacman -Su lvm2 python sudo
Repurpose the `alarm` user:
# usermod --gid users alarm
# groupdel alarm
# groupmod --gid 1000 users
# usermod --login bbguimaraes --home /home/bbguimaraes alarm
# mv /home/alarm ~bbguimaraes
Power off, transfer the card back, make sure the disks are plugged in, and
execute the playbook to to set up RAID as external storage and move dynamic
directories (`/home`, `/var`) to it.
$ ansible-playbook \
--inventory localhost, --connection local \
--extra-vars @ansible/bbb/vars.yaml \
--become \
ansible/bbb/disk.yaml
Transfer everything to the device and finish the installation:
$ ansible-playbook \
--inventory ansible/hosts --limit bbb \
--become --become-method su --ask-become-pass \
--extra-vars sudo_wheel_nopasswd=true \
ansible/install/base.yaml
$ ansible-playbook \
--inventory ansible/hosts --limit bbb \
--become --become-method su --ask-become-pass \
--extra-vars sudo_wheel_nopasswd=true \
ansible/bbb/install.yaml
$ ansible-playbook \
--inventory ansible/hosts --limit bbb \
--user root \
ansible/install/base_user.yaml
$ ansible-playbook \
--inventory ansible/hosts --limit bbb \
ansible/install/base_user.yaml
Set user password and lock `root` account:
# passwd --lock root
- hosts: all
tasks:
- name: create physical volumes / volume groups
lvg:
state: present
pvs: "{{ pvs }}"
vg: "{{ vg }}"
- name: create swap logical volume
lvol:
state: present
vg: "{{ vg }}"
lv: "{{ swap_lv }}"
size: "{{ swap_size }}"
- name: format swap volume
filesystem:
dev: "{{ swap_dev }}"
fstype: swap
- name: format raid volume
filesystem:
dev: "{{ raid_dev }}"
fstype: ext4
- name: create mount points
file:
state: directory
path: "{{ item }}"
loop:
- "{{ sd_mount_root }}"
- "{{ raid_mount_root }}"
- name: mount SD card
command:
argv:
- mount
- -t
- ext4
- "{{ item.0 }}"
- "{{ item.1 }}"
when: |
item.1 not in ansible_mounts|map(attribute="mount")
loop:
- - "{{ sd_card_dev }}-part1"
- "{{ sd_mount_root }}"
- - "{{ raid_dev }}"
- "{{ raid_mount_root }}"
- name: create storage directory
file:
state: directory
path: "{{ item }}"
loop:
- "{{ sd_mount_root }}"
- "{{ raid_mount_dir }}"
- name: list files in root
command: ls "{{ sd_mount_root }}"
register: out
changed_when: false
- name: move mounts to raid
shell: |
mv -t "{{ raid_mount_dir }}/" "{{ sd_mount_root }}/{{ item }}"
when: item in out.stdout_lines
loop: "{{ raid_mounts }}"
- name: add raid to fstab
mount:
state: present
fstab: "{{ sd_mount_root }}/etc/fstab"
fstype: ext4
src: "{{ raid_dev }}"
path: "{{ raid_mount_root }}"
opts: defaults
- name: add bind mounts to fstab
mount:
state: present
fstab: "{{ sd_mount_root }}/etc/fstab"
fstype: none
src: "{{ raid_mount_dir }}/{{ item }}"
path: "/{{ item }}"
opts: defaults,bind
loop: "{{ raid_mounts }}"
- name: unmount
command:
argv:
- umount
- "{{ item }}"
when: item in ansible_mounts|map(attribute="mount")
loop:
- "{{ raid_mount_root }}"
- "{{ sd_mount_root }}"
- hosts: all
tasks:
- name: partition SD card
parted:
state: present
device: "{{ sd_card_dev }}"
number: 1
part_start: 2048s
part_end: 100%
align: none
- name: format SD card
filesystem:
dev: "{{ sd_card_dev }}-part1"
fstype: ext4
- name: mount SD card
command:
argv:
- mount
- "{{ sd_card_dev }}-part1"
- "{{ sd_mount_root }}"
when: |
sd_mount_root not in ansible_mounts|map(attribute="mount")
- name: list files in root
command: ls "{{ sd_mount_root }}"
register: out
changed_when: false
- name: extract Arch Linux package
unarchive:
src: "{{ arch_pkg }}"
dest: "{{ sd_mount_root }}"
when: out.stdout in ("", "lost+found")
- name: install bootloader (0)
command:
argv:
- dd
- if={{ sd_mount_root }}/boot/MLO
- of={{ sd_card_dev }}
- count=1
- seek=1
- conv=notrunc
- bs=128k
- name: install bootloader (1)
command:
argv:
- dd
- if={{ sd_mount_root }}/boot/u-boot.img
- of={{ sd_card_dev }}
- count=2
- seek=1
- conv=notrunc
- bs=384k
- name: install ssh key
authorized_key:
state: present
user: bbguimaraes
path: "{{ sd_mount_root }}/home/alarm/.ssh/authorized_keys"
key: "{{ lookup('file', ssh_pub_key) }}"
manage_dir: false
- name: unmount SD card
command:
argv:
- umount
- "{{ sd_card_dev }}-part1"
when: |
sd_mount_root in ansible_mounts|map(attribute="mount")
# Host files
user_home: /home/bbguimaraes
arch_pkg: '{{ user_home }}/ArchLinuxARM-am33x-latest.tar.gz'
ssh_pub_key: '{{ user_home }}/.ssh/id_rsa.pub'
# SD card device
sd_card_dev: /dev/disk/by-id/usb-Generic-_SD_MMC_20120501030900000-0:0
sd_mount_root: /mnt/sd
# External storage
pvs:
- /dev/disk/by-id/usb-Seagate_Backup+_BK_NA5CNF0A-0:0
- /dev/disk/by-id/usb-Seagate_Backup+_BK_NA5CL99P-0:0
vg: rpi_vg0
raid_lv: raid1
raid_dev: /dev/{{ vg }}/{{ raid_lv }}
raid_mount_root: /mnt/rpi_raid1
raid_mount_dir: '{{ raid_mount_root }}/rootfs/bbb'
raid_mounts: ['home', 'var']
# Swap
swap_lv: swap
swap_dev: /dev/{{ vg }}/{{ swap_lv }}
swap_size: 8G
......@@ -13,6 +13,7 @@ tenochtitlan
tjobim
rmanzarek
rh0
bbb
[personal]
tjobim
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment