diff --git a/playbooks/roles/bifrost-create-vm-nodes/defaults/main.yml b/playbooks/roles/bifrost-create-vm-nodes/defaults/main.yml index 56b34d8d7..2a5ff56e4 100644 --- a/playbooks/roles/bifrost-create-vm-nodes/defaults/main.yml +++ b/playbooks/roles/bifrost-create-vm-nodes/defaults/main.yml @@ -19,6 +19,7 @@ test_vm_node_driver: ipmi redfish_emulator_host: localhost redfish_emulator_port: 9132 +redfish_emulator_state_dir: /var/lib/redfish-emulator # NOTE(pas-ha) name and default are chosen to be the same # as in 'bifrost-ironic-install' role diff --git a/playbooks/roles/bifrost-create-vm-nodes/tasks/prepare_libvirt.yml b/playbooks/roles/bifrost-create-vm-nodes/tasks/prepare_libvirt.yml index 29b9e459a..291678692 100644 --- a/playbooks/roles/bifrost-create-vm-nodes/tasks/prepare_libvirt.yml +++ b/playbooks/roles/bifrost-create-vm-nodes/tasks/prepare_libvirt.yml @@ -217,6 +217,15 @@ vars: package: sushy-tools +- name: create Redfish Emulator state directory + file: + name: "{{ redfish_emulator_state_dir }}" + state: directory + owner: root + group: root + mode: 0600 + become: true + - name: ensure Redfish Emulator systemd service is configured template: src: redfish-emulator.service.j2 @@ -227,6 +236,10 @@ become: true register: redfish_emulator_service_file +- name: reload systemd units if needed + systemd: + daemon_reload: "{{ redfish_emulator_service_file.changed }}" + - name: find OVMF firmware set_fact: efi_loader_path: "{{ item }}" @@ -260,10 +273,28 @@ become: true register: redfish_emulator_config_file +# NOTE(dtantsur): the migration can be removed after Xena + +- name: check for the old state directory + stat: + path: /tmp/sushy-emulator + register: redfish_emulator_old_state_dir + +- block: + - name: stop Redfish Emulator before migrating its state directory + systemd: + name: redfish-emulator + state: stopped + - name: migrate existing Redfish Emulator state directory + shell: mv /tmp/sushy-emulator/*.sqlite "{{ redfish_emulator_state_dir }}" + become: true + ignore_errors: true + when: redfish_emulator_old_state_dir.stat.exists + and redfish_emulator_state_dir != '/tmp/sushy-emulator' + - name: ensure Redfish Emulator systemd service is started and enabled systemd: name: redfish-emulator enabled: yes state: "{{ 'restarted' if redfish_emulator_config_file.changed else 'started' }}" - daemon_reload: "{{ redfish_emulator_service_file.changed }}" become: true diff --git a/playbooks/roles/bifrost-create-vm-nodes/templates/redfish-emulator.conf.j2 b/playbooks/roles/bifrost-create-vm-nodes/templates/redfish-emulator.conf.j2 index 9dd334e84..901ef4ecd 100644 --- a/playbooks/roles/bifrost-create-vm-nodes/templates/redfish-emulator.conf.j2 +++ b/playbooks/roles/bifrost-create-vm-nodes/templates/redfish-emulator.conf.j2 @@ -11,3 +11,4 @@ SUSHY_EMULATOR_BOOT_LOADER_MAP = { SUSHY_EMULATOR_LISTEN_IP = '{{ redfish_emulator_host }}' SUSHY_EMULATOR_LISTEN_PORT = {{ redfish_emulator_port }} +SUSHY_EMULATOR_STATE_DIR = '{{ redfish_emulator_state_dir }}'