mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Use Ansible mount module options to modify /etc/fstab
This commit is contained in:
parent
e7717a8890
commit
67e4258335
@ -1,23 +0,0 @@
|
||||
"""
|
||||
This Python 3 script reads the /etc/fstab file line by line
|
||||
and writes a new file /tmp/fstab line by line.
|
||||
If a line contains the string '/dev/xvdp', it replaces that
|
||||
line with:
|
||||
/dev/xvdp /data ext4 defaults,nofail,nobootwait 0 2
|
||||
It then:
|
||||
- moves /etc/fstab to /etc/old_fstab
|
||||
- moves /tmp/fstab to /etc/fstab
|
||||
"""
|
||||
|
||||
import shutil
|
||||
|
||||
with open('/tmp/fstab', 'a') as tmp_fstab:
|
||||
with open('/etc/fstab') as f:
|
||||
for line in f:
|
||||
if '/dev/xvdp' in line:
|
||||
tmp_fstab.write('/dev/xvdp /data ext4 defaults,nofail,nobootwait 0 2\n')
|
||||
else:
|
||||
tmp_fstab.write(line)
|
||||
|
||||
shutil.move('/etc/fstab', '/etc/old_fstab')
|
||||
shutil.move('/tmp/fstab', '/etc/fstab')
|
@ -8,33 +8,22 @@
|
||||
filesystem: fstype=ext4 dev=/dev/xvdp
|
||||
become: true
|
||||
|
||||
# Note that this also modifies /etc/fstab so the mount will persist through a crash
|
||||
- name: Ensure /data dir exists and is mounted on /dev/xvdp + update /etc/fstab
|
||||
mount: name=/data src=/dev/xvdp fstype=ext4 state=mounted
|
||||
# Note that this also modifies /etc/fstab so the mount will persist through a crash.
|
||||
# To better understand the /etc/fstab fields/columns, see:
|
||||
# http://man7.org/linux/man-pages/man5/fstab.5.html
|
||||
# https://tinyurl.com/jmmsyon = the soure code of the mount module
|
||||
- name: Ensure /data dir exists and is mounted + update /etc/fstab
|
||||
mount:
|
||||
name=/data
|
||||
src=/dev/xvdp
|
||||
fstype=ext4
|
||||
opts="defaults,nofail,nobootwait"
|
||||
dump=0
|
||||
passno=2
|
||||
state=mounted
|
||||
become: true
|
||||
|
||||
# After allowing the above to proceed,
|
||||
# I did "cat /etc/fstab" and got:
|
||||
# LABEL=cloudimg-rootfs / ext4 defaults,discard 0 0
|
||||
# /dev/xvdp /data ext4 defaults 0 0
|
||||
|
||||
# Let's change "defaults 0 0" to "defaults,nofail,nobootwait 0 2"
|
||||
|
||||
- name: Ensure any old edit_etc_fstab.py file is deleted
|
||||
file: name=/tmp/edit_etc_fstab.py state=absent
|
||||
|
||||
- name: Copy local Python script edit_etc_fstab.py to the remote host
|
||||
copy: src={{role_path}}/tasks/edit_etc_fstab.py dest=/tmp/edit_etc_fstab.py
|
||||
|
||||
- name: Run edit_etc_fstab.py using Python 3
|
||||
shell: /usr/bin/python3 /tmp/edit_etc_fstab.py
|
||||
become: true
|
||||
|
||||
- name: Ensure /tmp/edit_etc_fstab.py is deleted
|
||||
file: name=/tmp/edit_etc_fstab.py state=absent
|
||||
|
||||
# Modify the I/O scheduler? Is that even a good idea?
|
||||
# Must do this in /sys/block/xvdp/queue/scheduler
|
||||
# and also with grub (so the I/O scheduler stays changed on reboot)
|
||||
# Example: https://gist.github.com/keithchambers/80b60559ad83cebf1672
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user