diff --git a/attributes/default.rb b/attributes/default.rb index 5e61d4d..7f5537d 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -40,6 +40,11 @@ default['openstack']['bare-metal']['conductor']['workers_pool_size'] = 100 default['openstack']['bare-metal']['rpc_thread_pool_size'] = 64 default['openstack']['bare-metal']['rpc_conn_pool_size'] = 30 default['openstack']['bare-metal']['rpc_response_timeout'] = 60 + +# The name of the Chef role that knows about the message queue server +# that Ironic uses +default['openstack']['bare-metal']['rabbit_server_chef_role'] = 'os-ops-messaging' + case node['openstack']['mq']['service_type'] when 'rabbitmq' default['openstack']['bare-metal']['rpc_backend'] = 'rabbit' diff --git a/spec/ironic-common_spec.rb b/spec/ironic-common_spec.rb index 38f1de3..611407e 100644 --- a/spec/ironic-common_spec.rb +++ b/spec/ironic-common_spec.rb @@ -135,20 +135,116 @@ describe 'openstack-bare-metal::ironic-common' do end end + context 'qpid as mq service' do + before do + node.set['openstack']['mq']['bare-metal']['service_type'] = 'qpid' + end + + it 'has default RPC/AMQP options set' do + [/^rpc_conn_pool_size=30$/, + /^amqp_durable_queues=false$/, + /^amqp_auto_delete=false$/].each do |line| + expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', line) + end + end + + %w(port username sasl_mechanisms reconnect reconnect_timeout reconnect_limit + reconnect_interval_min reconnect_interval_max reconnect_interval heartbeat protocol + tcp_nodelay).each do |attr| + it "has qpid_#{attr} attribute" do + node.set['openstack']['mq']['bare-metal']['qpid'][attr] = "qpid_#{attr}_value" + expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', /^qpid_#{attr}=qpid_#{attr}_value$/) + end + end + + it 'has qpid_hostname' do + node.set['openstack']['mq']['bare-metal']['qpid']['host'] = 'qpid_host_value' + expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', /^qpid_hostname=qpid_host_value$/) + end + + it 'has qpid_password' do + expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', /^qpid_password=user_pass$/) + end + + it 'has default qpid topology version' do + expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', /^qpid_topology_version=1$/) + end + end + context 'rabbit mq backend' do before do node.set['openstack']['mq']['bare-metal']['service_type'] = 'rabbitmq' end + it 'has default RPC/AMQP options set' do + [/^rpc_conn_pool_size=30$/, + /^amqp_durable_queues=false$/, + /^amqp_auto_delete=false$/].each do |line| + expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', line) + end + end + it 'does not have kombu ssl version set' do - expect(chef_run).not_to render_config_file(file.name).with_section_content('DEFAULT', /^kombu_ssl_version=TLSv1.2$/) + expect(chef_run).not_to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^kombu_ssl_version=TLSv1.2$/) end it 'sets kombu ssl version' do node.set['openstack']['mq']['bare-metal']['rabbit']['use_ssl'] = true node.set['openstack']['mq']['bare-metal']['rabbit']['kombu_ssl_version'] = 'TLSv1.2' - expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^kombu_ssl_version=TLSv1.2$/) + expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^kombu_ssl_version=TLSv1.2$/) + end + + context 'ha attributes' do + before do + node.set['openstack']['mq']['bare-metal']['rabbit']['ha'] = true + end + + it 'has a rabbit_hosts attribute' do + allow_any_instance_of(Chef::Recipe).to receive(:rabbit_servers) + .and_return('rabbit_servers_value') + + expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_hosts=rabbit_servers_value$/) + end + + %w(host port).each do |attr| + it "does not have rabbit_#{attr} attribute" do + expect(chef_run).not_to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_#{attr}=/) + end + end + end + + context 'non ha attributes' do + before do + node.set['openstack']['mq']['bare-metal']['rabbit']['ha'] = false + end + + %w(host port).each do |attr| + it "has rabbit_#{attr} attribute" do + node.set['openstack']['mq']['bare-metal']['rabbit'][attr] = "rabbit_#{attr}_value" + expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_#{attr}=rabbit_#{attr}_value$/) + end + end + + it 'does not have a rabbit_hosts attribute' do + expect(chef_run).not_to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_hosts=/) + end + end + + %w(use_ssl userid).each do |attr| + it "has rabbit_#{attr}" do + node.set['openstack']['mq']['bare-metal']['rabbit'][attr] = "rabbit_#{attr}_value" + expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_#{attr}=rabbit_#{attr}_value$/) + end + end + + it 'has rabbit_password' do + expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_password=user_pass$/) + end + + it 'has rabbit_virtual_host' do + node.set['openstack']['mq']['bare-metal']['rabbit']['vhost'] = 'vhost_value' + expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_virtual_host=vhost_value$/) end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 190325c..0dc4a26 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -35,5 +35,7 @@ shared_context 'bare-metal-stubs' do allow_any_instance_of(Chef::Recipe).to receive(:get_secret) .with('openstack_identity_bootstrap_token') .and_return('bootstrap-token') + allow_any_instance_of(Chef::Recipe).to receive(:rabbit_servers) + .and_return('1.1.1.1:5672,2.2.2.2:5672') end end diff --git a/templates/default/ironic.conf.erb b/templates/default/ironic.conf.erb index 6b45815..5bf14d3 100644 --- a/templates/default/ironic.conf.erb +++ b/templates/default/ironic.conf.erb @@ -2,114 +2,6 @@ [DEFAULT] -# -# Options defined in oslo.messaging -# - -# Use durable queues in AMQP. (boolean value) -# Deprecated group/name - [DEFAULT]/rabbit_durable_queues -amqp_durable_queues=<%= node['openstack']['mq']['bare-metal']['durable_queues'] %> - -# Auto-delete queues in AMQP. (boolean value) -amqp_auto_delete=<%= node['openstack']['mq']['bare-metal']['auto_delete'] %> - -# Size of RPC connection pool. (integer value) -rpc_conn_pool_size=<%= node['openstack']['bare-metal']['rpc_conn_pool_size'] %> - -<% if @mq_service_type == 'rabbitmq' %> -<% if node['openstack']['mq']['bare-metal']['rabbit']['use_ssl'] && node['openstack']['mq']['bare-metal']['rabbit']['kombu_ssl_version'] %> -kombu_ssl_version=<%= node['openstack']['mq']['bare-metal']['rabbit']['kombu_ssl_version'] %> -<% end -%> - -##### RABBITMQ ##### -# The RabbitMQ userid. (string value) -rabbit_userid=<%= node['openstack']['mq']['bare-metal']['rabbit']['userid'] %> - -# The RabbitMQ password. (string value) -rabbit_password=<%= @mq_password %> - -# The RabbitMQ virtual host. (string value) -rabbit_virtual_host=<%= node['openstack']['mq']['bare-metal']['rabbit']['vhost'] %> -<% if node['openstack']['mq']['bare-metal']['rabbit']['ha'] -%> -# RabbitMQ HA cluster host:port pairs. (list value) -rabbit_hosts=<%= @rabbit_hosts %> - -# Use HA queues in RabbitMQ (x-ha-policy: all). If you change -# this option, you must wipe the RabbitMQ database. (boolean -# value) -rabbit_ha_queues=True - -rabbit_use_ssl=<%= node['openstack']['mq']['bare-metal']['rabbit']['use_ssl'] %> -<% else -%> -# The RabbitMQ broker address where a single node is used. -# (string value) -rabbit_host=<%= node['openstack']['mq']['bare-metal']['rabbit']['host'] %> - -# The RabbitMQ broker port where a single node is used. -# (integer value) -rabbit_port=<%= node['openstack']['mq']['bare-metal']['rabbit']['port'] %> - -# Connect over SSL for RabbitMQ. (boolean value) -rabbit_use_ssl=<%= node['openstack']['mq']['bare-metal']['rabbit']['use_ssl'] %> -<% end -%> -<% end -%> - -<% if @mq_service_type == 'qpid' %> -##### QPID ##### -# Qpid broker hostname. (string value) -qpid_hostname=<%= node['openstack']['mq']['bare-metal']['qpid']['host'] %> - -# Qpid broker port. (integer value) -qpid_port=<%= node['openstack']['mq']['bare-metal']['qpid']['port'] %> - -# Password for Qpid connection. (string value) -qpid_password=<%= @mq_password %> - -# Username for Qpid connection. (string value) -qpid_username=<%= node['openstack']['mq']['bare-metal']['qpid']['username'] %> - -# Space separated list of SASL mechanisms to use for auth. -# (string value) -qpid_sasl_mechanisms=<%= node['openstack']['mq']['bare-metal']['qpid']['sasl_mechanisms'] %> -qpid_reconnect_timeout=<%= node['openstack']['mq']['bare-metal']['qpid']['reconnect_timeout'] %> -qpid_reconnect_limit=<%= node['openstack']['mq']['bare-metal']['qpid']['reconnect_limit'] %> -qpid_reconnect_interval_min=<%= node['openstack']['mq']['bare-metal']['qpid']['reconnect_interval_min'] %> -qpid_reconnect_interval_max=<%= node['openstack']['mq']['bare-metal']['qpid']['reconnect_interval_max'] %> -qpid_reconnect_interval=<%= node['openstack']['mq']['bare-metal']['qpid']['reconnect_interval'] %> - -# Seconds between connection keepalive heartbeats. (integer -# value) -qpid_heartbeat=<%= node['openstack']['mq']['bare-metal']['qpid']['heartbeat'] %> - -# qpid protocol. default 'tcp'. set to 'ssl' to enable SSL -qpid_protocol=<%= node['openstack']['mq']['bare-metal']['qpid']['protocol'] %> - -# Whether to disable the Nagle algorithm. (boolean value) -qpid_tcp_nodelay=<%= node['openstack']['mq']['bare-metal']['qpid']['tcp_nodelay'] %> - -# The qpid topology version to use. Version 1 is what was -# originally used by impl_qpid. Version 2 includes some -# backwards-incompatible changes that allow broker federation -# to work. Users should update to version 2 when they are -# able to take everything down, as it requires a clean break. -# (integer value) -qpid_topology_version=<%= node['openstack']['mq']['bare-metal']['qpid']['topology_version'] %> -<% end %> - - -# Qpid HA cluster host:port pairs. (list value) -#qpid_hosts=$qpid_hostname:$qpid_port - - -# The number of prefetched messages held by receiver. (integer -# value) -#qpid_receiver_capacity=1 - -# SSL version to use (valid only if SSL enabled). valid values -# are TLSv1 and SSLv23. SSLv2 and SSLv3 may be available on -# some distributions. (string value) -#kombu_ssl_version= - # SSL key file (valid only if SSL enabled). (string value) #kombu_ssl_keyfile= @@ -124,24 +16,6 @@ qpid_topology_version=<%= node['openstack']['mq']['bare-metal']['qpid']['topolog # consumer cancel notification. (floating point value) #kombu_reconnect_delay=1.0 - - -# The RabbitMQ login method. (string value) -#rabbit_login_method=AMQPLAIN - - -# How frequently to retry connecting with RabbitMQ. (integer -# value) -#rabbit_retry_interval=1 - -# How long to backoff for between retries when connecting to -# RabbitMQ. (integer value) -#rabbit_retry_backoff=2 - -# Maximum number of RabbitMQ connection retries. Default is 0 -# (infinite retry count). (integer value) -#rabbit_max_retries=0 - # Deprecated, use rpc_backend=kombu+memory or rpc_backend=fake # (boolean value) #fake_rabbit=false @@ -1184,6 +1058,147 @@ url=<%= @network_endpoint %> #allow_insecure_clients=false +<% if @mq_service_type == "qpid" %> +[oslo_messaging_qpid] + +# +# From oslo.messaging +# + +# Use durable queues in AMQP. (boolean value) +# Deprecated group/name - [DEFAULT]/rabbit_durable_queues +amqp_durable_queues=<%= node['openstack']['mq']['bare-metal']['durable_queues'] %> + +# Auto-delete queues in AMQP. (boolean value) +amqp_auto_delete=<%= node['openstack']['mq']['bare-metal']['auto_delete'] %> + +# Size of RPC connection pool. (integer value) +rpc_conn_pool_size=<%= node['openstack']['bare-metal']['rpc_conn_pool_size'] %> + +##### QPID ##### +# Qpid broker hostname. (string value) +qpid_hostname=<%= node['openstack']['mq']['bare-metal']['qpid']['host'] %> + +# Qpid broker port. (integer value) +qpid_port=<%= node['openstack']['mq']['bare-metal']['qpid']['port'] %> + +# Password for Qpid connection. (string value) +qpid_password=<%= @mq_password %> + +# Username for Qpid connection. (string value) +qpid_username=<%= node['openstack']['mq']['bare-metal']['qpid']['username'] %> + +# Space separated list of SASL mechanisms to use for auth. +# (string value) +qpid_sasl_mechanisms=<%= node['openstack']['mq']['bare-metal']['qpid']['sasl_mechanisms'] %> +qpid_reconnect=<%= node['openstack']['mq']['bare-metal']['qpid']['reconnect'] %> +qpid_reconnect_timeout=<%= node['openstack']['mq']['bare-metal']['qpid']['reconnect_timeout'] %> +qpid_reconnect_limit=<%= node['openstack']['mq']['bare-metal']['qpid']['reconnect_limit'] %> +qpid_reconnect_interval_min=<%= node['openstack']['mq']['bare-metal']['qpid']['reconnect_interval_min'] %> +qpid_reconnect_interval_max=<%= node['openstack']['mq']['bare-metal']['qpid']['reconnect_interval_max'] %> +qpid_reconnect_interval=<%= node['openstack']['mq']['bare-metal']['qpid']['reconnect_interval'] %> + +# Seconds between connection keepalive heartbeats. (integer +# value) +qpid_heartbeat=<%= node['openstack']['mq']['bare-metal']['qpid']['heartbeat'] %> + +# qpid protocol. default 'tcp'. set to 'ssl' to enable SSL +qpid_protocol=<%= node['openstack']['mq']['bare-metal']['qpid']['protocol'] %> + +# Whether to disable the Nagle algorithm. (boolean value) +qpid_tcp_nodelay=<%= node['openstack']['mq']['bare-metal']['qpid']['tcp_nodelay'] %> + +# The qpid topology version to use. Version 1 is what was +# originally used by impl_qpid. Version 2 includes some +# backwards-incompatible changes that allow broker federation +# to work. Users should update to version 2 when they are +# able to take everything down, as it requires a clean break. +# (integer value) +qpid_topology_version=<%= node['openstack']['mq']['bare-metal']['qpid']['topology_version'] %> + +# Qpid HA cluster host:port pairs. (list value) +#qpid_hosts=$qpid_hostname:$qpid_port + +# The number of prefetched messages held by receiver. (integer +# value) +#qpid_receiver_capacity=1 +<% end %> + + +<% if @mq_service_type == "rabbitmq" %> +[oslo_messaging_rabbit] + +# +# From oslo.messaging +# + +# Use durable queues in AMQP. (boolean value) +# Deprecated group/name - [DEFAULT]/rabbit_durable_queues +amqp_durable_queues=<%= node['openstack']['mq']['bare-metal']['durable_queues'] %> + +# Auto-delete queues in AMQP. (boolean value) +amqp_auto_delete=<%= node['openstack']['mq']['bare-metal']['auto_delete'] %> + +# Size of RPC connection pool. (integer value) +rpc_conn_pool_size=<%= node['openstack']['bare-metal']['rpc_conn_pool_size'] %> + +<% if node['openstack']['mq']['bare-metal']['rabbit']['use_ssl'] && node['openstack']['mq']['bare-metal']['rabbit']['kombu_ssl_version'] %> +# SSL version to use (valid only if SSL enabled). valid values +# are TLSv1 and SSLv23. SSLv2 and SSLv3 may be available on +# some distributions. (string value) +kombu_ssl_version=<%= node['openstack']['mq']['bare-metal']['rabbit']['kombu_ssl_version'] %> +<% end -%> + +##### RABBITMQ ##### +# The RabbitMQ userid. (string value) +rabbit_userid=<%= node['openstack']['mq']['bare-metal']['rabbit']['userid'] %> + +# The RabbitMQ password. (string value) +rabbit_password=<%= @mq_password %> + +# The RabbitMQ virtual host. (string value) +rabbit_virtual_host=<%= node['openstack']['mq']['bare-metal']['rabbit']['vhost'] %> +<% if node['openstack']['mq']['bare-metal']['rabbit']['ha'] -%> +# RabbitMQ HA cluster host:port pairs. (list value) +rabbit_hosts=<%= @rabbit_hosts %> + +# Use HA queues in RabbitMQ (x-ha-policy: all). If you change +# this option, you must wipe the RabbitMQ database. (boolean +# value) +rabbit_ha_queues=True + +rabbit_use_ssl=<%= node['openstack']['mq']['bare-metal']['rabbit']['use_ssl'] %> +<% else -%> +# The RabbitMQ broker address where a single node is used. +# (string value) +rabbit_host=<%= node['openstack']['mq']['bare-metal']['rabbit']['host'] %> + +# The RabbitMQ broker port where a single node is used. +# (integer value) +rabbit_port=<%= node['openstack']['mq']['bare-metal']['rabbit']['port'] %> + +# Connect over SSL for RabbitMQ. (boolean value) +rabbit_use_ssl=<%= node['openstack']['mq']['bare-metal']['rabbit']['use_ssl'] %> +<% end -%> + +# The RabbitMQ login method. (string value) +#rabbit_login_method=AMQPLAIN + + +# How frequently to retry connecting with RabbitMQ. (integer +# value) +#rabbit_retry_interval=1 + +# How long to backoff for between retries when connecting to +# RabbitMQ. (integer value) +#rabbit_retry_backoff=2 + +# Maximum number of RabbitMQ connection retries. Default is 0 +# (infinite retry count). (integer value) +#rabbit_max_retries=0 +<% end -%> + + [pxe] #