init project

This commit is contained in:
Lei Zhang 2014-07-25 15:37:21 +08:00
commit c517cce726
10 changed files with 201 additions and 0 deletions

0
README.md Normal file
View File

6
nova/base.sls Normal file
View File

@ -0,0 +1,6 @@
pkg-utils:
pkg.installed:
- refresh: False
- pkgs:
- sysfsutils
- conntrack

4
nova/conf.sls Normal file
View File

@ -0,0 +1,4 @@
/etc/nova/nova.conf:
file.managed:
- source: salt://nova/files/nova.conf
- template: jinja

26
nova/controller.sls Normal file
View File

@ -0,0 +1,26 @@
{%- from "nova/map.jinja" import nova with context %}
include:
- .base
- .db
- .keystone
- .conf
nova:
pkg.installed:
- refresh: False
- pkgs: {{ nova.controller_pkgs }}
service.running:
- enable: True
- restart: True
- names: {{ nova.controller_services }}
- require:
- pkg: nova
- watch:
- file: /etc/nova/nova.conf
nova_db_sync:
cmd.run:
- name: nova-manage db sync
- require:
- file: /etc/nova/nova.conf

14
nova/db.sls Normal file
View File

@ -0,0 +1,14 @@
{% set name="nova" %}
{{ name }}-db:
mysql_database.present:
- name: {{ name }}
mysql_user.present:
- name: {{ name }}
- host: "{{ salt["pillar.get"](name + ":mysql:host","localhost") }}"
- password: {{ salt["pillar.get"](name + ":mysql:password") }}
mysql_grants.present:
- host: "{{ salt["pillar.get"](name + ":mysql:host","localhost") }}"
- grant: all privileges
- database: "{{ name }}.*"
- user: {{ name }}

16
nova/files/nova.conf Normal file
View File

@ -0,0 +1,16 @@
{% from "nova/map.jinja" import nova_config with context -%}
# This file is managed by salt
{% for section, section_values in nova_config | dictsort(true) %}
[{{ section }}]
{%- for key, value in section_values|dictsort(true)%}
{%- if value is string or value is not sequence %}
{{ key }} = {{ value }}
{%- else %}
{%- for v in value %}
{{ key }} = {{ v }}
{%- endfor %}
{%- endif %}
{%- endfor %}
{% endfor %}
{#- vim:ft=sls
-#}

0
nova/init.sls Normal file
View File

26
nova/keystone.sls Normal file
View File

@ -0,0 +1,26 @@
{%- from "openstack/map.jinja" import node with context %}
{%- set name="nova" %}
keystone_{{ name }}_user:
keystone.user_present:
- name: {{ name }}
- password: {{ salt["pillar.get"](name + ":keystone:password") }}
- email: {{ salt["pillar.get"](name + ":keystone:email", name + "@localhost.nolocal")}}
- tenant: service
- enable: True
- roles:
- service:
- admin
keystone_{{ name }}_service:
keystone.service_present:
- name: {{ name }}
- service_type: compute
- description: Openstack Compute Service
keystone_{{ name }}_endpoint:
keystone.endpoint_present:
- name: {{ name }}
- publicurl: http://{{ salt["pillar.get"](name + ":public_ip") }}:8774/v2/%(tenant_id)s
- internalurl: http://{{ salt["pillar.get"](name + ":internal_ip") }}:8774/v2/%(tenant_id)s
- adminurl: http://{{ salt["pillar.get"](name + ":admin_ip") }}:8774/v2/%(tenant_id)s

84
nova/map.jinja Normal file
View File

@ -0,0 +1,84 @@
{%- set nova=salt["grains.filter_by"]({
"Debian": {
"name": "nova",
"controller_pkgs": ["nova-api",
"nova-conductor",
"nova-consoleauth",
"nova-novncproxy",
"nova-scheduler",
"python-novaclient"],
"controller_services": ["nova-api",
"nova-conductor",
"nova-consoleauth",
"nova-scheduler"],
},
}, merge=salt["pillar.get"]("nova:lookup")) %}
# Set the nova default config
{%- set nova_config = {
"DEFAULT": {
"dhcpbridge_flagfile": "/etc/nova/nova.conf",
"dhcpbridge": "/usr/bin/nova-dhcpbridge",
"logdir": "/var/log/nova",
"state_path": "/var/lib/nova",
"lock_path": "/var/lock/nova",
"force_dhcp_release": "True",
"iscsi_helper": "tgtadm",
"connection_type": "libvirt",
"root_helper": "sudo nova-rootwrap /etc/nova/rootwrap.conf",
"ec2_private_dns_show_ip": "True",
"api_paste_config": "/etc/nova/api-paste.ini",
"enabled_apis": "ec2,osapi_compute,metadata",
"memcached_servers": salt["pillar.get"]("nova:internal_ip") + ":11211",
"auth_strategy": "keystone",
"glance_host": salt["pillar.get"]("nova:internal_ip"),
"rpc_backend": "nova.openstack.common.rpc.impl_kombu",
"rabbit_userid": salt["pillar.get"]("nova:rabbitmq:name"),
"rabbit_password": salt["pillar.get"]("nova:rabbitmq:password"),
"novncproxy_host": "0.0.0.0",
"vncserver_listen": "0.0.0.0",
"novncproxy_base_url": "http://" + salt["pillar.get"]("nova:config:DEFAULT:novncproxy_base_ip") + ":6080/vnc_auto.html",
"vncserver_proxyclient_address": salt["pillar.get"]("nova:internal_ip"),
"network_manager ": "nova.network.manager.VlanManager",
"vlan_start ": "1000",
"vlan_interface ": salt["pillar.get"]("nova:private_interface"),
"multi_host": True,
"send_arp_for_ha": True,
"public_interface": salt["pillar.get"]("nova:public_interface"),
"share_dhcp_address": True,
"dns_server": ["223.6.6.6",
"8.8.4.4"],
"resume_guests_state_on_host_boot": "True",
"snapshot_image_format": "qcow2",
"remove_unused_base_images": "True",
},
"database": {
"connection": ("mysql://nova:" + salt["pillar.get"]("nova:mysql:password") + "@"
+ salt["pillar.get"]("nova:mysql:ip", "localhost")
+ "/nova?charset=utf8")
},
"libvirt": {
"virt_type": "kvm",
"snapshot_compression": "True",
"use_virtio_for_bridges": "True",
"snapshot_compression": "true",
"live_migration_flag": "VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE",
},
"keystone_authtoken":{
"auth_host": salt["pillar.get"]("nova:keystone:host", "localhost"),
"auth_port": 5000,
"auth_protocol": "http",
"admin_tenant_name": "service",
"admin_user" : "nova",
"admin_password": salt["pillar.get"]("nova:keystone:password")
}
} %}
{#- vim:ft=sls
-#}

25
pillar.example Normal file
View File

@ -0,0 +1,25 @@
nova:
public_ip: 10.0.0.12
internal_ip: 10.0.0.12
admin_ip: 10.0.0.12
public_interface: eth0
private_interface: eth0
keystone:
password: 'pass'
email: zhang.lei.fly@gmail.com
host: 10.0.0.12
rabbitmq:
name: openstack
password: pass
ip: 10.0.0.12
mysql:
ip: 10.0.0.12
host: '%'
password: pass
config:
DEFAULT:
novncproxy_base_ip: 10.0.0.12
{#- vim:ft=sls
-#}