add simple examples
This commit is contained in:
parent
08ea5191bc
commit
42ee3aa307
|
@ -0,0 +1,130 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'json'
|
||||
require 'yaml'
|
||||
|
||||
nodes = {
|
||||
"compute-01" => '64:7D:B8:84:64:79',
|
||||
"controller-01" => "64:43:7B:CA:56:DD",
|
||||
}
|
||||
|
||||
|
||||
public_iface = "eth0"
|
||||
internal_iface = "eth1"
|
||||
private_iface = "eth2"
|
||||
default_gateway = "10.20.0.1"
|
||||
master_ip = "10.20.0.2"
|
||||
dns1 = default_gateway
|
||||
internal_net = '10.20.1.0'
|
||||
|
||||
internal_net_prefix = internal_net.split('.')[0..2].join(".")
|
||||
|
||||
|
||||
template = YAML.load(File.open('example_new.yaml'))
|
||||
template_node = template['node_01']
|
||||
newyaml = template
|
||||
newyaml['nodes'] = []
|
||||
newyaml.delete('node_01')
|
||||
cluster = JSON.load(File.open("simple.json"))
|
||||
nodes.each do |node,macaddr|
|
||||
result = template_node.clone
|
||||
json_node = cluster.select {|n| n['mac'].to_s == macaddr.to_s.upcase}[0]
|
||||
mac = json_node['mac'].to_s
|
||||
ip = json_node['ip'].to_s
|
||||
l_octet = ip.split('.')[3]
|
||||
id = json_node['id'].to_s
|
||||
uid = id
|
||||
if node == nodes.select{ |n,m| n.to_s =~ /controller/ }.map{|n,m| n}.first
|
||||
role = 'primary-controller'
|
||||
elsif node =~ /controller/
|
||||
role = 'controller'
|
||||
elsif node == nodes.select { |n,m| n.to_s =~ /swiftproxy/ }.map{|n,m| n}.first
|
||||
role = 'primary-swift-proxy'
|
||||
elsif node =~ /swiftproxy/
|
||||
role = 'swift-proxy'
|
||||
elsif node =~ /swift-\d+/
|
||||
role = 'storage'
|
||||
else
|
||||
role = 'compute'
|
||||
end
|
||||
|
||||
cobbler_dnsname = "#{node}.domain.tld"
|
||||
cobbler_interfaces = {
|
||||
public_iface => {"ip_address"=>ip, "netmask"=> "255.255.255.0", "dns_name"=>cobbler_dnsname, "static"=> "1", "mac_address" => mac}
|
||||
}
|
||||
cobbler_interfaces_extra = {
|
||||
public_iface => {'onboot'=>'yes','peerdns'=>'no'},
|
||||
internal_iface => {'onboot'=>'no','peerdns'=>'no'},
|
||||
private_iface => {'onboot'=>'no','peerdns'=>'no'}
|
||||
}
|
||||
result['interfaces'] = cobbler_interfaces
|
||||
result['interfaces_extra'] = cobbler_interfaces_extra
|
||||
result['power_address'] = ip
|
||||
result['mac'] = mac
|
||||
result['default_gateway'] = default_gateway
|
||||
result['name'] = node
|
||||
result['id'] = id
|
||||
result['uid'] = uid
|
||||
result['ip'] = ip
|
||||
result['name_servers'] = master_ip
|
||||
result['role'] = role
|
||||
result['fqdn'] = cobbler_dnsname
|
||||
system_disk=json_node['meta']['disks'].select {|disk| disk['name'] == 'vda'}.first
|
||||
cinder_disk=json_node['meta']['disks'].select {|disk| disk['name'] == 'vdb'}.first
|
||||
|
||||
system_disk_path = system_disk['disk']
|
||||
system_disk_size = (system_disk['size']/1048756.0).floor
|
||||
cinder_disk_path = cinder_disk['disk']
|
||||
cinder_disk_size = (cinder_disk['size']/1048756.0).floor
|
||||
|
||||
system_pv_size = system_disk_size - 201
|
||||
swap_size = 1024
|
||||
free_vg_size = system_pv_size - swap_size
|
||||
free_extents = (free_vg_size/32.0).floor
|
||||
system_disk_size = 32 * free_extents
|
||||
|
||||
|
||||
# ks_spaces: '"[{\"type\": \"disk\", \"id\": \"disk/by-path/pci-0000:00:06.0-virtio-pci-virtio3\",
|
||||
# \"volumes\": [{\"mount\": \"/boot\", \"type\": \"partition\", \"size\": 200},
|
||||
# {\"type\": \"mbr\"}, {\"size\": 20000, \"type\": \"pv\", \"vg\": \"os\"}],
|
||||
# \"size\": 20480}, {\"type\": \"vg\", \"id\": \"os\", \"volumes\": [{\"mount\":
|
||||
# \"/\", \"type\": \"lv\", \"name\": \"root\", \"size\": 10240 }, {\"mount\":
|
||||
# \"swap\", \"type\": \"lv\", \"name\": \"swap\", \"size\": 2048}]}]"'
|
||||
|
||||
|
||||
ks_spaces = '"[{\"type\": \"disk\", \"id\": \"' +
|
||||
system_disk_path.to_s +
|
||||
'\",\"volumes\": [{\"mount\": \"/boot\", \"type\": \"partition\", \"size\": 200}, {\"type\": \"mbr\"}, {\"size\": ' +
|
||||
system_pv_size.to_s +
|
||||
', \"type\": \"pv\", \"vg\": \"os\"}],\"size\": ' +
|
||||
system_disk_size.to_s +
|
||||
'},{\"type\": \"vg\", \"id\": \"os\", \"volumes\": [{\"mount\": \"/\", \"type\": \"lv\", \"name\": \"root\", \"size\": ' +
|
||||
system_disk_size.to_s +
|
||||
'}, {\"mount\": \"swap\", \"type\": \"lv\", \"name\": \"swap\", \"size\": '+
|
||||
swap_size.to_s +
|
||||
'}]}, {\"type\": \"disk\", \"id\": \"' + cinder_disk_path + '\", \"volumes\": [{\"type\": \"mbr\"}, {\"size\": ' +
|
||||
cinder_disk_size.to_s +
|
||||
', \"type\": \"pv\", \"vg\": \"cinder-volumes\"}], \"size\": ' +
|
||||
cinder_disk_size.to_s + '}]"'
|
||||
|
||||
|
||||
cobbler_ks_meta={"ks_spaces"=>ks_spaces,"mco_host"=>master_ip}
|
||||
|
||||
result['ks_meta'] = result['ks_meta'].update(cobbler_ks_meta)
|
||||
puppet_network_data = [
|
||||
{"name" => 'public', 'ip'=>ip, "dev" => public_iface, 'netmask' => "255.255.255.0", "gateway" => default_gateway },
|
||||
{"name" => ['management','storage'], 'ip'=>"#{internal_net_prefix.to_s}.#{l_octet}", "dev" => public_iface, 'netmask' => "255.255.255.0"},
|
||||
{"name" => 'fixed', "dev" => private_iface},
|
||||
]
|
||||
result['network_data'] = puppet_network_data
|
||||
# puts result.to_yaml
|
||||
newyaml['nodes'].push(result)
|
||||
end
|
||||
|
||||
newyaml['attributes']['dns_nameservers'] = master_ip
|
||||
newyaml['attributes']['libvirt_type'] = 'kvm'
|
||||
newyaml['attributes']['floating_network_range'] = '10.20.0.150/28'
|
||||
newyaml['attributes']['fixed_network_range'] = '10.20.1.0/24'
|
||||
newyaml['attributes']['base_syslog']['syslog_server'] = master_ip
|
||||
|
||||
puts newyaml.to_yaml
|
||||
|
|
@ -0,0 +1,166 @@
|
|||
[
|
||||
{
|
||||
"status": "discover",
|
||||
"name": "Untitled (64:79)",
|
||||
"ip": "10.20.0.122",
|
||||
"error_type": null,
|
||||
"pending_addition": false,
|
||||
"fqdn": null,
|
||||
"network_data": [],
|
||||
"platform_name": null,
|
||||
"cluster": null,
|
||||
"mac": "64:7D:B8:84:64:79",
|
||||
"meta": {
|
||||
"memory": {
|
||||
"slots": 1,
|
||||
"total": 2147483648,
|
||||
"maximum_capacity": 2147483648,
|
||||
"devices": [
|
||||
{
|
||||
"type": "RAM",
|
||||
"size": 2147483648
|
||||
}
|
||||
]
|
||||
},
|
||||
"interfaces": [
|
||||
{
|
||||
"mac": "64:F1:30:1A:0A:95",
|
||||
"max_speed": null,
|
||||
"name": "eth2",
|
||||
"current_speed": null
|
||||
},
|
||||
{
|
||||
"mac": "64:95:7B:3A:4D:B6",
|
||||
"max_speed": null,
|
||||
"name": "eth1",
|
||||
"current_speed": null
|
||||
},
|
||||
{
|
||||
"name": "eth0",
|
||||
"ip": "10.20.0.122",
|
||||
"netmask": "255.255.255.0",
|
||||
"mac": "64:7D:B8:84:64:79",
|
||||
"max_speed": null,
|
||||
"current_speed": null
|
||||
}
|
||||
],
|
||||
"disks": [
|
||||
{
|
||||
"model": null,
|
||||
"disk": "disk/by-path/pci-0000:00:07.0-virtio-pci-virtio4",
|
||||
"name": "vdb",
|
||||
"size": 21474836480
|
||||
},
|
||||
{
|
||||
"model": null,
|
||||
"disk": "disk/by-path/pci-0000:00:06.0-virtio-pci-virtio3",
|
||||
"name": "vda",
|
||||
"size": 21474836480
|
||||
}
|
||||
],
|
||||
"system": {
|
||||
"fqdn": "bootstrap",
|
||||
"manufacturer": "KVM"
|
||||
},
|
||||
"cpu": {
|
||||
"real": 0,
|
||||
"total": 1,
|
||||
"spec": [
|
||||
{
|
||||
"model": "QEMU Virtual CPU version 1.0",
|
||||
"frequency": 3300
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"role": null,
|
||||
"online": true,
|
||||
"progress": 0,
|
||||
"pending_deletion": false,
|
||||
"os_platform": "centos",
|
||||
"id": 1,
|
||||
"manufacturer": "KVM"
|
||||
},
|
||||
{
|
||||
"status": "discover",
|
||||
"name": "Untitled (56:DD)",
|
||||
"ip": "10.20.0.94",
|
||||
"error_type": null,
|
||||
"pending_addition": false,
|
||||
"fqdn": null,
|
||||
"network_data": [],
|
||||
"platform_name": null,
|
||||
"cluster": null,
|
||||
"mac": "64:43:7B:CA:56:DD",
|
||||
"meta": {
|
||||
"memory": {
|
||||
"slots": 1,
|
||||
"total": 1073741824,
|
||||
"maximum_capacity": 1073741824,
|
||||
"devices": [
|
||||
{
|
||||
"type": "RAM",
|
||||
"size": 1073741824
|
||||
}
|
||||
]
|
||||
},
|
||||
"interfaces": [
|
||||
{
|
||||
"mac": "64:D8:E1:F6:66:43",
|
||||
"max_speed": null,
|
||||
"name": "eth2",
|
||||
"current_speed": null
|
||||
},
|
||||
{
|
||||
"mac": "64:C8:E2:3B:FD:6E",
|
||||
"max_speed": null,
|
||||
"name": "eth1",
|
||||
"current_speed": null
|
||||
},
|
||||
{
|
||||
"name": "eth0",
|
||||
"ip": "10.20.0.94",
|
||||
"netmask": "255.255.255.0",
|
||||
"mac": "64:43:7B:CA:56:DD",
|
||||
"max_speed": null,
|
||||
"current_speed": null
|
||||
}
|
||||
],
|
||||
"disks": [
|
||||
{
|
||||
"model": null,
|
||||
"disk": "disk/by-path/pci-0000:00:07.0-virtio-pci-virtio4",
|
||||
"name": "vdb",
|
||||
"size": 21474836480
|
||||
},
|
||||
{
|
||||
"model": null,
|
||||
"disk": "disk/by-path/pci-0000:00:06.0-virtio-pci-virtio3",
|
||||
"name": "vda",
|
||||
"size": 21474836480
|
||||
}
|
||||
],
|
||||
"system": {
|
||||
"fqdn": "bootstrap",
|
||||
"manufacturer": "KVM"
|
||||
},
|
||||
"cpu": {
|
||||
"real": 0,
|
||||
"total": 1,
|
||||
"spec": [
|
||||
{
|
||||
"model": "QEMU Virtual CPU version 1.0",
|
||||
"frequency": 3300
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"role": null,
|
||||
"online": true,
|
||||
"progress": 0,
|
||||
"pending_deletion": false,
|
||||
"os_platform": "centos",
|
||||
"id": 2,
|
||||
"manufacturer": "KVM"
|
||||
}
|
||||
]
|
|
@ -0,0 +1,249 @@
|
|||
---
|
||||
nodes:
|
||||
- role: compute
|
||||
network_data:
|
||||
- name: public
|
||||
ip: 10.20.0.122
|
||||
dev: eth0
|
||||
netmask: 255.255.255.0
|
||||
gateway: 10.20.0.1
|
||||
- name:
|
||||
- management
|
||||
- storage
|
||||
ip: 10.20.1.122
|
||||
dev: eth0
|
||||
netmask: 255.255.255.0
|
||||
- name: fixed
|
||||
dev: eth2
|
||||
public_br: br-ex
|
||||
internal_br: br-mgmt
|
||||
id: '1'
|
||||
default_gateway: 10.20.0.1
|
||||
uid: '1'
|
||||
mac: 64:7D:B8:84:64:79
|
||||
name: compute-01
|
||||
ip: 10.20.0.122
|
||||
profile: centos-x86_64
|
||||
fqdn: compute-01.domain.tld
|
||||
power_type: ssh
|
||||
power_user: root
|
||||
power_pass: /root/.ssh/bootstrap.rsa
|
||||
power_address: 10.20.0.122
|
||||
netboot_enabled: '1'
|
||||
name_servers: 10.20.0.2
|
||||
puppet_master: fuel.domain.tld
|
||||
ks_meta: &17570000
|
||||
ks_spaces: ! '"[{\"type\": \"disk\", \"id\": \"disk/by-path/pci-0000:00:06.0-virtio-pci-virtio3\",\"volumes\":
|
||||
[{\"mount\": \"/boot\", \"type\": \"partition\", \"size\": 200}, {\"type\":
|
||||
\"mbr\"}, {\"size\": 20275, \"type\": \"pv\", \"vg\": \"os\"}],\"size\": 19232},{\"type\":
|
||||
\"vg\", \"id\": \"os\", \"volumes\": [{\"mount\": \"/\", \"type\": \"lv\", \"name\":
|
||||
\"root\", \"size\": 19232}, {\"mount\": \"swap\", \"type\": \"lv\", \"name\":
|
||||
\"swap\", \"size\": 1024}]}, {\"type\": \"disk\", \"id\": \"disk/by-path/pci-0000:00:07.0-virtio-pci-virtio4\",
|
||||
\"volumes\": [{\"type\": \"mbr\"}, {\"size\": 20476, \"type\": \"pv\", \"vg\":
|
||||
\"cinder-volumes\"}], \"size\": 20476}]"'
|
||||
mco_enable: 1
|
||||
mco_vhost: mcollective
|
||||
mco_pskey: unset
|
||||
mco_user: mcollective
|
||||
puppet_enable: 0
|
||||
install_log_2_syslog: 1
|
||||
mco_password: marionette
|
||||
puppet_auto_setup: 1
|
||||
puppet_master: fuel.domain.tld
|
||||
mco_auto_setup: 1
|
||||
auth_key: ! '""'
|
||||
puppet_version: 2.7.19
|
||||
mco_connector: rabbitmq
|
||||
mco_host: 10.20.0.2
|
||||
interfaces:
|
||||
eth0:
|
||||
ip_address: 10.20.0.122
|
||||
netmask: 255.255.255.0
|
||||
dns_name: compute-01.domain.tld
|
||||
static: '1'
|
||||
mac_address: 64:7D:B8:84:64:79
|
||||
interfaces_extra:
|
||||
eth0:
|
||||
onboot: 'yes'
|
||||
peerdns: 'no'
|
||||
eth1:
|
||||
onboot: 'no'
|
||||
peerdns: 'no'
|
||||
eth2:
|
||||
onboot: 'no'
|
||||
peerdns: 'no'
|
||||
meta: &17588060
|
||||
memory:
|
||||
total: 778694656
|
||||
interfaces:
|
||||
- mac: 64:D8:E1:F6:66:43
|
||||
max_speed: 100
|
||||
name: eth2
|
||||
ip: 10.22.0.94
|
||||
netmask: 255.255.255.0
|
||||
current_speed: 100
|
||||
- mac: 64:C8:E2:3B:FD:6E
|
||||
max_speed: 100
|
||||
name: eth1
|
||||
ip: 10.21.0.94
|
||||
netmask: 255.255.255.0
|
||||
current_speed: 100
|
||||
- name: eth0
|
||||
ip: 10.20.0.94
|
||||
netmask: 255.255.255.0
|
||||
mac: 64:43:7B:CA:56:DD
|
||||
max_speed: 100
|
||||
current_speed: 100
|
||||
disks:
|
||||
- model: VBOX HARDDISK
|
||||
disk: disk/by-path/pci-0000:00:0d.0-scsi-2:0:0:0
|
||||
name: sdc
|
||||
size: 2411724800000
|
||||
- model: VBOX HARDDISK
|
||||
disk: disk/by-path/pci-0000:00:0d.0-scsi-1:0:0:0
|
||||
name: sdb
|
||||
size: 536870912000
|
||||
- model: VBOX HARDDISK
|
||||
disk: disk/by-path/pci-0000:00:0d.0-scsi-0:0:0:0
|
||||
name: sda
|
||||
size: 17179869184
|
||||
system:
|
||||
serial: '0'
|
||||
version: '1.2'
|
||||
fqdn: bootstrap
|
||||
family: Virtual Machine
|
||||
manufacturer: VirtualBox
|
||||
cpu:
|
||||
real: 0
|
||||
total: 1
|
||||
spec:
|
||||
- model: Intel(R) Core(TM)2 Duo CPU P8600 @ 2.40GHz
|
||||
frequency: 2397
|
||||
error_type:
|
||||
- role: primary-controller
|
||||
network_data:
|
||||
- name: public
|
||||
ip: 10.20.0.94
|
||||
dev: eth0
|
||||
netmask: 255.255.255.0
|
||||
gateway: 10.20.0.1
|
||||
- name:
|
||||
- management
|
||||
- storage
|
||||
ip: 10.20.1.94
|
||||
dev: eth0
|
||||
netmask: 255.255.255.0
|
||||
- name: fixed
|
||||
dev: eth2
|
||||
public_br: br-ex
|
||||
internal_br: br-mgmt
|
||||
id: '2'
|
||||
default_gateway: 10.20.0.1
|
||||
uid: '2'
|
||||
mac: 64:43:7B:CA:56:DD
|
||||
name: controller-01
|
||||
ip: 10.20.0.94
|
||||
profile: centos-x86_64
|
||||
fqdn: controller-01.domain.tld
|
||||
power_type: ssh
|
||||
power_user: root
|
||||
power_pass: /root/.ssh/bootstrap.rsa
|
||||
power_address: 10.20.0.94
|
||||
netboot_enabled: '1'
|
||||
name_servers: 10.20.0.2
|
||||
puppet_master: fuel.domain.tld
|
||||
ks_meta: *17570000
|
||||
interfaces:
|
||||
eth0:
|
||||
ip_address: 10.20.0.94
|
||||
netmask: 255.255.255.0
|
||||
dns_name: controller-01.domain.tld
|
||||
static: '1'
|
||||
mac_address: 64:43:7B:CA:56:DD
|
||||
interfaces_extra:
|
||||
eth0:
|
||||
onboot: 'yes'
|
||||
peerdns: 'no'
|
||||
eth1:
|
||||
onboot: 'no'
|
||||
peerdns: 'no'
|
||||
eth2:
|
||||
onboot: 'no'
|
||||
peerdns: 'no'
|
||||
meta: *17588060
|
||||
error_type:
|
||||
attributes:
|
||||
use_cow_images: true
|
||||
libvirt_type: kvm
|
||||
dns_nameservers: 10.20.0.2
|
||||
verbose: true
|
||||
debug: true
|
||||
auto_assign_floating_ip: true
|
||||
start_guests_on_host_boot: true
|
||||
create_networks: true
|
||||
compute_scheduler_driver: nova.scheduler.multi.MultiScheduler
|
||||
quantum: true
|
||||
master_hostname: controller-01
|
||||
nagios: false
|
||||
proj_name: test
|
||||
nagios_master: fuelweb.domain.tld
|
||||
management_vip: 10.20.1.200
|
||||
public_vip: 10.20.0.200
|
||||
novanetwork_parameters:
|
||||
vlan_start: <1-1024>
|
||||
network_manager: String
|
||||
network_size: <Integer>
|
||||
quantum_parameters:
|
||||
tenant_network_type: gre
|
||||
segment_range: 300:500
|
||||
metadata_proxy_shared_secret: quantum
|
||||
mysql:
|
||||
root_password: root
|
||||
glance:
|
||||
db_password: glance
|
||||
user_password: glance
|
||||
swift:
|
||||
user_password: swift_pass
|
||||
nova:
|
||||
db_password: nova
|
||||
user_password: nova
|
||||
access:
|
||||
password: admin
|
||||
user: admin
|
||||
tenant: admin
|
||||
email: admin@example.org
|
||||
keystone:
|
||||
db_password: keystone
|
||||
admin_token: nova
|
||||
quantum_access:
|
||||
user_password: quantum
|
||||
db_password: quantum
|
||||
rabbit:
|
||||
password: nova
|
||||
user: nova
|
||||
cinder:
|
||||
password: cinder
|
||||
user: cinder
|
||||
floating_network_range: 10.20.0.150/28
|
||||
fixed_network_range: 10.20.1.0/24
|
||||
base_syslog:
|
||||
syslog_port: '514'
|
||||
syslog_server: 10.20.0.2
|
||||
syslog:
|
||||
syslog_port: '514'
|
||||
syslog_transport: udp
|
||||
syslog_server: ''
|
||||
use_unicast_corosync: false
|
||||
horizon_use_ssl: false
|
||||
cinder_nodes:
|
||||
- controller
|
||||
ntp_servers:
|
||||
- pool.ntp.org
|
||||
deployment_id: 1
|
||||
deployment_mode: ha
|
||||
deployment_source: cli
|
||||
deployment_engine: nailyfact
|
||||
engine:
|
||||
url: http://localhost/cobbler_api
|
||||
username: cobbler
|
||||
password: cobbler
|
Loading…
Reference in New Issue