In fact almost all these tasks could be replaced by ansible modules (except the last the 3 lineinfile commands).
Fair enough, I was sort of sleep deprived and just wanted something that actually worked as quickly as possible haha.
I'd also prefer those be replaced with a template. IMO, reading a config file with placeholders is much easier than concatenating it in my mind as a series of _lineinfile_ commands.