Configuring the default variables to allow multiple 1 or more virtualhosts #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was an issue in the Phansible/Phansible repository (#282) asking how to set up multiple virtualhosts. Having done something similar in our Ansible setup, I'd like to propose the following changes.
default/main.yml
- alter the yaml structure to include a hosts section, by default it will work the same way as it did before. This also allows some flexibility to set apache level variables, as well as variables at the vhost level. Also provided aconfig_name
option that will allow a user to set the name of the file that will go in/etc/apache2/sites-available
tasks/main.yml
- Modify the 2.4 and 2.2 tasks to use the items inapache.hosts
to build the virtual hosts and use the{{ item.config_name }}
value to name the vhost file.templates/vhost22.yml & templates/vhost24.yml
- Since we are looping through the hosts, on each pass theitem
will be available, in order for these to be configured correctly - had to change theapache.docroot
andapache.servername
tokens withitem.docroot
anditem.servername
.Since the default variables will be overwritten by anything, setting up the default variables this way provides a little bit of structure if a user wanted to change where they are using variables