--- layout: default title: Virtualization published: false sorting: 80 tags: [overviews, special topics, guide] --- CFEngine Products & Services Resources Company Events Try now CFEngine Documentation Archive This is an archive of previous versions of the CFEngine documentation up to version 3.0. For the latest documentation, go here: Get started with CFEngine Upgrade CFEngine 2 to CFEngine 3 Study the CFEngine language CFEngine 3 Enterprise Plan a CFEngine architecture Create Service management Define and ensure compliance Orchestrate complex processes Integrate with System Monitoring Ensure Speed, Scale and Agility Agility in Infrastructure Engineering Change Management and Incident Repair Scale and Scalability Virtualization and Cloud Support in CFEngine Secure your Systems with CFEngine Integrate CFEngine into an ecosystem Using CFEngine with Open Nebula Reporting Virtualization and Cloud Support in CFEngine Get Reports from CFEngine Virtualization and Cloud Support in CFEngine Virtualization and Cloud Support in CFEngine Next: What are virtualization and cloud computing?, Previous: (dir), Up: (dir) Virtualization What are virtualization and cloud computing? Why build virtualization support into CFEngine? What can CFEngine do with virtual machines? Guest environments promises Virtualization types supported Distinct states Example deployment Virtualized host examples Virtual network example COMPLETE TABLE OF CONTENTS Summary of contents Next: Why build virtualization support into CFEngine?, Previous: Top, Up: Top What are virtualization and cloud computing? Virtualization refers to the ability to run multiple host instances on a single physical node. Cloud computing typically refers to what is called `platform as a service', or deployment of virtual machines on demand, often as an online service. In this document, virtualization support refers specifically to hypervisor technologies supported by the open source library layer libvirt project, which includes interfaces for Xen, KVM, Vmware-ESX, and more. CFEngine thus integrates freely with other tools based on this library, such as virsh and the Virtual Manager graphical user interface. Next: What can CFEngine do with virtual machines?, Previous: What are virtualization and cloud computing?, Up: Top Why build virtualization support into CFEngine? Virtualization engines (usually called supervisors or hypervisors) are seeing an explosion of development. They exist as a number of projects in various stages of maturity. The libvirt project was designed as an integration layer based on an XML specification. The tools for management are still quite primitive and require much manual work. CFEngine has a unique role to play in maintaining desired state in virtual machine systems. In the cloud, virtual machines may be rented from remote commercial providers, and managed as disposable resources. Convergent or `self-healing' maintenance is an essential method for managing machines that are geographically remote and awkward to access, e.g. machines in other time-zones that it is impractical to monitor by legacy methods. Next: Guest environments promises, Previous: Why build virtualization support into CFEngine?, Up: Top What can CFEngine do with virtual machines? The simple answer is: anything thatlibvirtcan do, with added convergence to a desired state: that means, creating, destroying and starting and stopping machines. By starting virtual machines through CFEngine, you can be sure that a given `virtual guest' is running on one and only one physical host, thus avoiding conflicts that are difficult to detect with centralized systems. CFEngine does not support everything that libvirt does – it offers a simplified interface that is meant for robustness, stability and hands-free repeatability. CFEngine does not use libvirt's TLS based web communication layer. It manages every host as an independent entity, in typical CFEngine fashion, using CFEngine's own distributed cooperation to provide thje implicit communication. CFEngine does not currently support so-called `live migration' of virtual machines. Next: Virtualization types supported, Previous: What can CFEngine do with virtual machines?, Up: Top Guest environments promises A virtual machine is one example of what CFEngine calls an `guest_environment'. You can promise to create (and host) an guest environment with certain attributes, just as you can promise to host a file or a process. Here is a simple example: body common control { bundlesequence => { "my_vm_cloud" }; } ####################################################### bundle agent my_vm_cloud { guest_environments: "myUbuntu" # the running instance name, defined in XML environment_resources => virt_xml, environment_type => "xen", environment_host => "my_physical_computer", # ipv4_10_1_2_3 environment_state => "create"; } ####################################################### body environment_resources virt_xml { env_spec_file => "/srv/xen/centos5-libvirt-create.xml"; } The promiser (in this case ‘myUbuntu’) is the name of the virtual machine. This should be a unique identifier, as we need to be able to refer to machines uniquely. The guest environment host is the name of the computer that is the host for the virtual machine. Normally when we want to ensure something on a machine, we use classes to decide where the promise will be made. For guest environments, however, we need to make promises about the uniqueness of the machine. When you make a machine instance you normally want it to be running on one and only one host. So you want every machine to make a promise. On the guest environment's host, you want to promise that the guest environment is running, and on every other machine you want to promise that it is not. In CFEngine, you simply include a unique class belonging to host in the promise using environment_host and CFEngine assumes that rest. Unique classes might include Hostname class e.g. myhost_CFEngine_com IP address class e.g. ipv4_123_456_789_123 An alternative way to write this example is to quote the XML specification in CFEngine directly. This has a few advantages: you can re-use the data and use it as a template, filling in CFEngine-variables. You can thus adapt the configuration using CFEngine's classes. bundle agent my_vm_cloud { guest_environments: "myUbuntu" # the running instance name, defined in XML environment_resources => virt_xml("$(this.promiser)"), environment_type => "xen", environment_host => "myphysicalcomputer"; environment_state => "create" } ####################################################### body environment_resources virt_xml(host) { env_spec_file => " $(host) linux /var/lib/xen/install/vmlinuz-ubuntu10.4-x86_64 /var/lib/xen/install/initrd-vmlinuz-ubuntu10.4-x86_64 kickstart=http://example.com/myguest.ks 131072 1