From 6ba4db526768cbf26baad923e288bcbd1fa061eb Mon Sep 17 00:00:00 2001 From: Seth Vidal Date: Wed, 1 May 2013 22:28:12 +0000 Subject: [PATCH] initial commit of koji/make_builder playbook which replaces the new_builder builder script in a shockingly small amount of playbook code --- inventory/group_vars/buildvm | 2 +- playbooks/koji/make_builder.yml | 56 +++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 playbooks/koji/make_builder.yml diff --git a/inventory/group_vars/buildvm b/inventory/group_vars/buildvm index 5af35264bb..e1cdbf5f94 100644 --- a/inventory/group_vars/buildvm +++ b/inventory/group_vars/buildvm @@ -9,7 +9,7 @@ nm: 255.255.255.0 gw: 10.5.125.254 dns: 10.5.126.21 volgroup: /dev/vg_host01 -install_command: /usr/bin/virt-install -n ${inventory_hostname} -r ${mem_size} +install_command: /usr/sbin/virt-install -n ${inventory_hostname} -r ${mem_size} --disk ${volgroup}/${inventory_hostname_short} --vcpus=${num_cpus} -l ${ks_repo} -x "ksdevice=eth0 ks=${ks_url} ip=${eth0_ip} netmask=${nm} diff --git a/playbooks/koji/make_builder.yml b/playbooks/koji/make_builder.yml new file mode 100644 index 0000000000..c3c8470438 --- /dev/null +++ b/playbooks/koji/make_builder.yml @@ -0,0 +1,56 @@ +# create a new koji builder +# NOTE: should be used with --limit most of the time +# NOTE: make sure there is room/space for this builder on the buildvmhost +# NOTE: most of these vars come from group_vars/buildvm or from hostvars + +- name: make koji builder(s) + hosts: buildvm + user: root + gather_facts: False + + vars_files: + - /srv/web/infra/ansible/vars/global.yml + - ${private}/vars.yml + - ${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 vnc port + local_action: wait_for delay=180 host=${inventory_hostname} port=1 state=stopped timeout=900 + + - name: start the vm up + action: virt state=running name=${inventory_hostname} + delegate_to: $vmhost + + - name: set the vm up to autostart + action: virt command=autostart 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=300 + + + # include postinstall playbook +# - include: $playbooks/koji/build_postinstall.yml + +