Puppet Class: octavia::worker

Defined in:
manifests/worker.pp

Overview

Installs & configure the octavia controller worker service

Parameters

enabled

(optional) Should the service be enabled. Defaults to true

manage_service

(optional) Whether the service should be managed by Puppet. Defaults to true.

package_ensure

(optional) ensure state for package. Defaults to ‘present’

workers

(optional) Number of worker processes.

Defaults to $facts['os_workers']
manage_nova_flavor

(optional) Whether or not manage Nova flavor for the Amphora. Defaults to true.

nova_flavor_config

(optional) Nova flavor config hash. Should be an hash. Example: $nova_flavor_config = { ‘ram’ => ‘2048’ } Possible options are documented in puppet-nova nova_flavor type. Defaults to {}.

key_path

(optional) full path to the private key for the amphora SSH key Defaults to ‘/etc/octavia/.ssh/octavia_ssh_key’

manage_keygen

(optional) Whether or not create OpenStack keypair for communicating with amphora. Defaults to false

ssh_key_type

(optional) Type of ssh key to create. Defaults to ‘rsa’

ssh_key_bits

(optional) Number of bits in ssh key. Defaults to 2048

amp_project_name

(optional) Set the project to be used for creating load balancer instances. Defaults to ‘services’

Parameters:

  • manage_service (Boolean) (defaults to: true)
  • enabled (Boolean) (defaults to: true)
  • package_ensure (Any) (defaults to: 'present')
  • workers (Any) (defaults to: $facts['os_workers'])
  • manage_nova_flavor (Boolean) (defaults to: true)
  • nova_flavor_config (Hash) (defaults to: {})
  • key_path (Stdlib::Absolutepath) (defaults to: '/etc/octavia/.ssh/octavia_ssh_key')
  • manage_keygen (Boolean) (defaults to: false)
  • ssh_key_type (Enum['rsa', 'dsa', 'ecdsa', 'ed25519', 'rsa1']) (defaults to: 'rsa')
  • ssh_key_bits (Integer) (defaults to: 2048)
  • amp_project_name (String[1]) (defaults to: 'services')


54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'manifests/worker.pp', line 54

class octavia::worker (
  Boolean $manage_service                                      = true,
  Boolean $enabled                                             = true,
  $package_ensure                                              = 'present',
  $workers                                                     = $facts['os_workers'],
  Boolean $manage_nova_flavor                                  = true,
  Hash $nova_flavor_config                                     = {},
  Stdlib::Absolutepath $key_path                               = '/etc/octavia/.ssh/octavia_ssh_key',
  Boolean $manage_keygen                                       = false,
  Enum['rsa', 'dsa', 'ecdsa', 'ed25519', 'rsa1'] $ssh_key_type = 'rsa',
  Integer $ssh_key_bits                                        = 2048,
  String[1] $amp_project_name                                  = 'services',
) {

  include octavia::deps
  include octavia::params
  include octavia::controller

  if $manage_nova_flavor {
    $octavia_flavor = { "octavia_${::octavia::controller::amp_flavor_id}" =>
      { 'id'           => $::octavia::controller::amp_flavor_id,
        'project_name' => $amp_project_name
      }
    }

    $octavia_flavor_defaults = {
      'ensure'    => 'present',
      'ram'       => '1024',
      'disk'      => '2',
      'vcpus'     => '1',
      'is_public' => false,
      'tag'       => ['octavia']
    }
    $nova_flavor_defaults = merge($octavia_flavor_defaults, $nova_flavor_config)
    create_resources('nova_flavor', $octavia_flavor, $nova_flavor_defaults)
    if $manage_service {
      Nova_flavor<| tag == 'octavia' |> ~> Service['octavia-worker']
    }
  }

  package { 'octavia-worker':
    ensure => $package_ensure,
    name   => $::octavia::params::worker_package_name,
    tag    => ['openstack', 'octavia-package'],
  }

  if $manage_service {
    if $enabled {
      $service_ensure = 'running'
    } else {
      $service_ensure = 'stopped'
    }

    service { 'octavia-worker':
      ensure     => $service_ensure,
      name       => $::octavia::params::worker_service_name,
      enable     => $enabled,
      hasstatus  => true,
      hasrestart => true,
      tag        => ['octavia-service'],
    }
  }

  if $manage_keygen and ! $::octavia::controller::enable_ssh_access {
    fail('SSH key management cannot be enabled when SSH key access is disabled')
  }

  if $manage_keygen {
    exec {'create_amp_key_dir':
      path    => ['/bin', '/usr/bin'],
      command => "mkdir -p ${key_path}",
      creates => $key_path
    }

    file { 'amp_key_dir':
      ensure => directory,
      path   => $key_path,
      mode   => '0700',
      group  => $::octavia::params::group,
      owner  => $::octavia::params::user
    }

    ssh_keygen { $::octavia::controller::amp_ssh_key_name:
      user     => $::octavia::params::user,
      type     => $ssh_key_type,
      bits     => $ssh_key_bits,
      filename => "${key_path}/${::octavia::controller::amp_ssh_key_name}",
      comment  => 'Used for Octavia Service VM'
    }

    Anchor['octavia::config::begin']
    -> Exec['create_amp_key_dir']
    -> File['amp_key_dir']
    -> Ssh_keygen[$::octavia::controller::amp_ssh_key_name]
    -> Anchor['octavia::config::end']
  }

  octavia_config {
    'controller_worker/workers' : value => $workers;
  }
}