Compare commits

...

3 Commits

  1. 2
      files/lxd-databases.sh
  2. 2
      inventory.py
  3. 7
      setup-backup.py
  4. 28
      setup-base.py
  5. 3
      setup-zfs-and-lxd.py

2
files/lxd-databases.sh

@ -5,7 +5,7 @@ cd /var/backups/databases
for i in $(lxc list --format csv -c n); do
if lxc exec "$i" -- which mysql >/dev/null 2>&1; then
echo "Dumping $i"
lxc exec "$i" -- mysqldump --opt --all-databases --force --events --hex-blob | cat > "${i}.sql"
lxc exec "$i" -- mysqldump --opt --all-databases --force --hex-blob | cat > "${i}.sql"
fi
if lxc exec "$i" -- which psql >/dev/null 2>&1; then
if lxc exec "$i" -- id postgres >/dev/null 2>&1; then

2
inventory.py

@ -1 +1 @@
my_hosts = ['lxd.local']
my_hosts = ['lxd20.benpro.fr']

7
setup-backup.py

@ -9,6 +9,12 @@ apt.packages(
update=True,
)
if not host.fact.command('zpool list backup | grep backup || true'):
server.shell(
name='Create ZFS pool',
commands=['zpool create -o ashift=12 -o autotrim=on -O acltype=posixacl -O canmount=off -O compression=lz4 -O dnodesize=auto -O normalization=formD -O relatime=on -O xattr=sa backup /dev/vdb']
)
files.directory(
name='Ensure /var/backups/lxd exists',
path='/var/backups/lxd',
@ -105,4 +111,3 @@ systemd.service(
running=True,
enabled=True,
)

28
setup-base.py

@ -14,7 +14,7 @@ server.user(
server.hostname(
name='Set the hostname',
hostname='lxd.local',
hostname='lxd20.benpro.fr',
)
apt.update(
@ -25,20 +25,27 @@ apt.upgrade(
name='Upgrade apt packages',
)
apt.packages(
name='Install ufw',
packages=['ufw'],
update=False,
server.shell(
name='Add ufw rules',
commands=['ufw limit 22', 'ufw limit 28'],
)
server.shell(
name='Add ufw rules',
commands=['ufw limit 22'],
name='Enable ufw',
commands=['yes | ufw enable'],
)
server.shell(
name='Enable ufw',
commands=['yes | ufw enable'],
files.line(
name='Set port 28 for SSH',
path='/etc/ssh/sshd_config',
line=r'Port .*',
replace='Port 28',
)
systemd.service(
name='Reload sshd',
service='ssh.service',
reloaded=True,
)
apt.packages(
@ -89,4 +96,3 @@ files.put(
group='root',
mode='700',
)

3
setup-zfs-and-lxd.py

@ -12,7 +12,7 @@ apt.packages(
if not host.fact.command('zpool list local | grep local || true'):
server.shell(
name='Create ZFS pool',
commands=['zpool create -o ashift=12 -o autotrim=on -O acltype=posixacl -O canmount=off -O compression=lz4 -O dnodesize=auto -O normalization=formD -O relatime=on -O xattr=sa local /dev/vdb']
commands=['zpool create -o ashift=12 -o autotrim=on -O acltype=posixacl -O canmount=off -O compression=lz4 -O dnodesize=auto -O normalization=formD -O relatime=on -O xattr=sa local /dev/vda2']
)
files.put(
@ -78,4 +78,3 @@ systemd.service(
running=True,
enabled=True,
)
Loading…
Cancel
Save