Coder Social home page Coder Social logo

nilsmeyer / ansible-debootstrap Goto Github PK

View Code? Open in Web Editor NEW
35.0 35.0 19.0 121 KB

An ansible role for bootstrapping new Debian based systems, including setting up partitions, file systems, encryption (luks), RAID and LVM

License: GNU Lesser General Public License v3.0

Shell 26.58% Python 73.42%

ansible-debootstrap's People

Contributors

doubleo8 avatar mvk15 avatar nilsmeyer avatar progval avatar rpw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ansible-debootstrap's Issues

Add support for dropbear initramfs

For remote system it makes sense to use dropbear in initramfs, , since this may be required for first boot when there is no iKVM available.

  • install dropbear package
  • convert newly generated ssh keys to dropbear format
  • rebuild initramfs

Stretch goal:

  • Add some sort of remote unlock script

Support zfs legacy mountpoints

Since there are some problems with automounting ZFS on /var, it should be possible to use legacy mountpoints and add those filesystems to fstab

Round down LUKS partition to luks-sector-size boundary

device mapper has issues when the partition size doesn't divide cleanly by luks-sector-size. This is not an issue with devices that report a native sector size of 4KiB, but may be an issue otherwise. The partition size can be rounded down to eh 4KiB boundary so this problem does not occur - there probably needs to be some wiggle room for other data structures as well.

The error one sees with this is: device-mapper: reload ioctl on failed: Invalid argument
And in the kernel log:

device-mapper: table: 253:2: crypt: Device size is not multiple of sector_size feature
device-mapper: ioctl: error adding target to table

[Question] LVM for VMs

I have a volume group (vg0) on a vm host platform, which has all vm root partitions as volumes (/dev/vg0/testvm-root). The vm sees the volume as /dev/vda. I've been trying for a while now, but can't figure out a way to handle this with this role. Is it possible without modifying this too much or do I basically need to reimplement the handling of partitions?

Include the simplest possible example in README

Could you please include a simple example on how to make a simple directory debootstrap with this script? That would make it more complete and easier to try out.

I may do a PR when (or if) I figure it out. Is it a supported scenario to do an installation to a directory? It is especially useful for LXC containers.

"cryptsetup" tool uses early then it is installed

The first Ansible task in the file encryption.yml uses the command cryptsetup --version before it will be installed in the 3rd task:

---

- name: fetch cryptsetup version  <==========================
  command: "cryptsetup --version"
  changed_when: no
  register: _cryptsetup_version

- name: register version
  set_fact:
    cryptsetup_version: "{{ _cryptsetup_version.stdout[11:] }}"

- block:
  - name: install dependencies  <============================
    apt:
      name: "{{ dependencies.encryption }}"
      state: latest
      update_cache: no # skip cache check since we already ran apt

Add automated tests and test playbook

There should be a way to automatically test this, since it's a bit of a special use case may require some sort of special vagrant box (booted from secondary disk or so).

playbook fails creating /etc/fstab

trying to set up a system with 2 disks in mdadm raid, playbook gets to place templates in /etc and fails:

failed: [ip_address] (item={'src': 'fstab'}) => {"ansible_loop_var": "item", "changed": false, "item": {"src": "fstab"}, "msg": "AnsibleUndefinedVariable: 'dict object' has no attribute 'fs'"}
changed: [ip_address => (item={'src': 'crypttab', 'dest': 'crypttab'})

I believe because /dev/sd{a,b}1 has no filesystem (it's a boot partition)

~# lsblk -f
NAME      FSTYPE      LABEL                UUID                                 MOUNTPOINT
loop0     squashfs                                                              /lib/live/mount/rootfs/img.current.sq
sda                                                                             
├─sda1                                                                          
└─sda2    linux_raid_ 163-172-251-100:root 5d8518c2-7589-668b-d736-6c8a724d21a5 
  └─md127 ext4                             9a54cc12-4af5-43af-859b-59e23735ffbd /mnt/bootstrap
sdb                                                                             
├─sdb1                                                                          
└─sdb2    linux_raid_ 163-172-251-100:root 5d8518c2-7589-668b-d736-6c8a724d21a5 
  └─md127 ext4                             9a54cc12-4af5-43af-859b-59e23735ffbd /mnt/bootstrap

Creating the swap area in a logical volume (LVM)

Hi,
I really love your role Ansible! It is particularly suitable for my setup where the Debian installer can not do it.

Could you add swap support under LVM (mkswap and append to fstab) please ?

Here are my dictionaries:

release: buster
layout:
  - device: '/dev/sda'
    partitions:
      - num: 1
        size: 1M
        type: ef02
        label: BIOS
      - num: 2
        size: 100M
        type: ef00
        fs: vfat
        mount: /boot/efi
        mountdump: 0
        mountpass: 1
        mountopts: noatime,nofail,x-systemd.device-timeout=1,umask=0077
        label: EFI
      - num: 3
        size: 250M
        type: 8300
        fs: xfs
        mount: /boot
        mountdump: 0
        mountpass: 2
        mountopts: noatime,nodev,nosuid
        label: BOOT

lvm:
  - lv: swap
    vg: vg-srv
    pvs: /dev/sdb
    size: 1G
    opts: ~
    label: swap
    fs: swap
    mount: none
    mountdump: 0
    mountpass: 0
    mountopts: sw
  - lv: os
    vg: vg-srv
    pvs: /dev/sdb
    size: 15G
    opts: ~
    label: os
    fs: xfs
    mount: /
    mountdump: 0
    mountpass: 1
    mountopts: noatime,nodev

Thank you in advance

ZFS module issues with version 0.8

There is a problem with using ZFS from the jonathonf ppa - at some point the shipped and hopelessly outdated zfs module is loaded, preventing the newly installed/built module from loading, later on breaking ZFS support. The error looks like this:

failed: [ansible-debootstrap] (item={'poolname': 'rpool', 'devices': ['/dev/sdb3'], 'options': ['ashift=12'], 'fs_options': ['canmount=off', 'mountpoint=/', 'compression=lz4', 'atime=off', 'normalization=formD']}) => {"ansible_loop_var": "item", "changed": true, "cmd": ["zpool", "create", "-o", "ashift=12", "-O", "canmount=off", "-O", "mountpoint=/", "-O", "compression=lz4", "-O", "atime=off", "-O", "normalization=formD", "-R", "/mnt/bootstrap", "rpool", "/dev/sdb3"], "delta": "0:00:00.011030", "end": "2019-06-25 23:19:50.791048", "item": {"devices": ["/dev/sdb3"], "fs_options": ["canmount=off", "mountpoint=/", "compression=lz4", "atime=off", "normalization=formD"], "options": ["ashift=12"], "poolname": "rpool"}, "msg": "non-zero return code", "rc": 1, "start": "2019-06-25 23:19:50.780018", "stderr": "cannot create 'rpool': invalid argument for this pool operation", "stderr_lines": ["cannot create 'rpool': invalid argument for this pool operation"], "stdout": "", "stdout_lines": []}

The problem is a version mismatch between the module and the installed zfs utils. Using the old ZFS version works.

Convert to two stage playbook to enable running user roles

Instead of running a lot of things via the shell module, invoking chroot, I think it may be more prudent to at least temporarily start an sshd instance in the chrooted system (on a different port or possibly tunneled through the main host), then allow further plays to be executed on that sshd instance. This would also allow the user to add their roles to the playbook and allows separating out some of the more advanced features.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.