PageRenderTime 47ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/README.md

https://gitlab.com/FunFR/foreman-vagrant
Markdown | 113 lines | 93 code | 20 blank | 0 comment | 0 complexity | b6f1ffdcdecfe997e17e9f47e1e81d52 MD5 | raw file
  1. ### Installing Foreman and Puppet Agent on Multiple VMs Using Vagrant and VirtualBox
  2. Automatically install and configure Foreman, the open source infrastructure life-cycle management tool, and multiple Puppet Agent VMs using Vagrant and VirtualBox. Project is part of my blog post, [Installing Foreman and Puppet Agent on Multiple VMs Using Vagrant and VirtualBox](http://wp.me/p1RD28-1nb).
  3. The ```centos7``` branch was created 8/20/2015 to reflect changes to original blog post in the ```master``` branch. Changes were required to fix incapability issues with the latest versions of Puppet and Foreman. For details, see [Puppet Compatibility](http://theforeman.org/manuals/1.9/index.html#3.1.2PuppetCompatibility). Additionally, the version of CentOS on all VMs was updated from 6.6 to 7.1 and the version of Foreman was updated from 1.7 to 1.9.
  4. <p><a href="https://programmaticponderings.wordpress.com/?attachment_id=3459" title="New Foreman Hosts" rel="attachment"><img width="620" height="390" src="https://programmaticponderings.files.wordpress.com/2015/08/new-foreman-hosts.png?w=620" alt="New Foreman Hosts"></a></p>
  5. #### Vagrant Plug-ins
  6. This project requires the Vagrant vagrant-hostmanager plugin to be installed. The Vagrantfile uses the vagrant-hostmanager plugin to automatically ensure all DNS entries are consistent between guests as well as the host, in the `/etc/hosts` file. An example of the modified `/etc/hosts` file is shown below.
  7. ```text
  8. ## vagrant-hostmanager-start id: c472843a-e854-4e58-8a13-856b3b0766f2
  9. 192.168.35.5 theforeman.example.com
  10. 192.168.35.10 agent01.example.com
  11. 192.168.35.20 agent02.example.com
  12. ## vagrant-hostmanager-end
  13. ```
  14. You can manually run `vagrant hostmanager` to update `/etc/hosts` at anytime.
  15. This project also requires the Vagrant vagrant-vbguest plugin is also used to keep the vbguest tools updated.
  16. ```sh
  17. vagrant plugin install vagrant-hostmanager
  18. vagrant plugin install vagrant-vbguest
  19. ```
  20. #### JSON Configuration File
  21. The `Vagrantfile` retrieves multiple VM configurations from a separate `nodes.json` JSON file. All VM configuration is
  22. contained in that JSON file. You can add additional VMs to the JSON file, following the existing pattern. The
  23. `Vagrantfile` will loop through all nodes (VMs) in the `nodes.json` file and create the VMs. You can easily swap
  24. configuration files for alternate environments since the `Vagrantfile` is designed to be generic and portable.
  25. #### Instructions
  26. Provision the Foreman VM first, before the agents. It will takes several minutes to fully provision the VM.
  27. ```sh
  28. vagrant up theforeman.example.com
  29. ```
  30. Important, when the provisioning is complete, note the output from Vagrant. The output provides the `admin` login password and URL for the Foreman console. Example output below.
  31. ```text
  32. ==> theforeman.example.com: Success!
  33. ==> theforeman.example.com: * Foreman is running at https://theforeman.example.com
  34. ==> theforeman.example.com: Initial credentials are admin / 7x2fpZBWgVEHvzTw
  35. ==> theforeman.example.com: * Foreman Proxy is running at https://theforeman.example.com:8443
  36. ==> theforeman.example.com: * Puppetmaster is running at port 8140
  37. ==> theforeman.example.com: The full log is at /var/log/foreman-installer/foreman-installer.log
  38. ```
  39. Log into Foreman's browser-based console using the information provided in the output from Vagrant (example above). Change the `admin` account password, and/or set-up your own `admin` account(s).
  40. Next, build two puppet agent VMs. Again, it will takes several minutes to fully provision the two VMs.
  41. ```sh
  42. vagrant up agent01.example.com agent02.example.com
  43. ```
  44. Next, complete the CSR process. Read the [blog post](http://wp.me/p1RD28-1nb) for complete instructions.
  45. ```sh
  46. # ssh into first agent node
  47. vagrant ssh agent01.example.com
  48. # initiate certificate signing request (CSR)
  49. sudo puppet agent -t -w=60
  50. # sign certificate within foreman to complete CSR
  51. exit
  52. # ssh into second agent node
  53. vagrant ssh agent02.example.com
  54. # initiate certificate signing request (CSR)
  55. sudo puppet agent -t -w=60
  56. # sign certificate within foreman to complete CSR
  57. ```
  58. You can always force a puppet run on a node using `sudo puppet agent -t`.
  59. #### Forwarding Ports
  60. To expose forwarding ports, add them to the 'ports' array. For example:
  61. ```JSON
  62. "ports": [
  63. {
  64. ":host": 1234,
  65. ":guest": 2234,
  66. ":id": "port-1"
  67. },
  68. {
  69. ":host": 5678,
  70. ":guest": 6789,
  71. ":id": "port-2"
  72. }
  73. ]
  74. ```
  75. #### Errors
  76. **Error: Unknown configuration section 'hostmanager'.**
  77. => **Solution: **Install the `vagrant-hostmanager` plugin with `vagrant plugin install vagrant-hostmanager`
  78. #### Useful Multi-VM Commands
  79. The use of the specific <machine> name is optional in most cases.
  80. * `vagrant up <machine>`
  81. * `vagrant reload <machine>`
  82. * `vagrant destroy -f <machine> && vagrant up <machine>`
  83. * `vagrant status <machine>`
  84. * `vagrant ssh <machine>`
  85. * `vagrant global-status`
  86. #### Useful Logs for Debugging Project Issues
  87. Some logs require sudo access
  88. * `sudo tail -50 /var/log/syslog`
  89. * `sudo tail -50 /var/log/puppet/masterhttp.log`
  90. * `sudo tail -50 /var/log/foreman/production.log`
  91. * `sudo tail -50 /var/log/foreman-installer/foreman-installer.log`
  92. * `sudo tail -50 /var/log/foreman-proxy/proxy.log`
  93. * `tail -50 ~/VirtualBox\ VMs/<machine>/Logs/VBox.log`