Skip to content
This repository has been archived by the owner on Feb 2, 2018. It is now read-only.

Commit

Permalink
vagrant: Ported Vagrantfile from MVP. (#41)
Browse files Browse the repository at this point in the history
* vagrant: Ported Vagrantfile from MVP.

* fixup! vagrant: Ported Vagrantfile from MVP.
  • Loading branch information
ashcrow authored and mbarnes committed Nov 7, 2016
1 parent 6a9ae8a commit ab207f3
Show file tree
Hide file tree
Showing 2 changed files with 196 additions and 13 deletions.
169 changes: 169 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|

# NOTE: Ordering matters! The commissaire box should be the
# the last box to start!

# Development servers server.
config.vm.define "servers" do |servers|
servers.vm.box = "fedora/24-cloud-base"
servers.vm.network "private_network", ip: "192.168.152.101"
servers.vm.provision "shell", inline: <<-SHELL
echo "==> Setting hostname"
sudo hostnamectl set-hostname servers
echo "===> Updating the system"
sudo dnf update --setopt=tsflags=nodocs -y
echo "===> Installing etcd and redis"
sudo dnf install -y etcd redis
echo "===> Configuring etcd"
sudo sed -i "s/localhost/192.168.152.101/g" /etc/etcd/etcd.conf
echo "===> Starting etcd"
sudo systemctl enable etcd
sudo systemctl start etcd
echo "===> Set flannel network"
sudo etcdctl --endpoint=http://192.168.152.101:2379 set '/atomic01/network/config' '{"Network": "172.16.0.0/12", "SubnetLen": 24, "Backend": {"Type": "vxlan"}}'
echo "===> Configure redis"
sudo sed -i "s/127.0.0.1/192.168.152.101/g" /etc/redis.conf
sudo systemctl enable redis
sudo systemctl start redis
SHELL
# End servers
end

# Development Kubernetes server.
# NOTE: This must start after etcd.
config.vm.define "kubernetes", autostart: false do |kubernetes|
kubernetes.vm.box = "fedora/24-cloud-base"
kubernetes.vm.network "private_network", ip: "192.168.152.102"
kubernetes.vm.provision "shell", inline: <<-SHELL
echo "==> Setting hostname"
sudo hostnamectl set-hostname kubernetes
echo "===> Updating the system"
sudo dnf update --setopt=tsflags=nodocs -y
echo "===> Installing kubernetes"
sudo dnf install -y kubernetes-master.x86_64
echo "===> Configuring kubernetes"
sudo sed -i "s|insecure-bind-address=127.0.0.1|insecure-bind-address=192.168.152.102|g" /etc/kubernetes/apiserver
sudo sed -i "s|etcd-servers=http://127.0.0.1:2379|etcd-servers=http://192.168.152.101:2379|g" /etc/kubernetes/apiserver
echo "===> Starting kubernetes"
sudo systemctl enable kube-apiserver kube-scheduler kube-controller-manager
sudo systemctl start kube-apiserver kube-scheduler kube-controller-manager
SHELL
# End kubernetes
end


# Development Node 1
config.vm.define "fedora-cloud" do |node|
node.vm.box = "fedora/24-cloud-base"
node.vm.network "private_network", ip: "192.168.152.110"
node.vm.provision "shell", inline: <<-SHELL
echo "==> Setting hostname"
sudo hostnamectl set-hostname fedora-cloud
echo "===> Installing SSH keys"
mkdir --parents /home/vagrant/.ssh
cp /vagrant/features/id_rsa{,.pub} /home/vagrant/.ssh
cat /home/vagrant/.ssh/id_rsa.pub >> /home/vagrant/.ssh/authorized_keys
echo "===> Updating the system"
sudo dnf update --setopt=tsflags=nodocs -y
echo "===> Installing OS dependencies"
sudo dnf install -y python
SHELL
# End fedora-cloud
end

# Development Node 1
config.vm.define "fedora-atomic" do |node|
node.vm.box = "fedora/24-atomic-host"
node.vm.network "private_network", ip: "192.168.152.111"
config.vm.synced_folder ".", "/vagrant", disabled: true
node.vm.provision "shell", inline: <<-SHELL
echo "==> Setting hostname"
sudo hostnamectl set-hostname fedora-atomic
echo "===> Installing SSH keys"
mkdir --parents /home/vagrant/.ssh
cp /home/vagrant/sync/features/id_rsa{,.pub} /home/vagrant/.ssh
cat /home/vagrant/.ssh/id_rsa.pub >> /home/vagrant/.ssh/authorized_keys
echo "===> Updating the system"
sudo atomic host upgrade
sudo systemctl reboot
SHELL
# End fedora-atomic
end

# Development commissaire server and services
# NOTE: This must start after etcd.
config.vm.define "commissaire", primary: true do |commissaire|
commissaire.vm.box = "fedora/24-cloud-base"
commissaire.vm.network "private_network", ip: "192.168.152.100"
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder ".", "/vagrant/commissaire", mount_options: ['vers=3']
config.vm.synced_folder "../commissaire-http", "/vagrant/commissaire-http", mount_options: ['vers=3']
config.vm.synced_folder "../commissaire-service", "/vagrant/commissaire-service", mount_options: ['vers=3']
commissaire.vm.provision "shell", inline: <<-SHELL
echo "==> Setting hostname"
sudo hostnamectl set-hostname commissaire
echo "===> Updating the system"
sudo dnf update -y
echo "===> Installing OS dependencies"
sudo dnf install -y --setopt=tsflags=nodocs rsync openssh-clients redhat-rpm-config python3-virtualenv gcc libffi-devel openssl-devel git nfs-utils
echo "===> Setting up virtualenv"
virtualenv-3 commissaire_env
echo "===> Installing commissaire"
. commissaire_env/bin/activate && pip install -U -r /vagrant/commissaire/test-requirements.txt
. commissaire_env/bin/activate && pip install -e /vagrant/commissaire/
echo "===> Installing commissaire-http"
. commissaire_env/bin/activate && pip install -U -r /vagrant/commissaire-http/test-requirements.txt
. commissaire_env/bin/activate && pip install -e /vagrant/commissaire-http/
echo "===> Installing commissaire-service"
. commissaire_env/bin/activate && pip install -U -r /vagrant/commissaire-service/test-requirements.txt
. commissaire_env/bin/activate && pip install -e /vagrant/commissaire-service/
echo "===> Setting up commissaire-server to autostart"
sudo cp /vagrant/commissaire-http/conf/systemd/commissaire-server.service /etc/systemd/system/commissaire-server.service
sudo chmod 644 /etc/systemd/system/commissaire-server.service
sudo mkdir --parents /etc/commissaire
sudo cp /vagrant/commissaire-http/conf/commissaire.conf /etc/commissaire/commissaire.conf
sudo sed -i 's|"listen-interface": "127.0.0.1"|"listen-interface": "192.168.152.100"|g' /etc/commissaire/commissaire.conf
sudo sed -i 's|"bus-uri": "redis://127.0.0.1:6379/"|"bus-uri": "redis://192.168.152.101:6379/"|g' /etc/commissaire/commissaire.conf
sudo sed -i 's|^ExecStart=.*|ExecStart=/bin/bash -c ". /home/vagrant/commissaire_env/bin/activate \\&\\& commissaire-server -c /etc/commissaire/commissaire.conf"|' /etc/systemd/system/commissaire-server.service
sudo sed -i 's|Type=simple|\&\\nWorkingDirectory=/vagrant|' /etc/systemd/system/commissaire-server.service
echo "===> Setting up commissaire-storage service to autostart"
sudo cp /vagrant/commissaire-service/conf/storage.conf /etc/commissaire/storage.conf
sudo cp /vagrant/commissaire-service/conf/systemd/commissaire-storage.service /etc/systemd/system/commissaire-storage.service
sudo sed -i 's|"server_url": "http://127.0.0.1:2379"|"server_url": "http://192.168.152.101:2379"|g' /etc/commissaire/storage.conf
sudo sed -i 's|^ExecStart=.*|ExecStart=/bin/bash -c ". /home/vagrant/commissaire_env/bin/activate \\&\\& commissaire-storage-service -c /etc/commissaire/storage.conf"|' /etc/systemd/system/commissaire-storage.service
echo "===> Setting up commissaire-investogater-service to autostart"
sudo cp /vagrant/commissaire-service/conf/systemd/commissaire-investigator.service /etc/systemd/system/commissaire-investigator.service
sudo sed -i 's|^ExecStart=.*|ExecStart=/bin/bash -c ". /home/vagrant/commissaire_env/bin/activate \\&\\& commissaire-investigator-service -c /etc/commissaire/investigator.conf"|' /etc/systemd/system/commissaire-investigator.service
echo "===> Setting up commissaire-watcher service to autostart"
sudo cp /vagrant/commissaire-service/conf/systemd/commissaire-watcher.service /etc/systemd/system/commissaire-watcher.service
sudo sed -i 's|^ExecStart=.*|ExecStart=/bin/bash -c ". /home/vagrant/commissaire_env/bin/activate \\&\\& commissaire-watcher-service -c /etc/commissaire/watcher.conf"|' /etc/systemd/system/commissaire-watcher.service
echo "===> Starting commissaire-server"
sudo systemctl daemon-reload
sudo systemctl enable commissaire-server
sudo systemctl start commissaire-server
echo "===> Starting commissaire-storage service"
sudo systemctl enable commissaire-storage
sudo systemctl start commissaire-storage
echo "===> Starting commissaire-investigator"
sudo systemctl enable commissaire-investigator
sudo systemctl start commissaire-investigator
echo "===> Starting commissaire-watcher service"
sudo systemctl enable commissaire-watcher
sudo systemctl start commissaire-watcher
SHELL
# End commissaire
end

# End config
end
40 changes: 27 additions & 13 deletions doc/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,46 @@ your system with application only dependencies while you code.
Vagrant
-------

.. todo::
A ``Vagrantfile`` is provided which will give you a full local development setup.

Currently not ported to new architecture.
To run the vagrant development environment make sure you have a supported
virtualization system, vagrant installed, and have all commissaire projects checked
out in the parent folder as the commissaire vagrant box will attempt to mount them
over NFS.

.. code-block:: shell
$ ls ../ | grep 'commissaire'
commissaire
commissaire-http
commissaire-service
$
A ``Vagrantfile`` is provided which will give you a full local development setup.
To run the vagrant development environment make sure you have a support
virtualization system as well as vagrant installed and execute ``vagrant up``.

.. warning::

The initial run updates the systems and can take some time. To provision faster try ``vagrant up --parallel etcd fedora-cloud fedora-atomic && vagrant up commissaire``.
The initial run updates the systems and can take some time. To provision faster try ``vagrant up --parallel servers fedora-cloud fedora-atomic && vagrant up commissaire``.

.. note::

On some Linux versions you may have to follow extra steps for vagrant. Here is an example for using vagrant with NFS on `Fedora <https://developer.fedoraproject.org/tools/vagrant/vagrant-nfs.html>`_.

.. note::

You will need to add an ssh pub key to ``/root/.ssh/authorized_keys`` on nodes if you will not be using ``cloud-init`` for bootstrapping.

================== =============== ================ =========
Server IP OS AutoStart
================== =============== ================ =========
Etcd 192.168.152.101 Fedora Cloud 24 Yes
Fedora Node 192.168.152.110 Fedora Cloud 24 Yes
Fedora Atomic Node 192.168.152.111 Fedora Atomic 23 Yes
Commissaire 192.168.152.100 Fedora Cloud 24 Yes
Kubernetes 192.168.152.102 Fedora Cloud 24 No
================== =============== ================ =========
==================== =============== ================ =========
Server IP OS AutoStart
==================== =============== ================ =========
Servers (etcd/redis) 192.168.152.101 Fedora Cloud 24 Yes
Fedora Node 192.168.152.110 Fedora Cloud 24 Yes
Fedora Atomic Node 192.168.152.111 Fedora Atomic 24 Yes
Commissaire 192.168.152.100 Fedora Cloud 24 Yes
Kubernetes 192.168.152.102 Fedora Cloud 24 No
==================== =============== ================ =========

For more information see the `Vagrant site <https://www.vagrantup.com>`_.

Expand Down

0 comments on commit ab207f3

Please sign in to comment.