af0eec6bd5
The old conditional caused an error when used with new Ansible, "no test named 'greaterthan'". Change-Id: I5c61da71794bba0b24f5aa69cdd38cfbcab0ef4d Closes-Bug: #1732423
116 lines
3.5 KiB
YAML
116 lines
3.5 KiB
YAML
---
|
|
|
|
- name: Install VirtualBMC package
|
|
when: release not in ['liberty', 'mitaka', 'newton']
|
|
package:
|
|
name: "python2-virtualbmc"
|
|
state: present
|
|
use: yum
|
|
become: true
|
|
|
|
- name: Create VirtualBMC directories
|
|
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 ['liberty', 'mitaka', '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
|
|
|
|
# the non_root_user id is not in the facts of the virthost when
|
|
# executed in devmode. To be safe let's delegate to the virthost
|
|
# and obtain the uuid of the non_root_user
|
|
- name: get virthost non_root_user userid
|
|
shell: id -u {{ non_root_user }}
|
|
register: non_root_user_uid
|
|
delegate_to: virthost
|
|
|
|
- name: set fact on non_root_user_uid
|
|
set_fact:
|
|
non_root_user_uid: "{{ non_root_user_uid.stdout }}"
|
|
|
|
# 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: Create the Virtual BMCs
|
|
when: release not in ['liberty', 'mitaka', '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
|
|
become_user: root
|
|
|
|
# TODO(lucasagomes): The service file should be included in the
|
|
# virtualbmc RPM package.
|
|
- name: Create the VirtualBMC systemd service
|
|
when: release not in ['liberty', 'mitaka', 'newton']
|
|
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
|
|
when: release not in ['liberty', 'mitaka', 'newton']
|
|
service:
|
|
name: "virtualbmc@{{ item.name }}"
|
|
state: started
|
|
enabled: true
|
|
with_items: "{{ overcloud_nodes }}"
|
|
become: true
|
|
|