Pass and use the environment in validate_template

Use the environment passed in validate_template to be able to validate
template using custom resources.

Change-Id: I464d837c74d8be16e125d7701830d0bcbced75ab
Closes-Bug: #1298450