diff --git a/etc/kayobe/ansible/blazar-host-create.yml b/etc/kayobe/ansible/blazar-host-create.yml new file mode 100644 index 000000000..e46da7fdc --- /dev/null +++ b/etc/kayobe/ansible/blazar-host-create.yml @@ -0,0 +1,38 @@ +--- +- name: Create Blazar hosts + hosts: blazar-compute + gather_facts: false + vars: + venv: "{{ virtualenv_path }}/blazar" + venv_python: "{{ 'python' ~ ansible_facts.python.version.major ~ '.' ~ ansible_facts.python.version.minor }}" + tasks: + - name: Set up openstack cli virtualenv + ansible.builtin.pip: + virtualenv: "{{ venv }}" + virtualenv_command: "{{ venv_python }} -m venv" + name: + - python-openstackclient + - python-blazarclient + state: latest + extra_args: "{% if pip_upper_constraints_file %}-c {{ pip_upper_constraints_file }}{% endif %}" + run_once: true + delegate_to: localhost + become: true + + - name: List Blazar compute hosts + ansible.builtin.shell: + cmd: | + {{ venv }}/bin/openstack reservation host show \ + {{ inventory_hostname }} \ + register: host_show + failed_when: false + changed_when: false + delegate_to: localhost + + - name: Ensure Blazar compute hosts are created + ansible.builtin.shell: + cmd: | + {{ venv }}/bin/openstack reservation host create \ + {{ inventory_hostname }} \ + delegate_to: localhost + when: '"Unable to find resource" in host_show.stderr'