From 1696cc678a9269a72424b2f31e85a96edd3ea029 Mon Sep 17 00:00:00 2001 From: Seth Vidal Date: Fri, 3 May 2013 16:56:38 +0000 Subject: [PATCH] restructure virt to be more like cloud creation remove a line from the todo --- TODO | 1 - playbooks/koji/make_builder.yml | 40 ++++----------------------------- tasks/virt_instance_create.yml | 34 ++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 37 deletions(-) create mode 100644 tasks/virt_instance_create.yml diff --git a/TODO b/TODO index 3dcc88ad5b..31f74ea7ec 100644 --- a/TODO +++ b/TODO @@ -13,6 +13,5 @@ - figure out how and where we are going to run these from cron - merge in tasks/playbooks/inventory/etc from: - - euca cloud - builders diff --git a/playbooks/koji/make_builder.yml b/playbooks/koji/make_builder.yml index ef2b1ac222..f25a391cfa 100644 --- a/playbooks/koji/make_builder.yml +++ b/playbooks/koji/make_builder.yml @@ -14,44 +14,12 @@ - ${vars}/${ansible_distribution}.yml tasks: - - name: get vm list on the vmhost - delegate_to: $vmhost - virt: command=list_vms - register: result - - - name: check if the host is already defined/existent - local_action: fail msg="host is up, need to kill it first" - when_string: ${inventory_hostname} in ${result.list_vms} - - - name: echo well we got here - local_action: ping - delegate_to: $vmhost - - - name: ensure the lv for the host is made - lvol: lv=$inventory_hostname_short vg=$volgroup size=$lvm_size state=present - delegate_to: $vmhost - - - name: run the virt-install - shell: ${install_command} - delegate_to: $vmhost - - - name: wait for the install to finish - by watching the domstate - # this just keeps checking the domstate until it stops running - shell: while `/usr/bin/virsh domstate ${inventory_hostname} | grep -q running` ; do sleep 20; done - delegate_to: $vmhost - async: 1200 - poll: 10 - - - name: start the vm up - action: virt state=running name=${inventory_hostname} - delegate_to: $vmhost - - - name: wait for ssh on the vm to start back - local_action: wait_for delay=10 host=${inventory_hostname} port=22 state=started timeout=1200 - + - include: $tasks/virt_instance_create.yml + - name: ping the host + ping: msg="pingy" # include postinstall playbook -- include: /srv/web/infra/ansible/playbooks/koji/config_builder.yml +#- include: /srv/web/infra/ansible/playbooks/koji/config_builder.yml diff --git a/tasks/virt_instance_create.yml b/tasks/virt_instance_create.yml new file mode 100644 index 0000000000..1dbdfd2db2 --- /dev/null +++ b/tasks/virt_instance_create.yml @@ -0,0 +1,34 @@ +# setup a virt instance using a dizzying array of variables :) +- name: get vm list on the vmhost + delegate_to: $vmhost + virt: command=list_vms + register: result + +- name: ensure the lv for the host is made + lvol: lv=$inventory_hostname_short vg=$volgroup size=$lvm_size state=present + delegate_to: $vmhost + when_string: ${inventory_hostname} not in ${result.list_vms} + +- name: run the virt-install + shell: ${install_command} + delegate_to: $vmhost + when_string: ${inventory_hostname} not in ${result.list_vms} + +- name: wait for the install to finish - by watching the domstate + # this just keeps checking the domstate until it stops running + shell: while `/usr/bin/virsh domstate ${inventory_hostname} | grep -q running` ; do sleep 20; done + delegate_to: $vmhost + async: 1200 + poll: 10 + when_string: ${inventory_hostname} not in ${result.list_vms} + +- name: start the vm up + action: virt state=running name=${inventory_hostname} + delegate_to: $vmhost + when_string: ${inventory_hostname} not in ${result.list_vms} + +- name: wait for ssh on the vm to start back + local_action: wait_for delay=10 host=${inventory_hostname} port=22 state=started timeout=1200 + when_string: ${inventory_hostname} not in ${result.list_vms} + +