The template module does the validation using the *new* configuration file.
This takes places *before* the file is put into its final place, so it’s specifically *not* /etc/apache2/apache2.conf, but rather a temporary file.
The location of this tempfile is part of the registered results:
TASK [Gathering Facts] ****************************************************************************************************************************************
ok: [bionic]
TASK [test template module] ***********************************************************************************************************************************
changed: [bionic]
TASK [debug] **************************************************************************************************************************************************
ok: [bionic] => {
"results": {
"changed": true,
"checksum": "9ef49cb61d96783deb22dd7ba23f42d48303a840",
"dest": "/etc/apache2/apache2.conf",
"diff": [],
"failed": false,
"gid": 0,
"group": "root",
"md5sum": "04f23d5d3f10c6f65eb3ec754d4ce73c",
"mode": "0644",
"owner": "root",
"size": 7250,
"src": "/home/vagrant/.ansible/tmp/ansible-tmp-1534823379.24-1117512573422/source",
"state": "file",
"uid": 0
}
}
PLAY RECAP ****************************************************************************************************************************************************
bionic : ok=3 changed=1 unreachable=0 failed=0
From you question it's not clear whether you manually ran 'apache2 -t -f /etc/apache2/apache2.conf' on the target host *after* the template module has run, or before that?
And it's also not clear if the template module changed something when "thinks it's just fine".
Either way, debugging output (-v) should reveal more.
Dick