Fix "More than one line in file '/etc/sysconfig/libvirtd' matches pattern" errors

The current code that matches the LIBVIRTD_ARGS= lines can have multiple
matches if said line shows up multiple times in a comment and we can end
up with the following error:

  Error: /Stage[main]/Nova::Migration::Libvirt/File_line[/etc/sysconfig/libvirtd libvirtd args]/
    ensure: change from 'absent' to 'present' failed: More than one line in file '/etc/sysconfig/libvirtd' matches pattern
      'LIBVIRTD_ARGS='

For the record the sysconfig file that triggered this error had the
following lines:

  # connects.
  LIBVIRTD_ARGS="--timeout 120"

  # If systemd socket activation is disabled, then the following
  # can be used to listen on TCP/TLS sockets
  #LIBVIRTD_ARGS="--listen"

Tested this change and I correctly did not fail the deployment anymore.

Change-Id: Iae595796559cc6551d8ae27e2573122a8a2da15d
Closes-Bug: #1847288
This commit is contained in:
Michele Baldessari 2019-10-08 17:28:28 +02:00
parent 954f5a1cea
commit 8377b33bd1
1 changed files with 1 additions and 1 deletions

View File

@ -237,7 +237,7 @@ class nova::migration::libvirt(
file_line { '/etc/sysconfig/libvirtd libvirtd args':
path => '/etc/sysconfig/libvirtd',
line => 'LIBVIRTD_ARGS="--listen"',
match => 'LIBVIRTD_ARGS=',
match => '^LIBVIRTD_ARGS=',
tag => 'libvirt-file_line',
}
}