OpenStack Nova Puppet Module
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

qemu.pp 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. # == Class: nova::compute::libvirt::qemu
  2. #
  3. # Configures qemu limits for use by libvirt
  4. #
  5. # === Parameters:
  6. #
  7. # [*configure_qemu*]
  8. # (optional) Whether or not configure qemu bits.
  9. # Defaults to false.
  10. #
  11. # [*group*]
  12. # (optional) Group under which the qemu should run.
  13. # Defaults to undef.
  14. #
  15. # [*max_files*]
  16. # (optional) Maximum number of opened files, per process.
  17. # Defaults to 1024.
  18. #
  19. # [*max_processes*]
  20. # (optional) Maximum number of processes that can be run by qemu user.
  21. # Defaults to 4096.
  22. #
  23. # [*vnc_tls*]
  24. # (optional) Enables TLS for vnc connections.
  25. # Defaults to false.
  26. #
  27. # [*vnc_tls_verify*]
  28. # (optional) Enables TLS client cert verification when vnc_tls is enabled.
  29. # Defaults to true.
  30. #
  31. # [*memory_backing_dir*]
  32. # (optional) This directory is used for memoryBacking source if configured as file.
  33. # NOTE: big files will be stored here
  34. # Defaults to undef.
  35. #
  36. # [*nbd_tls*]
  37. # (optional) Enables TLS for nbd connections.
  38. # Defaults to false.
  39. #
  40. # [*libvirt_version*]
  41. # (optional) installed libvirt version. Default is automatic detected depending
  42. # of the used OS installed via ::nova::compute::libvirt::version::default .
  43. # Defaults to ::nova::compute::libvirt::version::default
  44. #
  45. class nova::compute::libvirt::qemu(
  46. $configure_qemu = false,
  47. $group = undef,
  48. $max_files = 1024,
  49. $max_processes = 4096,
  50. $vnc_tls = false,
  51. $vnc_tls_verify = true,
  52. $memory_backing_dir = undef,
  53. $nbd_tls = false,
  54. $libvirt_version = $::nova::compute::libvirt::version::default,
  55. ) inherits nova::compute::libvirt::version {
  56. include ::nova::deps
  57. require ::nova::compute::libvirt
  58. Anchor['nova::config::begin']
  59. -> Augeas<| tag == 'qemu-conf-augeas'|>
  60. -> Anchor['nova::config::end']
  61. Augeas<| tag == 'qemu-conf-augeas'|>
  62. ~> Service['libvirt']
  63. if $configure_qemu {
  64. if $vnc_tls {
  65. $vnc_tls_value = 1
  66. $vnc_tls_verify_value = $vnc_tls_verify ? { true => 1, false => 0 }
  67. } else {
  68. $vnc_tls_value = 0
  69. $vnc_tls_verify_value = 0
  70. }
  71. if $nbd_tls {
  72. $nbd_tls_value = 1
  73. } else {
  74. $nbd_tls_value = 0
  75. }
  76. $augues_changes_default = [
  77. "set max_files ${max_files}",
  78. "set max_processes ${max_processes}",
  79. "set vnc_tls ${vnc_tls_value}",
  80. "set vnc_tls_x509_verify ${vnc_tls_verify_value}",
  81. ]
  82. if $group and !empty($group) {
  83. $augues_group_changes = ["set group ${group}"]
  84. } else {
  85. $augues_group_changes = []
  86. }
  87. if $memory_backing_dir and !empty($memory_backing_dir) {
  88. $augues_memory_backing_dir_changes = ["set memory_backing_dir ${memory_backing_dir}"]
  89. } else {
  90. $augues_memory_backing_dir_changes = []
  91. }
  92. if versioncmp($libvirt_version, '4.5') >= 0 {
  93. $augues_nbd_tls_changes = ["set nbd_tls ${nbd_tls_value}"]
  94. } else {
  95. $augues_nbd_tls_changes = []
  96. }
  97. $augues_changes = concat($augues_changes_default, $augues_group_changes, $augues_memory_backing_dir_changes, $augues_nbd_tls_changes)
  98. augeas { 'qemu-conf-limits':
  99. context => '/files/etc/libvirt/qemu.conf',
  100. changes => $augues_changes,
  101. tag => 'qemu-conf-augeas',
  102. }
  103. } else {
  104. $augues_changes_default = [
  105. 'rm max_files',
  106. 'rm max_processes',
  107. 'rm group',
  108. 'rm vnc_tls',
  109. 'rm vnc_tls_x509_verify',
  110. 'rm memory_backing_dir',
  111. ]
  112. if versioncmp($libvirt_version, '4.5') >= 0 {
  113. $augues_nbd_tls_changes = ['rm nbd_tls']
  114. } else {
  115. $augues_nbd_tls_changes = []
  116. }
  117. $augues_changes = concat($augues_changes_default, $augues_nbd_tls_changes)
  118. augeas { 'qemu-conf-limits':
  119. context => '/files/etc/libvirt/qemu.conf',
  120. changes => $augues_changes,
  121. tag => 'qemu-conf-augeas',
  122. }
  123. }
  124. }