From c43747fdc986007c804d6c4e8c8d05252123c370 Mon Sep 17 00:00:00 2001 From: Kayobe Automation Date: Mon, 14 Oct 2024 14:01:58 +0000 Subject: [PATCH 1/2] Add Blazar host create playbook --- etc/kayobe/ansible/blazar-host-create.yml | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 etc/kayobe/ansible/blazar-host-create.yml diff --git a/etc/kayobe/ansible/blazar-host-create.yml b/etc/kayobe/ansible/blazar-host-create.yml new file mode 100644 index 000000000..9464c897c --- /dev/null +++ b/etc/kayobe/ansible/blazar-host-create.yml @@ -0,0 +1,24 @@ +--- +- name: Create Blazar hosts + hosts: blazar-compute + gather_facts: false + vars: + venv: "/stack/kayobe-automation-env/venvs/os-venv" + tasks: + - 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' From 13d1807f081d3375b749f545076809a715fee4c8 Mon Sep 17 00:00:00 2001 From: Kayobe Automation Date: Wed, 16 Oct 2024 13:23:45 +0000 Subject: [PATCH 2/2] Ensure venv exists --- etc/kayobe/ansible/blazar-host-create.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/etc/kayobe/ansible/blazar-host-create.yml b/etc/kayobe/ansible/blazar-host-create.yml index 9464c897c..e46da7fdc 100644 --- a/etc/kayobe/ansible/blazar-host-create.yml +++ b/etc/kayobe/ansible/blazar-host-create.yml @@ -3,8 +3,22 @@ hosts: blazar-compute gather_facts: false vars: - venv: "/stack/kayobe-automation-env/venvs/os-venv" + 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: |