ansible/tasks/virt_instance_create.yml
Kevin Fenzi c84b99223c osbs: raise a glass for it's service
This removes osbs and allmost all it's associated playbooks and files.

It served long and well, but we no longer need it.
flatpaks are building with a koji-flatpak plugin.
base/minimal/toolbox containers are building with kiwi.
We aren't building any other containers right now, and we did they could
be added to kiwi.

This is the end of an era... I look with nostolga on
ansible-ansible-openshift-ansible (a role to setup ansible on a control
host and run it from our ansible).

Good bye osbs!

Signed-off-by: Kevin Fenzi <kevin@scrye.com>
2024-03-28 12:52:07 -07:00

72 lines
2.4 KiB
YAML

#
# This task is the thing that creates a vm for later use
#
- include_vars: dir=/srv/web/infra/ansible/vars/all/ ignore_files=README
- name: get vm list
vars:
ansible_python_interpreter: "{{ hostvars[vmhost]['ansible_python']['executable'] }}"
delegate_to: "{{ vmhost }}"
virt: command=list_vms
register: result
check_mode: no
- name: ensure no old facts exist
delegate_to: localhost
file: path=/root/.ansible_facts_cache/{{ inventory_hostname }} state=absent
when: inventory_hostname not in result.list_vms
- name: ensure the lv for the guest is made
lvol: lv={{ inventory_hostname }} vg={{ volgroup }} size={{ lvm_size }} state=present
delegate_to: "{{ vmhost }}"
when: inventory_hostname not in result.list_vms
- name: run the virt-install
shell: "{{ virt_install_command }}"
delegate_to: "{{ vmhost }}"
when: inventory_hostname not in result.list_vms
- name: wait for the install to finish -> {{ inventory_hostname }}
virt: command=status name={{ inventory_hostname }}
register: vmstatus
until: vmstatus.status == 'shutdown'
delegate_to: "{{ vmhost }}"
retries: 1500
delay: 20
when: inventory_hostname not in result.list_vms
- name: start the vm up and set it to autostart
virt: state=running name={{ inventory_hostname }} autostart=True
delegate_to: "{{ vmhost }}"
when: inventory_hostname not in result.list_vms
- 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
when: 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: inventory_hostname not in result.list_vms
- name: gather ssh host key from new instance
local_action: command ssh-keyscan -t rsa {{ inventory_hostname }}
ignore_errors: True
register: hostkey
when: inventory_hostname not in result.list_vms
- name: add new ssh host key (until we can sign it)
local_action: known_hosts path={{item}} key="{{ hostkey.stdout }}" host={{ inventory_hostname }} state=present
ignore_errors: True
with_items:
- /root/.ssh/known_hosts
when: inventory_hostname not in result.list_vms
- name: gather facts
setup:
check_mode: no
ignore_errors: True
register: facts
when: inventory_hostname not in result.list_vms