Use hostsfile cookbook to manipulate the /etc/hosts file.

and also :
* 127.0.0.1 must be localhost
* 127.0.1.1 have fqdn and hostname
* use chef notification instead of a variable flag