From f4d74c2ef189341f2193778ffccc2b8bab47fb17 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Tue, 23 Feb 2016 13:19:09 -0800 Subject: [PATCH] Add examples directory To help people get started running this puppet, let's provide a set of DIB elements and libvirt templates to help set up a mock development environment. Change-Id: Ife8e253ba0429bedb924fde5a12f5be9e23dc163 --- examples/README.rst | 77 +++++++++++++++++++ examples/definitions/compute.xml | 52 +++++++++++++ examples/definitions/controller.xml | 52 +++++++++++++ examples/definitions/network.xml | 13 ++++ .../infracloud-static-net/element-deps | 1 + .../post-install.d/05-set-hostname | 14 ++++ .../post-install.d/10-set-ips | 34 ++++++++ .../infracloud-static-net/static/etc/hosts | 3 + .../rules.d/76-persistent-net-generator.rules | 2 + examples/elements/motd/element-deps | 1 + examples/elements/motd/static/etc/motd | 7 ++ examples/elements/puppet/element-deps | 1 + .../puppet/install.d/15-install-puppet | 6 ++ .../environments/production/environment.conf | 2 + .../puppet/static/etc/puppet/hiera.yaml | 14 ++++ .../puppet/static/etc/puppet/puppet.conf | 9 +++ .../hieradata/production/common.yaml | 51 ++++++++++++ examples/elements/smoke-test/element-deps | 1 + .../elements/smoke-test/static/opt/smoke-test | 66 ++++++++++++++++ examples/elements/system-config/element-deps | 1 + .../source-repository-system-config | 1 + examples/functions/sshvm | 37 +++++++++ 22 files changed, 445 insertions(+) create mode 100644 examples/README.rst create mode 100644 examples/definitions/compute.xml create mode 100644 examples/definitions/controller.xml create mode 100644 examples/definitions/network.xml create mode 100644 examples/elements/infracloud-static-net/element-deps create mode 100755 examples/elements/infracloud-static-net/post-install.d/05-set-hostname create mode 100755 examples/elements/infracloud-static-net/post-install.d/10-set-ips create mode 100644 examples/elements/infracloud-static-net/static/etc/hosts create mode 100644 examples/elements/infracloud-static-net/static/etc/udev/rules.d/76-persistent-net-generator.rules create mode 100644 examples/elements/motd/element-deps create mode 100644 examples/elements/motd/static/etc/motd create mode 100644 examples/elements/puppet/element-deps create mode 100755 examples/elements/puppet/install.d/15-install-puppet create mode 100644 examples/elements/puppet/static/etc/puppet/environments/production/environment.conf create mode 100644 examples/elements/puppet/static/etc/puppet/hiera.yaml create mode 100644 examples/elements/puppet/static/etc/puppet/puppet.conf create mode 100644 examples/elements/puppet/static/opt/system-config/hieradata/production/common.yaml create mode 100644 examples/elements/smoke-test/element-deps create mode 100644 examples/elements/smoke-test/static/opt/smoke-test create mode 100644 examples/elements/system-config/element-deps create mode 100644 examples/elements/system-config/source-repository-system-config create mode 100644 examples/functions/sshvm diff --git a/examples/README.rst b/examples/README.rst new file mode 100644 index 0000000..ade636b --- /dev/null +++ b/examples/README.rst @@ -0,0 +1,77 @@ +InfraCloud Development +====================== + +This example provides a set of DIB elements, libvirt templates, and +instructions for creating a local development environment that simulates the +InfraCloud production environment. This means the networking and everything +ansible sets up in preparation for running puppet apply, including a dummy +hiera database. It also includes a script to do a short smoke test. + +Setup +----- + +These instructions assume libvirt and disk-image-builder are already installed, +and that there is a public SSH key in ~/.ssh/id_rsa.pub for the devuser element +to copy. + +Create two disk images:: + + export DIB_DEV_USER_PWDLESS_SUDO=yes + export ELEMENTS_PATH=$HOME/infracloud-development/elements + DIB_ROLE=controller disk-image-create -u ubuntu devuser system-config puppet \ + motd smoke-test infracloud-static-net vm cloud-init-nocloud \ + -o "/tmp/infracloud-controller.qcow2" --image-size 20 \ + -p git,vim,vlan,bridge-utils + DIB_ROLE=compute disk-image-create -u ubuntu devuser system-config puppet \ + motd infracloud-static-net vm cloud-init-nocloud \ + -o "/tmp/infracloud-compute.qcow2" --image-size 20 \ + -p git,vim,vlan,bridge-utils + +These images have static IP addresses and hostnames baked into them. This +simulates the production environment for most purposes but avoids too much +complexity setting up local networks. + +Define the network:: + + virsh net-define definitions/network.xml + +Start the network:: + + virsh net-start public + +Define the VMs:: + + virsh define definitions/controller.xml + virsh define definitions/compute.xml + +Start the VMs:: + + virsh start controller + virsh start compute + +Puppet +------ + +SSH into the controller:: + + source functions/sshvm + sshvm controller + +Apply any puppet changes you're testing to /etc/puppet/modules/infracloud or +/opt/system-config/production. + +Run puppet apply:: + + puppet apply /opt/system-config/production/manifests/site.pp + +Do the same on the compute node once the controller is finished:: + + sshvm compute + puppet apply /opt/system-config/production/manifests/site.pp + +Test +---- + +Run the smoke test script:: + + bash -ex /opt/smoke-test diff --git a/examples/definitions/compute.xml b/examples/definitions/compute.xml new file mode 100644 index 0000000..b3e0d59 --- /dev/null +++ b/examples/definitions/compute.xml @@ -0,0 +1,52 @@ + + compute + 4096 + 1 + + hvm + + + + + + + + + + destroy + restart + restart + + /usr/bin/kvm-spice + + + + +
+ + +
+ + + +