Configure Virtual BMC
* Configure the Virtual BMC daemon in systemd * Start the Virtual BMC daemon per hypervisor * Add each hypervisor's VMs to Virtual BMC
This commit is contained in:
@@ -45,3 +45,11 @@
|
||||
vms: >-
|
||||
{{ hostvars['localhost'].allocations.result[inventory_hostname]
|
||||
| default([]) }}
|
||||
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- include_tasks: virtualbmc.yml
|
||||
vars:
|
||||
vms: >-
|
||||
{{ hostvars['localhost'].allocations.result[inventory_hostname]
|
||||
| default([]) }}
|
||||
|
||||
@@ -35,4 +35,15 @@ veth_vm_ovs_suffix: '-ovs'
|
||||
# seem right.
|
||||
veth_vm_source_suffix: '-tap'
|
||||
|
||||
console_log_directory: /var/log/tenks/console_logs/
|
||||
# Directory in which to store Tenks logs.
|
||||
log_directory: /var/log/tenks/
|
||||
|
||||
# The address on which VBMC will listen for IPMI traffic.
|
||||
vbmc_ipmi_listen_address: 0.0.0.0
|
||||
# The range of ports available for use by VBMC.
|
||||
vbmc_ipmi_port_range_start: 6230
|
||||
vbmc_ipmi_port_range_end: 6240
|
||||
# The IPMI username that VBMC will use.
|
||||
vbmc_ipmi_username: username
|
||||
# The IPMI password that VBMC will use.
|
||||
vbmc_ipmi_password: password
|
||||
|
||||
7
ansible/templates/vbmcd.service.j2
Normal file
7
ansible/templates/vbmcd.service.j2
Normal file
@@ -0,0 +1,7 @@
|
||||
[Unit]
|
||||
Description=Virtual BMC daemon
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Restart=on-failure
|
||||
ExecStart="{{ virtualenv_path }}/bin/vbmcd" --foreground
|
||||
40
ansible/virtualbmc.yml
Normal file
40
ansible/virtualbmc.yml
Normal file
@@ -0,0 +1,40 @@
|
||||
---
|
||||
- name: Set service name
|
||||
set_fact:
|
||||
service: vbmcd
|
||||
|
||||
- name: Check that enough ports are available for Virtual BMC
|
||||
fail: >
|
||||
{{ vms | count }} VMs were specified to be created, but only
|
||||
{{ vbmc_ipmi_port_range_end - vbmc_ipmi_port_range_start }} ports are
|
||||
available for use by Virtual BMC.
|
||||
when: (vms | count) > (vbmc_ipmi_port_range_end - vbmc_ipmi_port_range_start)
|
||||
|
||||
- name: Ensure Virtual BMC systemd service is configured
|
||||
template:
|
||||
src: templates/{{ item }}.j2
|
||||
dest: /etc/systemd/system/{{ item }}
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
become: true
|
||||
register: vbmc_service_file
|
||||
loop:
|
||||
- "{{ service }}.service"
|
||||
|
||||
- name: Ensure Virtual BMC systemd service is started and enabled
|
||||
systemd:
|
||||
name: "{{ service }}"
|
||||
enabled: yes
|
||||
state: started
|
||||
daemon_reload: "{{ vbmc_service_file.changed }}"
|
||||
become: true
|
||||
|
||||
- include_tasks: vm_virtualbmc.yml
|
||||
vars:
|
||||
vm: "{{ vm }}"
|
||||
port: "{{ vbmc_ipmi_port_range_start + port_offset }}"
|
||||
loop: "{{ vms }}"
|
||||
loop_control:
|
||||
loop_var: vm
|
||||
index_var: port_offset
|
||||
38
ansible/vm_virtualbmc.yml
Normal file
38
ansible/vm_virtualbmc.yml
Normal file
@@ -0,0 +1,38 @@
|
||||
---
|
||||
- name: Set common strings
|
||||
set_fact:
|
||||
# vbmcd should already be running, so --no-daemon stops vbmc from spawning
|
||||
# another instance of the daemon.
|
||||
cmd: "'{{ virtualenv_path }}/bin/vbmc' --no-daemon"
|
||||
log_arg: "--log-file '{{ log_directory }}/vbmc-{{ vm.name }}.log'"
|
||||
|
||||
# Even if the VM is present in VBMC, we can't guarantee that it's configured
|
||||
# correctly. It's easiest to delete and re-add it; this should involve minimal
|
||||
# downtime.
|
||||
- name: Ensure VM is stopped and deleted in VBMC
|
||||
command: >-
|
||||
{{ cmd }} {{ item }} '{{ vm.name }}' {{ log_arg }}
|
||||
loop:
|
||||
- stop
|
||||
- delete
|
||||
register: res
|
||||
changed_when: res.rc != 0
|
||||
failed_when:
|
||||
- res.rc != 0
|
||||
- "'No domain with matching name' not in res.stderr"
|
||||
become: true
|
||||
|
||||
- name: Ensure VM is added to VBMC
|
||||
command: >-
|
||||
{{ cmd }} add '{{ vm.name }}'
|
||||
--port {{ port }}
|
||||
--username '{{ vbmc_ipmi_username }}'
|
||||
--password '{{ vbmc_ipmi_password }}'
|
||||
--address {{ vbmc_ipmi_listen_address }}
|
||||
{{ log_arg }}
|
||||
become: true
|
||||
|
||||
- name: Ensure VM is started in VBMC
|
||||
command: >
|
||||
{{ cmd }} start '{{ vm.name }}' {{ log_arg }}
|
||||
become: true
|
||||
Reference in New Issue
Block a user