diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-06-03 20:06:25 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-06-03 20:52:08 +0300 |
commit | 11dbc00cdda6b43d1e1aba5220062b8517c63f3c (patch) | |
tree | fa1e2ac87c810e1a53ff1e06f208b45f5574c34b | |
parent | f9722d363779bb949e1912b2f5fdfdec5709df09 (diff) | |
download | vmdb2-11dbc00cdda6b43d1e1aba5220062b8517c63f3c.tar.gz |
Add: Ansible plugin
-rw-r--r-- | NEWS | 8 | ||||
-rw-r--r-- | ansible.vmdb | 47 | ||||
-rw-r--r-- | pc.vmdb | 8 | ||||
-rw-r--r-- | roles/set_hostname/tasks/main.yml | 3 | ||||
-rw-r--r-- | roles/unset_root_password/tasks/main.yml | 3 |
5 files changed, 67 insertions, 2 deletions
@@ -4,6 +4,14 @@ NEWS for vmdb2, the Debian disk image builder Version 0.3+git, not yet released --------------------------------- +* Add a rudimenteary smoke test yarn for vmdb2-built images. + +* Add a plugin to run Ansible to configure an image at build time. + Doing this via Ansible saves me from having to write equivalent + functionality directly into vmdb2, which would be quite a lot of + work. (If someone wants puppet, a plugin for that is probably easily + doable, assuming it can run against a chroot. I don't now, I've + never used puppet.) Version 0.3, released 2017-05-21 --------------------------------- diff --git a/ansible.vmdb b/ansible.vmdb new file mode 100644 index 0000000..a8c0343 --- /dev/null +++ b/ansible.vmdb @@ -0,0 +1,47 @@ +# This is a sample VMDB2 input file to specify a simple +# system that boots on a PC with BIOS. + +steps: + - mkimg: "{{ output }}" + size: 4G + + - mklabel: msdos + device: "{{ output }}" + + - mkpart: primary + device: "{{ output }}" + start: 0% + end: 100% + part-tag: root-part + + - mkfs: ext4 + partition: root-part + + - mount: root-part + fs-tag: root-fs + + - unpack-rootfs: root-fs + + - debootstrap: stretch + mirror: http://http.debian.net/debian + target: root-fs + unless: rootfs_unpacked + + - apt: linux-image-amd64 + fs-tag: root-fs + unless: rootfs_unpacked + + - apt: python + fs-tag: root-fs + unless: rootfs_unpacked + + - cache-rootfs: root-fs + unless: rootfs_unpacked + + - ansible: root-fs + playbook: ansible.yml + + - grub: bios + root-fs: root-fs + root-part: root-part + device: "{{ output }}" @@ -36,8 +36,12 @@ steps: - chroot: root-fs shell: | - sed -i '/^root:[^:]*:/s//root::/' /etc/passwd - echo pc-vmdb2 > /etc/hostname + apt -y install python + + - shell: | + printf '[pc]\n%s hostname=pc\n' "$ROOT" > pc.inventory + ansible-playbook -i pc.inventory -c chroot pc.yml + root-fs: root-fs - grub: bios root-fs: root-fs diff --git a/roles/set_hostname/tasks/main.yml b/roles/set_hostname/tasks/main.yml new file mode 100644 index 0000000..f1b9649 --- /dev/null +++ b/roles/set_hostname/tasks/main.yml @@ -0,0 +1,3 @@ +- name: set /etc/hostname + shell: | + echo "{{ hostname }}" > /etc/hostname diff --git a/roles/unset_root_password/tasks/main.yml b/roles/unset_root_password/tasks/main.yml new file mode 100644 index 0000000..67134fd --- /dev/null +++ b/roles/unset_root_password/tasks/main.yml @@ -0,0 +1,3 @@ +- name: unset root password + shell: | + sed -i '/^root:[^:]*:/s//root::/' /etc/passwd |