132 lines
4.0 KiB
YAML
132 lines
4.0 KiB
YAML
---
|
|
- name: Create VirtualBMC directories
|
|
when: release not in ['newton']
|
|
file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
mode: 0750
|
|
owner: root
|
|
group: root
|
|
with_items:
|
|
- "/etc/virtualbmc"
|
|
- "/var/log/virtualbmc"
|
|
become: true
|
|
|
|
- name: Create VirtualBMC configuration file
|
|
when: release not in ['newton']
|
|
copy:
|
|
mode: 0750
|
|
dest: "/etc/virtualbmc/virtualbmc.conf"
|
|
content: |
|
|
[default]
|
|
config_dir=/root/.vbmc
|
|
[log]
|
|
logfile=/var/log/virtualbmc/virtualbmc.log
|
|
debug=True
|
|
[ipmi]
|
|
session_timout=20
|
|
become: true
|
|
|
|
# when running with 127.0.0.2 as
|
|
# the virthost ensure
|
|
- name: get the non_root_user_uuid
|
|
block:
|
|
- name: get virthost non_root_user userid
|
|
command: id -u {{ non_root_user }}
|
|
register: non_root_user_uid
|
|
delegate_to: virthost
|
|
changed_when: false
|
|
- name: set fact on non_root_user_uid
|
|
set_fact:
|
|
non_root_user_uid: "{{ non_root_user_uid.stdout }}"
|
|
rescue:
|
|
# set in roles/provision/local
|
|
- name: set fact on non_root_user_uid
|
|
set_fact:
|
|
non_root_user_uid: "{{ hostvars['localhost']['non_root_user_uid'] }}"
|
|
|
|
# The first network defined with an address will be used for vbmc access.
|
|
- name: set vbmc address if there is a (nat) network defined with an address
|
|
set_fact:
|
|
vbmc_address: "{{ networks|selectattr('address', 'defined')|map(attribute='address')|list|first }}"
|
|
when: networks|selectattr('address', 'defined')|map(attribute='name')|list|length > 0
|
|
|
|
# If there is no nat network with an address, the undercloud will be
|
|
# connected to the default libvirt network to fill this role.
|
|
- name: set vbmc address fact for default libvirt network
|
|
set_fact:
|
|
vbmc_address: "{{ libvirt_default_network_address }}"
|
|
when: vbmc_address is not defined
|
|
|
|
# The connection uri is slightly different when using qemu:///system
|
|
# and requires the root user.
|
|
- name: set qemu uri for qemu:///system usage
|
|
set_fact:
|
|
vbmc_libvirt_uri: "qemu+ssh://root@{{ vbmc_address }}/system?&keyfile=/root/.ssh/id_rsa_virt_power&no_verify=1&no_tty=1"
|
|
when: libvirt_uri == "qemu:///system"
|
|
|
|
- name: set qemu uri for qemu:///session usage
|
|
set_fact:
|
|
vbmc_libvirt_uri: "qemu+ssh://{{ non_root_user }}@{{ vbmc_address }}/session?socket=/run/user/{{ non_root_user_uid }}/libvirt/libvirt-sock&keyfile=/root/.ssh/id_rsa_virt_power&no_verify=1&no_tty=1"
|
|
when: vbmc_libvirt_uri is not defined
|
|
|
|
- name: Install VirtualBMC package
|
|
when: release not in ['newton']
|
|
package:
|
|
name: "python2-virtualbmc"
|
|
state: present
|
|
use: yum
|
|
become: true
|
|
|
|
- name: Start the Virtual BMCs (virtualbmc >= 1.4.0+)
|
|
when: release not in ['newton', 'ocata', 'pike', 'queens']
|
|
service:
|
|
name: "virtualbmc"
|
|
state: started
|
|
enabled: true
|
|
become: true
|
|
|
|
- name: Create the Virtual BMCs
|
|
when: release not in ['newton']
|
|
command: "vbmc add {{ item.name }} --port {{ item.virtualbmc_port }} --libvirt-uri {{ vbmc_libvirt_uri }}"
|
|
args:
|
|
creates: /root/.vbmc/{{ item.name }}/config
|
|
with_items: "{{ overcloud_nodes }}"
|
|
become: true
|
|
|
|
- name: Start the Virtual BMCs (virtualbmc >= 1.4.0+)
|
|
when: release not in ['newton', 'ocata', 'pike', 'queens']
|
|
command: "vbmc start {{ item.name }}"
|
|
with_items: "{{ overcloud_nodes }}"
|
|
become: true
|
|
|
|
- name: Create the VirtualBMC systemd service (virtualbmc < 1.4.0)
|
|
when: release in ['ocata', 'pike', 'queens']
|
|
copy:
|
|
mode: 0664
|
|
dest: "/usr/lib/systemd/system/virtualbmc@.service"
|
|
content: |
|
|
[Unit]
|
|
Description=VirtualBMC %i service
|
|
After=network.target
|
|
|
|
[Service]
|
|
Type=forking
|
|
PIDFile=/root/.vbmc/%i/pid
|
|
ExecStart=/bin/vbmc start %i
|
|
ExecStop=/bin/vbmc stop %i
|
|
Restart=always
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
become: true
|
|
|
|
- name: Start the Virtual BMCs (virtualbmc < 1.4.0)
|
|
when: release in ['ocata', 'pike', 'queens']
|
|
service:
|
|
name: "virtualbmc@{{ item.name }}"
|
|
state: started
|
|
enabled: true
|
|
with_items: "{{ overcloud_nodes }}"
|
|
become: true
|