summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-06-03 20:06:25 +0300
committerLars Wirzenius <liw@liw.fi>2017-06-03 20:52:08 +0300
commit11dbc00cdda6b43d1e1aba5220062b8517c63f3c (patch)
treefa1e2ac87c810e1a53ff1e06f208b45f5574c34b
parentf9722d363779bb949e1912b2f5fdfdec5709df09 (diff)
downloadvmdb2-11dbc00cdda6b43d1e1aba5220062b8517c63f3c.tar.gz
Add: Ansible plugin
-rw-r--r--NEWS8
-rw-r--r--ansible.vmdb47
-rw-r--r--pc.vmdb8
-rw-r--r--roles/set_hostname/tasks/main.yml3
-rw-r--r--roles/unset_root_password/tasks/main.yml3
5 files changed, 67 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 4d286e0..12420b5 100644
--- a/NEWS
+++ b/NEWS
@@ -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 }}"
diff --git a/pc.vmdb b/pc.vmdb
index c8f2bc6..c5d0a1e 100644
--- a/pc.vmdb
+++ b/pc.vmdb
@@ -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