2014-07-07 17:17:39 +00:00
|
|
|
#
|
|
|
|
# This task is the thing that creates a vm for later use
|
|
|
|
#
|
2013-05-03 16:58:47 +00:00
|
|
|
|
2014-07-07 17:17:39 +00:00
|
|
|
- name: get vm list
|
2013-11-25 18:37:51 +00:00
|
|
|
delegate_to: "{{ vmhost }}"
|
2013-05-03 16:56:38 +00:00
|
|
|
virt: command=list_vms
|
|
|
|
register: result
|
2016-11-01 16:29:49 +00:00
|
|
|
check_mode: no
|
2013-05-03 16:56:38 +00:00
|
|
|
|
2014-07-07 17:17:39 +00:00
|
|
|
- name: ensure the lv for the guest is made
|
2013-11-25 18:33:35 +00:00
|
|
|
lvol: lv={{ inventory_hostname }} vg={{ volgroup }} size={{ lvm_size }} state=present
|
2013-11-25 18:37:51 +00:00
|
|
|
delegate_to: "{{ vmhost }}"
|
2013-06-11 16:29:13 +00:00
|
|
|
when: inventory_hostname not in result.list_vms
|
2013-05-03 16:56:38 +00:00
|
|
|
|
2014-07-07 17:17:39 +00:00
|
|
|
- name: run the virt-install
|
2013-11-25 18:33:35 +00:00
|
|
|
shell: "{{ virt_install_command }}"
|
2013-11-25 18:37:51 +00:00
|
|
|
delegate_to: "{{ vmhost }}"
|
2013-06-11 16:29:13 +00:00
|
|
|
when: inventory_hostname not in result.list_vms
|
2013-05-03 16:56:38 +00:00
|
|
|
|
2014-07-07 17:17:39 +00:00
|
|
|
- name: wait for the install to finish
|
2014-07-03 16:37:35 +00:00
|
|
|
virt: command=status name={{ inventory_hostname }}
|
|
|
|
register: vmstatus
|
|
|
|
until: vmstatus.status == 'shutdown'
|
2013-11-25 18:37:51 +00:00
|
|
|
delegate_to: "{{ vmhost }}"
|
2014-07-19 23:41:52 +00:00
|
|
|
retries: 1500
|
2014-07-03 16:37:35 +00:00
|
|
|
delay: 10
|
2013-06-11 16:46:07 +00:00
|
|
|
when: inventory_hostname not in result.list_vms
|
2013-05-03 16:56:38 +00:00
|
|
|
|
2017-04-13 17:58:50 +00:00
|
|
|
- name: ARMv7 copy the kernel out
|
2017-04-13 19:17:57 +00:00
|
|
|
shell: "virt-builder --get-kernel {{ volgroup }}/{{ inventory_hostname }} --output /var/lib/libvirt/images/ | awk -F/ '{print $NF}' > /var/lib/libvirt/images/{{ inventory_hostname }}-details.txt"
|
2017-04-13 18:36:47 +00:00
|
|
|
delegate_to: "{{ vmhost}}"
|
2017-04-13 17:58:50 +00:00
|
|
|
when: inventory_hostname.startswith('buildvm-armv7')
|
|
|
|
|
|
|
|
- name: ARMv7 copy the cmdline out
|
2017-04-13 19:17:57 +00:00
|
|
|
shell: "virt-cat -a {{ volgroup }}/{{ inventory_hostname }} /boot/extlinux/extlinux.conf | grep -m1 append | sed -e 's/append //'"
|
2017-04-13 18:36:47 +00:00
|
|
|
delegate_to: "{{ vmhost}}"
|
2017-04-13 17:58:50 +00:00
|
|
|
register: host_cmdline
|
|
|
|
when: inventory_hostname.startswith('buildvm-armv7')
|
|
|
|
|
|
|
|
- name: ARMv7 update the virt parameters
|
2017-04-13 19:38:25 +00:00
|
|
|
virt_boot: domain={{ inventory_hostname }} kernel="/var/lib/libvirt/images/vmlinuz-4.10.8-200.fc25.armv7hl+lpae" initrd="/var/lib/libvirt/images/initramfs-4.10.8-200.fc25.armv7hl+lpae.img" cmdline={{ host_cmdline }}
|
2017-04-13 18:36:47 +00:00
|
|
|
delegate_to: "{{ vmhost}}"
|
2017-04-13 17:58:50 +00:00
|
|
|
when: inventory_hostname.startswith('buildvm-armv7')
|
|
|
|
|
2014-07-07 17:17:39 +00:00
|
|
|
- name: start the vm up
|
2017-04-13 01:37:21 +00:00
|
|
|
virt: state=started name={{ inventory_hostname }}
|
2013-11-25 18:37:51 +00:00
|
|
|
delegate_to: "{{ vmhost }}"
|
2013-06-11 16:46:07 +00:00
|
|
|
when: inventory_hostname not in result.list_vms
|
2013-05-03 16:56:38 +00:00
|
|
|
|
2014-07-07 17:17:39 +00:00
|
|
|
- name: set it to autostart
|
2016-01-06 21:25:10 +00:00
|
|
|
virt: command=autostart name={{ inventory_hostname }}
|
2014-06-27 20:08:54 +00:00
|
|
|
delegate_to: "{{ vmhost }}"
|
|
|
|
when: inventory_hostname not in result.list_vms
|
|
|
|
|
2015-04-22 14:41:48 +00:00
|
|
|
- name: make sure there is no old ssh host key for the host still around
|
|
|
|
local_action: known_hosts path={{item}} host={{ inventory_hostname }} state=absent
|
|
|
|
ignore_errors: True
|
|
|
|
with_items:
|
|
|
|
- /root/.ssh/known_hosts
|
|
|
|
- /etc/ssh/ssh_known_hosts
|
|
|
|
when: inventory_hostname not in result.list_vms
|
|
|
|
|
2016-10-25 19:13:19 +00:00
|
|
|
- name: (osbs-control01.stg) make sure there is no old ssh host key for the host still around
|
|
|
|
known_hosts: path={{item}} host={{ inventory_hostname }} state=absent
|
|
|
|
ignore_errors: True
|
|
|
|
with_items:
|
|
|
|
- /root/.ssh/known_hosts
|
|
|
|
- /etc/ssh/ssh_known_hosts
|
|
|
|
when: inventory_hostname not in result.list_vms and inventory_hostname in groups['osbs-masters-stg']+groups['osbs-nodes-stg']
|
|
|
|
delegate_to: osbs-control01.stg.phx2.fedoraproject.org
|
|
|
|
|
|
|
|
- name: (osbs-control01) make sure there is no old ssh host key for the host still around
|
|
|
|
known_hosts: path={{item}} host={{ inventory_hostname }} state=absent
|
|
|
|
ignore_errors: True
|
|
|
|
with_items:
|
|
|
|
- /root/.ssh/known_hosts
|
|
|
|
- /etc/ssh/ssh_known_hosts
|
|
|
|
when: inventory_hostname not in result.list_vms and inventory_hostname in groups['osbs-masters']+groups['osbs-nodes']
|
|
|
|
delegate_to: osbs-control01.phx2.fedoraproject.org
|
|
|
|
|
2013-05-03 16:56:38 +00:00
|
|
|
- name: wait for ssh on the vm to start back
|
2013-11-25 18:33:35 +00:00
|
|
|
local_action: wait_for delay=10 host={{ inventory_hostname }} port=22 state=started timeout=1200
|
2013-06-11 16:46:07 +00:00
|
|
|
when: inventory_hostname not in result.list_vms
|
2015-05-28 17:35:25 +00:00
|
|
|
|
|
|
|
- name: gather ssh host key from new instance
|
2015-05-28 17:49:23 +00:00
|
|
|
local_action: command ssh-keyscan -t rsa {{ inventory_hostname }}
|
2015-05-28 17:35:25 +00:00
|
|
|
ignore_errors: True
|
|
|
|
register: hostkey
|
|
|
|
when: inventory_hostname not in result.list_vms
|
|
|
|
|
|
|
|
- name: add new ssh host key (you still need to add it to official ssh_host_keys later)
|
2015-05-28 19:42:53 +00:00
|
|
|
local_action: known_hosts path={{item}} key="{{ hostkey.stdout }}" host={{ inventory_hostname }} state=present
|
2015-05-28 17:35:25 +00:00
|
|
|
ignore_errors: True
|
|
|
|
with_items:
|
|
|
|
- /root/.ssh/known_hosts
|
|
|
|
- /etc/ssh/ssh_known_hosts
|
|
|
|
when: inventory_hostname not in result.list_vms
|
|
|
|
|
2016-10-25 19:13:19 +00:00
|
|
|
- name: (osbs-control01.stg) add new ssh host key
|
|
|
|
known_hosts: path={{item}} key="{{ hostkey.stdout }}" host={{ inventory_hostname }} state=present
|
|
|
|
ignore_errors: True
|
|
|
|
with_items:
|
|
|
|
- /root/.ssh/known_hosts
|
|
|
|
- /etc/ssh/ssh_known_hosts
|
|
|
|
when: inventory_hostname not in result.list_vms and inventory_hostname in groups['osbs-masters-stg']+groups['osbs-nodes-stg']
|
|
|
|
delegate_to: osbs-control01.stg.phx2.fedoraproject.org
|
|
|
|
|
|
|
|
- name: (osbs-control01) add new ssh host key
|
|
|
|
known_hosts: path={{item}} key="{{ hostkey.stdout }}" host={{ inventory_hostname }} state=present
|
|
|
|
ignore_errors: True
|
|
|
|
with_items:
|
|
|
|
- /root/.ssh/known_hosts
|
|
|
|
- /etc/ssh/ssh_known_hosts
|
|
|
|
when: inventory_hostname not in result.list_vms and inventory_hostname in groups['osbs-masters']+groups['osbs-nodes']
|
|
|
|
delegate_to: osbs-control01.phx2.fedoraproject.org
|
|
|
|
|