Skip to content

Commit

Permalink
Merge pull request #305 from gitfred/build-iso-image
Browse files Browse the repository at this point in the history
Building IBP images on solar 'master' instead of downloading them
  • Loading branch information
sylwekb committed Nov 12, 2015
2 parents 8324065 + 558297d commit bd2fc4f
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 26 deletions.
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,5 @@ Solar is shipped with sane defaults in `vagrant-setting.yaml_defaults`. If you n
# Image based provisioning with Solar

* In `vagrant-setting.yaml_defaults` or `vagrant-settings.yaml` file uncomment `preprovisioned: false` line.
* Run `vagrant up`, it will take some time because it builds image for bootstrap.
* Currently in order to perform provisioning, pre-built images from Fuel can be used
* Download images [using this link](https://drive.google.com/file/d/0B7I3b5vI7ZYXM0FPTDJEdjg0Qnc/view).
* Login into vm `vagrant ssh solar-dev`
* Go to `cd /vagrant/tmp/` directory
* Untar the images `tar vxf targetimages.tar`
* Go to `/vagrant` directory
* Run `vagrant up`, it will take some time because it builds image for bootstrap and IBP images.
* Now you can run provisioning `/vagrant/examples/provisioning/provision.sh`
91 changes: 91 additions & 0 deletions bootstrap/playbooks/files/prov.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"image_data":{
"/boot":{
"container":"gzip",
"uri":"http://10.20.0.2:8080/targetimages/env_1_ubuntu_1404_amd64-boot.img.gz",
"format":"ext2"
},
"/":{
"container":"gzip",
"uri":"http://10.20.0.2:8080/targetimages/env_1_ubuntu_1404_amd64.img.gz",
"format":"ext4"
}
},
"output":"/vagrant/tmp/targetimages",
"repos":[
{
"name":"ubuntu",
"section":"main universe multiverse",
"uri":"http://archive.ubuntu.com/ubuntu/",
"priority":null,
"suite":"trusty",
"type":"deb"
},
{
"name":"ubuntu-updates",
"section":"main universe multiverse",
"uri":"http://archive.ubuntu.com/ubuntu/",
"priority":null,
"suite":"trusty-updates",
"type":"deb"
},
{
"name":"ubuntu-security",
"section":"main universe multiverse",
"uri":"http://archive.ubuntu.com/ubuntu/",
"priority":null,
"suite":"trusty-security",
"type":"deb"
},
{
"name":"mos",
"section":"main restricted",
"uri":"http://mirror.fuel-infra.org/fwm/7.0/ubuntu/",
"priority": 1050,
"suite":"mos7.0",
"type":"deb"
}
],
"codename":"trusty",
"packages": [
"acl",
"anacron",
"bash-completion",
"bridge-utils",
"bsdmainutils",
"build-essential",
"cloud-init",
"curl",
"daemonize",
"debconf-utils",
"gdisk",
"grub-pc",
"i40e-dkms",
"linux-firmware",
"linux-firmware-nonfree",
"linux-headers-generic-lts-trusty",
"linux-image-generic-lts-trusty",
"lvm2",
"mcollective",
"mdadm",
"ntp",
"openssh-client",
"openssh-server",
"puppet",
"python-amqp",
"ruby-augeas",
"ruby-ipaddress",
"ruby-json",
"ruby-netaddr",
"ruby-openstack",
"ruby-shadow",
"ruby-stomp",
"telnet",
"ubuntu-minimal",
"ubuntu-standard",
"uuid-runtime",
"vim",
"virt-what",
"vlan"
]
}
5 changes: 4 additions & 1 deletion bootstrap/playbooks/pxe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

# Install bareon-api
# Workaround is required because pbr does not handle git-eggs correctly and fails to install fuel-agent
- shell: 'pip install git+git://github.com/prmtl/fuel-agent.git@detach_from_nailgun#egg=fuel_agent'
- shell: 'pip install git+git://github.com/gitfred/fuel-agent.git@iso-build#egg=fuel_agent'
- shell: pip install git+https://github.com/Mirantis/bareon-api.git

# Install and configure supervisor
Expand All @@ -76,3 +76,6 @@

# Add nat rules so slaves have internet access via solar-dev
- shell: iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -o eth0 -j MASQUERADE

# build IBP images
- shell: fa_build_image --image_build_dir /tmp/ibp --log-file /tmp/ibp-image-build.log -d --data_driver nailgun_build_image --input_data_file files/prov.json
32 changes: 23 additions & 9 deletions examples/provisioning/provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,39 @@ def partitioning(self):
nodes_list = requests.get(discovery_service).json()

# Create slave node resources
node_resources = vr.create('nodes', 'templates/not_provisioned_nodes.yaml', {'nodes': nodes_list})
node_resources = vr.create('nodes', 'templates/not_provisioned_nodes.yaml',
{'nodes': nodes_list})

# Get master node
master_node = filter(lambda n: n.name == 'node_master', node_resources)[0]

with open('/vagrant/tmp/keys/ssh_public') as fp:
master_key = fp.read().strip()

# Dnsmasq resources
for node in nodes_list:
node = NodeAdapter(node)
node_resource = filter(lambda n: n.name.endswith('node_{0}'.format(node.node_id)), node_resources)[0]

node_resource.update({'partitioning': node.partitioning})

dnsmasq = vr.create('dnsmasq_{0}'.format(node.node_id), 'resources/dnsmasq', {})[0]
node_resource = next(n for n in node_resources
if n.name.endswith('node_{0}'.format(node.node_id)))

node_resource.update(
{
'partitioning': node.partitioning,
'master_key': master_key,
}
)

dnsmasq = vr.create('dnsmasq_{0}'.format(node.node_id),
'resources/dnsmasq', {})[0]
master_node.connect(dnsmasq)
node_resource.connect(dnsmasq, {'admin_mac': 'exclude_mac_pxe'})

event = React(node_resource.name, 'run', 'success', node_resource.name, 'provision')
event = React(node_resource.name, 'run', 'success', node_resource.name,
'provision')
add_event(event)
event = React(node_resource.name, 'provision', 'success', dnsmasq.name, 'exclude_mac_pxe')
event = React(node_resource.name, 'provision', 'success', dnsmasq.name,
'exclude_mac_pxe')
add_event(event)
event = React(dnsmasq.name, 'exclude_mac_pxe', 'success', node_resource.name, 'reboot')
event = React(dnsmasq.name, 'exclude_mac_pxe', 'success',
node_resource.name, 'reboot')
add_event(event)
2 changes: 1 addition & 1 deletion resources/not_provisioned_node/actions/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# we should have scripts dir variable passed from above
sed -i "s|<ROOT>|${DIR}|" "${DIR}"/templates/agent.config

provision --data_driver nailgun_simple --input_data_file "${DIR}"/templates/provisioning.json --config-file "${DIR}"/templates/agent.config
provision --log-file /tmp/fa_provision.log -d --data_driver nailgun_simple --input_data_file "${DIR}"/templates/provisioning.json --config-file "${DIR}"/templates/agent.config
3 changes: 3 additions & 0 deletions resources/not_provisioned_node/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ input:
ip:
schema: str!
value:
master_key:
schema: str!
value:
admin_mac:
schema: str!
value:
Expand Down
16 changes: 8 additions & 8 deletions resources/not_provisioned_node/templates/provisioning.json.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"mac_address": "08:00:27:6e:6d:b4"
},
"eth0": {
"ip_address": "10.0.2.15",
"dns_name": "node-8.test.domain.local",
"ip_address": "{{ ip }}",
"dns_name": "{{ name }}.test.domain.local",
"netmask": "255.255.255.0",
"static": "0",
"mac_address": "08:00:27:ea:35:e7"
Expand Down Expand Up @@ -119,7 +119,7 @@
"remote_relative": "dists/trusty/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64/initrd.gz"
}
},
"authorized_keys": [],
"authorized_keys": ["{{ master_key }}"],
"mlnx_iser_enabled": false,
"mco_pskey": "Gie6iega9ohngaenahthohngu8aebohxah9seidi",
"mco_user": "guest",
Expand All @@ -129,12 +129,12 @@
"image_data": {
"/boot": {
"container": "gzip",
"uri": "http://10.0.0.2:8001/tmp/targetimages/env_3_ubuntu_1404_amd64-boot.img.gz",
"uri": "http://10.0.0.2:8001/tmp/targetimages/env_1_ubuntu_1404_amd64-boot.img.gz",
"format": "ext2"
},
"/": {
"container": "gzip",
"uri": "http://10.0.0.2:8001/tmp/targetimages/env_3_ubuntu_1404_amd64.img.gz",
"uri": "http://10.0.0.2:8001/tmp/targetimages/env_1_ubuntu_1404_amd64.img.gz",
"format": "ext4"
}
},
Expand Down Expand Up @@ -213,9 +213,9 @@
"admin_net": "10.20.0.0/24",
"mco_host": "localhost"
},
"name": "node-2",
"hostname": "node-2.example.com",
"slave_name": "node-2",
"name": "{{ name }}",
"hostname": "{{ name }}.example.com",
"slave_name": "{{ name }}",
"power_pass": "/root/.ssh/bootstrap.rsa",
"netboot_enabled": "1"
}

0 comments on commit bd2fc4f

Please sign in to comment.