diff --git a/README.md b/README.md index 1014197c..e5dced03 100644 --- a/README.md +++ b/README.md @@ -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` diff --git a/bootstrap/playbooks/files/prov.json b/bootstrap/playbooks/files/prov.json new file mode 100644 index 00000000..0765502a --- /dev/null +++ b/bootstrap/playbooks/files/prov.json @@ -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" + ] +} \ No newline at end of file diff --git a/bootstrap/playbooks/pxe.yaml b/bootstrap/playbooks/pxe.yaml index b8ffe395..21ee8422 100644 --- a/bootstrap/playbooks/pxe.yaml +++ b/bootstrap/playbooks/pxe.yaml @@ -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 @@ -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 diff --git a/examples/provisioning/provision.py b/examples/provisioning/provision.py index d39706ed..8a515ac7 100755 --- a/examples/provisioning/provision.py +++ b/examples/provisioning/provision.py @@ -34,25 +34,39 @@ requests.post(bareon_sync) 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 = next(n for n in node_resources + if n.name.endswith('node_{0}'.format(node.node_id))) - node_resource.update({'partitioning': node.partitioning}) + node_resource.update( + { + 'partitioning': node.partitioning, + 'master_key': master_key, + } + ) - dnsmasq = vr.create('dnsmasq_{0}'.format(node.node_id), 'resources/dnsmasq', {})[0] + 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) diff --git a/resources/not_provisioned_node/actions/provision.sh b/resources/not_provisioned_node/actions/provision.sh index 408d0717..d41994bb 100644 --- a/resources/not_provisioned_node/actions/provision.sh +++ b/resources/not_provisioned_node/actions/provision.sh @@ -7,4 +7,4 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # we should have scripts dir variable passed from above sed -i "s||${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 diff --git a/resources/not_provisioned_node/meta.yaml b/resources/not_provisioned_node/meta.yaml index e541342c..014e6d8b 100644 --- a/resources/not_provisioned_node/meta.yaml +++ b/resources/not_provisioned_node/meta.yaml @@ -11,6 +11,9 @@ input: ip: schema: str! value: + master_key: + schema: str! + value: admin_mac: schema: str! value: diff --git a/resources/not_provisioned_node/templates/provisioning.json.jinja b/resources/not_provisioned_node/templates/provisioning.json.jinja index 445f39a3..2c287657 100644 --- a/resources/not_provisioned_node/templates/provisioning.json.jinja +++ b/resources/not_provisioned_node/templates/provisioning.json.jinja @@ -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" @@ -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", @@ -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" } }, @@ -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" }