summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <lwirzenius@wikimedia.org>2020-09-18 18:16:02 +0300
committerLars Wirzenius <lwirzenius@wikimedia.org>2020-09-18 18:16:02 +0300
commite4fae54bad14910c9bd02016443ebe92384ccdab (patch)
tree26a4252f30c91191d143a02d0477a0415379c71a
parent438bf651758828a3ff3dca4297cb5891b1aa05fc (diff)
downloadick-contractor-qemu.v2.tar.gz
stashqemu.v2
-rw-r--r--ansible.yml15
-rwxr-xr-xcontractor67
-rw-r--r--empty/not.empty1
-rw-r--r--hello.yaml2
-rw-r--r--test.yaml1
5 files changed, 73 insertions, 13 deletions
diff --git a/ansible.yml b/ansible.yml
index f84b205..61a6f17 100644
--- a/ansible.yml
+++ b/ansible.yml
@@ -21,11 +21,26 @@
- jq
- rsync
- kpartx
+ - python3-lxml
- name: "modify libvirt to use a non-standard IP range for guests"
shell:
sed -i 's/192\.168\.122\./192.168.99\./g' /etc/libvirt/qemu/networks/default.xml
args:
warn: no
+
+ - user:
+ name: debian
+ groups: libvirt
+ append: yes
+
+ - virt_net:
+ state: active
+ name: default
+
+ - virt_net:
+ autostart: yes
+ name: default
+
- user:
comment: "Manager"
name: manager
diff --git a/contractor b/contractor
index 4fe32a1..88cd63c 100755
--- a/contractor
+++ b/contractor
@@ -19,7 +19,7 @@ DEFAULT_CONFIGS = {os.path.expanduser("~/.config/contractor/config.yaml")}
# The device in the manager VM for the workspace disk.
-WS_DEV = "/dev/vdb"
+WS_DEV = "workspace.img"
# The worker VM image file on manager VM.
@@ -257,6 +257,22 @@ class StartGuestNetworking(MayFail):
return virsh("net-start", "default")
+class CreateWS(RemoteExecution):
+ def msg(self):
+ return "creating workspace disk on manager"
+
+ def argv(self):
+ return ["qemu-img", "create", "-f", "raw", WS_DEV, "20G"]
+
+
+class MkfsWS(RemoteExecution):
+ def msg(self):
+ return "mkfs workspace disk on manager"
+
+ def argv(self):
+ return ["sudo", "mkfs", "-t", "ext4", WS_DEV]
+
+
class MountWS(RemoteExecution):
def msg(self):
return "mounting workspace on manager"
@@ -576,16 +592,43 @@ def cmd_build(args):
# while to boot and we can do other things while that
# happens.
with Timer(vrb, "start-worker"):
- execs = [
- DestroyWorkerVM(),
- UndefineWorkerVM(),
- CopyWorkerImage(),
- StartGuestNetworking(),
- CreateWorkerVM(),
- TryUnmountWS(),
- MountWS(),
- ChownWS(),
- ]
+ execs = [DestroyWorkerVM()]
+ exec_quietly(manager, *execs)
+
+ with Timer(vrb, "start-worker-2"):
+ execs = [UndefineWorkerVM()]
+ exec_quietly(manager, *execs)
+
+ with Timer(vrb, "start-worker-3"):
+ execs = [CopyWorkerImage()]
+ exec_quietly(manager, *execs)
+
+ with Timer(vrb, "start-worker-4"):
+ execs = [StartGuestNetworking()]
+ exec_quietly(manager, *execs)
+
+ with Timer(vrb, "start-worker-5"):
+ execs = [CreateWorkerVM()]
+ exec_quietly(manager, *execs)
+
+ with Timer(vrb, "start-worker-6"):
+ execs = [TryUnmountWS()]
+ exec_quietly(manager, *execs)
+
+ with Timer(vrb, "start-worker-7"):
+ execs = [CreateWS()]
+ exec_quietly(manager, *execs)
+
+ with Timer(vrb, "start-worker-8"):
+ execs = [MkfsWS()]
+ exec_quietly(manager, *execs)
+
+ with Timer(vrb, "start-worker-9"):
+ execs = [MountWS()]
+ exec_quietly(manager, *execs)
+
+ with Timer(vrb, "start-worker-10"):
+ execs = [ChownWS()]
exec_quietly(manager, *execs)
with Timer(vrb, "upload-saved-workspace"):
@@ -606,7 +649,7 @@ def cmd_build(args):
worker_ip = parse_worker_ip(er.stdout)
with Timer(vrb, "prepare-workspace-worker"):
- worker_dest = "worker@{}".format(worker_ip)
+ worker_dest = "debian@{}".format(worker_ip)
vrb("worker is at {} (via manager)".format(worker_dest))
worker = OnWorker(dest, port, worker_dest, verbose=vrb)
exec_quietly(worker, Mkdir("/workspace"), MountWSonWorker())
diff --git a/empty/not.empty b/empty/not.empty
new file mode 100644
index 0000000..64017dc
--- /dev/null
+++ b/empty/not.empty
@@ -0,0 +1 @@
+this dir and this file are not empty
diff --git a/hello.yaml b/hello.yaml
index 9366cea..b87c7f1 100644
--- a/hello.yaml
+++ b/hello.yaml
@@ -9,7 +9,7 @@ ansible:
- build-essential
vars:
ansible_python_interpreter: /usr/bin/python3
-source: .
+source: empty
build: |
git clone git://git.liw/fi/heippa
cd heippa
diff --git a/test.yaml b/test.yaml
index 4461a8e..37ec1f7 100644
--- a/test.yaml
+++ b/test.yaml
@@ -1,3 +1,4 @@
manager_address: contractor
+manager_user: debian
verbose: yes
log: ~/contractor.log