#+Title: CFEngine Enterprise Vagrant Environment

A quick way to bring up a CFEngine Enterprise environment.


* Bring up the environment
:PROPERTIES:
:ID:       93a69077-307b-4d66-99b2-d09e9c0ae0d9
:END:

To initialize a stock environment with one hub and one client

#+begin_src sh
  vagrant up hub && vagrant up
#+end_src

*Note:* The ~HOSTS~ environment variable can be set and exported to change the number of
clients being initialized. For example:

#+begin_src sh
  export HOSTS=5
  vagrant up hub && vagrant up
#+end_src

to initialize a hub and 5 clients.

* Log in to Mission Portal
:PROPERTIES:
:ID:       72c4ab70-5ed0-45b9-93a7-9c226bcb8d66
:END:
Once the environment is up you should be able to log into Mission Portal at
https://localhost:9002.

*Note:* As of =3.9.0= Mission Portal uses HTTPS by default. You will need to add
an exception for the self signed certificate when accessing.

[[file:extras/images/README-example-invalid_security_certificate.png]]

For convenience you may want to consider a permanent exception.

[[file:extras/images/README-example-certificate-exception.png]]

* Environment Default Settings
:PROPERTIES:
:ID:       573b4f39-069a-4106-af9e-03e1a25ca6f1
:END:
Network: =192.168.56.0/24=

| host    |           ip |
|---------+--------------|
| hub     | 192.168.56.2 |
| host001 | 192.168.56.3 |

* Extra Configuration Options
:PROPERTIES:
:ID:       bcd17a52-2f33-432e-9b6c-71ac65adec07
:END:

** Override =/var/cfengine/masterfiles= on the hub
:PROPERTIES:
:ID:       d15b6258-e91c-4488-8ca3-a096b93784fd
:END:

It can be very useful as a test or development environment with your own
masterfiles. To bring up an environment with your own masterfiles run.

#+begin_src sh
  MASTERFILES=/path/to/my/masterfiles vagrant up
#+end_src

*Note:* You rename the vagrant project folder and the vm names will change their
prefix to match. This allows you to more easily have multiple vagrant projects
for different versions side by side.

** Mount =~/CFEngine= from host to =/CFEngine= on guest
:PROPERTIES:
:ID:       6f54765d-7a81-436f-9d6f-edb7e850eacd
:END:
This is primarily useful for policy developers. If =~/CFEngine= exists it will
be automatically mounted to =/CFEngine= on all hosts. This is useful if you work
with polices that are maintained outside your main repository.
** Alternate Platforms and Versions
:PROPERTIES:
:ID:       5087770a-6952-438f-b982-c85d6f86524e
:END:

It is possible with environment variables to bring up alternate vagrant platforms
as well as install alternate versions of cfengine.

Refer to [[https://cfengine.com/downloads/cfengine-enterprise/][Download CFEngine Enterprise]] to see which version are supported on which platforms.

#+begin_src sh
  PLATFORM=ubuntu/bionic64 PACKAGE_RELEASE=3.18.0 vagrant up hub
  PLATFORM=debian/stretch64 PACKAGE_RELEASE=3.15.4 vagrant up host001
#+end_src

*NOTE*: that networking configuration may not work on all vagrant boxes so if reporting fails, ensure that each host has the proper shared networking IP addresses in the 192.168.56.0/24 subnet.

** Bring up a mixed environment
:PROPERTIES:
:ID:       1f004759-4e2c-4d61-831e-b80b72d30b3f
:END:

To bring up a mixed environment you can use the following work-flow:

1) Bring up the hub using the default basebox.
2) Make sure we have cached the `ubunut/trusty64` basebox.
3) Bring up the first host

#+begin_src sh
  vagrant up hub
  vagrant box add ubuntu/trusty64
  PLATFORM="ubuntu/trusty64" vagrant up host001
#+end_src sh

By default only the packages compatible with the default basebox are
present. When host001 boots the provisioner will use the [[https://cfengine.com/downloads/quick-install/][Quick Install]] script
to install and then bootstrap to the hub.

*NOTE*: Some base boxes have firewalls enabled, if your host isn't showing up in
mission portal that's a good place to start checking.

You can rinse and repeat this procedure increasing `hosts` to get a larger mixed
environment.

For example:
#+Caption: Bring up mixed environment
#+BEGIN_SRC sh
  vagrant up hub
  PLATFORM=ARTACK/debian-jessie vagrant up host001
  HOSTS=3 PLATFORM="fujimakishouten/debian-stretch64" vagrant up host002
#+END_SRC

#+caption: Example mixed environment running from vagrant environment
#+name: fig:README-mixed-env-example
[[file:extras/images/README-mixed-env-example.png]]
