Moved devstack VM from ainsible to chef

Change-Id: If6fabf94a65081d7d8c7eeb0f3b886bb46a1c7c2
This commit is contained in:
David Schroeder 2014-11-07 16:25:51 -07:00
parent d7ca6e085f
commit bfcc524431
23 changed files with 129 additions and 207 deletions

3
.gitignore vendored
View File

@ -5,4 +5,5 @@
.settings .settings
*.deb *.deb
*.pyc *.pyc
roles roles/tkuhlman.*
roles/stympy.influxdb

7
Vagrantfile vendored
View File

@ -34,13 +34,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
vb.memory = 7168 vb.memory = 7168
vb.cpus = 4 vb.cpus = 4
end end
ds.vm.provision :chef_solo do |chef|
chef.roles_path = "roles"
chef.cookbooks_path = "cookbooks"
chef.data_bags_path = "data_bags"
chef.add_role "Devstack"
chef.arguments = '--force-formatter'
end
ds.vm.provision "ansible" do |ansible| ds.vm.provision "ansible" do |ansible|
ansible.playbook = "devstack.yml" ansible.playbook = "devstack.yml"
end end

View File

@ -1,12 +1,17 @@
monasca-devstack
tkuhlman.kafka tkuhlman.kafka
tkuhlman.monasca-agent tkuhlman.monasca-agent
tkuhlman.monasca-api tkuhlman.monasca-api
tkuhlman.monasca-keystone
tkuhlman.monasca-notification tkuhlman.monasca-notification
tkuhlman.monasca-persister tkuhlman.monasca-persister
tkuhlman.monasca-schema tkuhlman.monasca-schema
tkuhlman.monasca-thresh tkuhlman.monasca-thresh
tkuhlman.monasca-ui
tkuhlman.percona tkuhlman.percona
tkuhlman.storm tkuhlman.storm
tkuhlman.zookeeper tkuhlman.zookeeper
stympy.influxdb stympy.influxdb

View File

@ -1,11 +0,0 @@
devstack cookbook
=========================
Various helper recipes for the devstack server setup.
Requirements
------------
Recipes
---------
- mon-ui - installs the Monitoring panel in the UI
- keystone - simple keystone installation

View File

@ -1,7 +0,0 @@
name "devstack"
maintainer "Mon Team"
maintainer_email "hpcs-mon@hp.com"
license "All rights reserved"
description "Customizes devstack server for use with mini-mon"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.0.6"

View File

@ -1,40 +0,0 @@
plugin_config = data_bag_item('devstack', 'agent_plugin_config')
service "rabbitmq-server" do
action :nothing
supports :status => true, :start => true, :stop => true, :restart => true
end
execute "enable-rabbitmq-web-mgmt" do
command "/usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_management"
not_if "/usr/lib/rabbitmq/bin/rabbitmq-plugins list -e | grep rabbitmq_management"
not_if { ::File.file?('/root/.rabbitmq.cnf') }
notifies :restart, "service[rabbitmq-server]", :delayed
end
template "/root/.rabbitmq.cnf" do
action :create
source "rabbitmq.cnf.erb"
owner 'root'
group 'root'
mode 0600
not_if { ::File.file?('/root/.rabbitmq.cnf') }
variables(
:plugin_config => plugin_config
)
end
package 'python-mysqldb' do
action :install
end
template "/root/.my.cnf" do
action :create
source "my.cnf.erb"
owner 'root'
group 'root'
mode 0600
not_if { ::File.directory?('/root/.my.cnf') }
variables(
:plugin_config => plugin_config
)
end

View File

@ -1 +0,0 @@
# Add any necessary customizations here

View File

@ -1,77 +0,0 @@
# Sets up a user mini-mon username/password in keystone
python 'make default keystone users' do
action :run
code <<-EOH
import keystoneclient
from keystoneclient.v2_0 import client
def add_service_endpoint(key, service_name, endpoint_host):
"""Add the Monasca service to the catalog with the specified endpoint, if it doesn't yet exist."""
service_names = { service.name: service.id for service in key.services.list() }
if service_name in service_names.keys():
service_id = service_names[service_name]
else:
service=key.services.create(name=service_name, service_type='monitoring', description='Monasca monitoring service')
service_id = service.id
for endpoint in key.endpoints.list():
if endpoint.service_id == service_id:
return
key.endpoints.create(region="RegionOne", service_id=service_id,
publicurl="http://%s:8080/v2.0/" % endpoint_host,
adminurl="http://%s:8080/v2.0/" % endpoint_host,
internalurl="http://%s:8080/v2.0/" % endpoint_host)
def create_user(user_name, password, email,tenant_id):
user_id = None
user_list = key.users.list()
# Create the user if it doesn't exist
for user in user_list:
if user.name == user_name:
user_id = user.id
if user_id is None:
user_id = key.users.create(name=user_name, password=password, email=email, tenant_id=tenant_id, enabled=True)
return user_id
def create_role(user_name, role_name, tenant_id):
role_id = None
for role in key.roles.list():
if role.name == role_name:
role_id = role.id
#create role it doesn't exist
if role_id is None:
role_id = key.roles.create(role_name)
key.roles.add_user_role(user_name, role_id, tenant_id)
def create_tenant(tenant_name):
tenant_id = None
for tenant in key.tenants.list():
if tenant.name == tenant_name:
tenant_id = tenant.id
if tenant_id is None:
tenant_id = key.tenants.create(tenant_name).id
return tenant_id
try:
key = client.Client(token='ADMIN', endpoint='http://127.0.0.1:35357/v2.0/')
except keystoneclient.exceptions:
time.sleep(2) # Sometimes chef is too fast and the service is not yet up
key = client.Client(token='ADMIN', endpoint='http://127.0.0.1:35357/v2.0/')
tenant_id = create_tenant('mini-mon')
create_user('mini-mon', 'password', 'mini@mon.com', tenant_id)
monasca_user_id = create_user('monasca-agent', 'password', 'monasca-agent@mon.com', tenant_id)
create_role(monasca_user_id, 'monasca-agent', tenant_id)
add_service_endpoint(key, 'monasca', '192.168.10.4')
EOH
end

View File

@ -1,32 +0,0 @@
# Installs the mon-ui panel
package 'python-pip' do
action :install
end
# Grab the necessary packages
['monasca-ui','python-monascaclient'].each do |pkg|
execute "pip install #{pkg}" do
action :run
end
end
# Set up symlinks
# Use 'execute' resource because chef does not support symlinking directories
if !::File.exists?("/opt/stack/horizon/monitoring")
execute "ln -sfv /usr/local/lib/python2.7/dist-packages/monitoring/enabled/* /opt/stack/horizon/openstack_dashboard/local/enabled/"
execute "ln -sv /usr/local/lib/python2.7/dist-packages/monitoring /opt/stack/horizon/monitoring"
end
# install grafana and integrate with horizon
if !::File.exists?("/usr/local/lib/python2.7/dist-packages/monitoring/static/grafana")
execute "git clone https://github.com/hpcloud-mon/grafana.git /opt/stack/grafana"
execute "cp /opt/stack/grafana/src/config.monasca.js /opt/stack/grafana/src/config.js"
execute "ln -sv /opt/stack/grafana/src /usr/local/lib/python2.7/dist-packages/monitoring/static/grafana"
end
# Bounce the webserver
service "apache2" do
action :restart
end

View File

@ -1,3 +0,0 @@
[client]
user=<%= @plugin_config['mysql']['user'] %>
password=<%= @plugin_config['mysql']['password'] %>

View File

@ -1,6 +0,0 @@
[client]
user=<%= @plugin_config['rabbitmq']['user'] %>
password=<%= @plugin_config['rabbitmq']['password'] %>
nodes=<%= @plugin_config['rabbitmq']['nodes'] %>
queues=<%= @plugin_config['rabbitmq']['queues'] %>
exchanges=<%= @plugin_config['rabbitmq']['exchanges'] %>

View File

@ -1,13 +1,16 @@
- hosts: devstack - hosts: devstack
sudo: yes sudo: yes
vars: vars:
keystone_url: http://192.168.10.5:35357/v3 monasca_api_host: 192.168.10.4
monasca_agent: monasca_agent:
user: monasca-agent user: monasca-agent
password: password password: password
project: mini-mon project: mini-mon
service: monitoring service: monitoring
monasca_api_url: http://192.168.10.4:8080/v2.0 minimon:
user: mini-mon
password: password
monasca_api_url: http://{{ monasca_api_host }}:8080/v2.0
monasca_checks: monasca_checks:
host_alive: host_alive:
init_config: init_config:
@ -19,5 +22,23 @@
name: mini-mon name: mini-mon
host_name: 192.168.10.4 host_name: 192.168.10.4
alive_test: ssh alive_test: ssh
keystone_url: http://192.168.10.5:35357/v2.0
keystone_admin_token: ADMIN
keystone_users:
mini-mon:
tenant: mini-mon
password: password
monasca-agent:
password: password
tenant: mini-mon
role: monasca-agent
keystone_endpoint:
name: monasca
host: "{{ monasca_api_host }}"
roles: roles:
- {role: tkuhlman.monasca-ui, tags: [ui]}
- {role: tkuhlman.monasca-keystone, tags: [devstack, keystone]}
- {role: monasca-devstack, tags: [devstack]}
- {role: tkuhlman.monasca-agent, tags: [agent]} - {role: tkuhlman.monasca-agent, tags: [agent]}

View File

@ -1,20 +0,0 @@
{
"name": "Devstack",
"description": "Sets up a devstack server for keystone and UI",
"json_class": "Chef::Role",
"default_attributes": {
"apt": {
"periodic_update_min_delay": 60
}
},
"override_attributes": {
},
"chef_type": "role",
"run_list": [
"recipe[devstack::mon-ui]",
"recipe[devstack::keystone]",
"recipe[devstack::agent_plugin_config]"
],
"env_run_lists": {
}
}

View File

@ -0,0 +1,31 @@
#Devstack
Configures certain Monasca Agent plugins to work on a Devstak VM
Plugins configured:
- MySQL
- RabbitMQ
Usernames and passwords may need to be changed from defaults to reflect the
devstack environment:
- MySQL
- mysql_user
- mysql_pass
- RabbitMQ
- rmq_user
- rmq_pass
- rmq_nodes
- rmq_queues
- rmq_exchanges
##Requirements
- tkuhlman.monasca-agent
##Optional
##License
Apache
##Author Information
David Schroeder
Monasca Team email monasca@lists.launchpad.net

View File

@ -0,0 +1,8 @@
---
mysql_user: root
mysql_pass: pass
rmq_user: guest
rmq_pass: pass
rmq_nodes: rabbit@devstack
rmq_queues: conductor
rmq_exchanges: nova,cinder,ceilometer,glance,keystone,neutron,heat,ironic,openstack

View File

@ -0,0 +1,3 @@
---
- name: restart rabbitmq
service: name=rabbitmq-server state=restarted enabled=yes

View File

@ -0,0 +1,21 @@
---
galaxy_info:
author: David Schroeder
description: Configures a devstack instance to work with the Monasca project.
company: HP
license: Apache
min_ansible_version: 1.2
platforms:
- name: Ubuntu
versions:
- all
categories:
- monitoring
dependencies:
- tkuhlman.monasca-agent
# List your role dependencies here, one per line. Only
# dependencies available via galaxy should be listed here.
# Be sure to remove the '[]' above if you add dependencies
# to this list.

View File

@ -0,0 +1,9 @@
---
- name: install python-mysqldb package
apt: name=python-mysqldb state=present
- name: create/update mysql config
template: dest={{ mysql_cnf_file }} owner=root group=root mode=0600 src=my_cnf.j2
notify:
- run monasca-setup

View File

@ -0,0 +1,10 @@
---
- name: Agent RabbitMQ Plugin - Activate management plugin
rabbitmq_plugin: names=rabbitmq_management state=enabled new_only=no
- name: Agent RabbitMQ Plugin - Create/update rabbitmq config
template: dest={{ rabbitmq_cnf_file }} owner=root group=root mode=0600 src=rabbitmq_cnf.j2
notify:
- restart rabbitmq
- run monasca-setup

View File

@ -0,0 +1,3 @@
---
- include: agent_rabbitmq.yaml tags=devstack_rabbitmq
- include: agent_mysql.yaml tags=devstack_mysql

View File

@ -0,0 +1,4 @@
[client]
user={{ mysql_user }}
password={{ mysql_pass }}

View File

@ -0,0 +1,7 @@
[client]
user={{ rmq_user }}
password={{ rmq_pass }}
nodes={{ rmq_nodes }}
queues={{ rmq_queues }}
exchanges={{ rmq_exchanges }}

View File

@ -0,0 +1,3 @@
---
rabbitmq_cnf_file: /root/.rabbitmq.cnf
mysql_cnf_file: /root/.my.cnf