blob: 969fb44bb42327626e16a43d675db2e266637637 [file] [log] [blame]
---
- hosts: all
connection: local
remote_user: chrome-bot
become_user: root
become: yes
become_method: sudo
vars:
net: 192.168.1.0
# override with --extra-vars "nfs_mount_point=/opt/stage"
nfs_mount_point: /opt/prod
# override with --extra-vars "image=/opt/rpi_img/stage.img"
image: /opt/rpi_img/prod.img
# 8192 * 512
offset_boot: 4194304
# 131072 * 512
offset_root: 67108864
# 122880 * 512
sizelimit_boot: 62914560
# 4624384 * 512
sizelimit_root: 2367684608
fsid: "2"
tasks:
- set_fact:
fsid: "1"
when: nfs_mount_point == "/opt/prod"
- file: path={{nfs_mount_point}}/boot state=directory
- file: path={{nfs_mount_point}}/root state=directory
- mount: src="{{image}}" name="{{nfs_mount_point}}/boot" fstype="auto" opts="loop,offset={{offset_boot}},sizelimit={{sizelimit_boot}},noauto" state="mounted"
- mount: src="{{image}}" name="{{nfs_mount_point}}/root" fstype="auto" opts="loop,offset={{offset_root}},sizelimit={{sizelimit_root}},noauto" state="mounted"
# start nfs
- service: name=nfs-kernel-server state=restarted
# make sure root stays mounted
- lineinfile: dest=/etc/cron.d/opt_raspberrypi_root line="* * * * * root /bin/mount {{nfs_mount_point}}/root" create=yes state=present
# Remount these at startup
- lineinfile: dest=/etc/rc.local line="mount {{nfs_mount_point}}/root" insertbefore="exit 0" create=yes
- lineinfile: dest=/etc/rc.local line="mount {{nfs_mount_point}}/boot" insertbefore="exit 0" create=yes
# It is very important to specify different fsids for the prod and staging mounts.
# It seems that if this is not done, both directories end up with the same fsid, which
# means they are indistinguishable to any nfs client and thus all RPIs will attach
# to the first nfs rule.
- name: make prod nfs sharing rule
lineinfile: dest=/etc/exports line="{{nfs_mount_point}}/root {{net}}/24(ro,sync,no_root_squash,no_subtree_check,fsid={{fsid}})"