2

I'm trying to automate some deployments and I need to comment out some configuration, which essentially comprises of a full block. Is there a way to comment a particular block of code/configuration via ansible playbook?

hellodk
  • 316
  • 4
  • 11

1 Answers1

0

Commenting a whole block will be very hard. I can't think of a way to do this without a custom written module.

If it is an option, you can remove a block with the blockinfile module, which has an state: absent option. Unfortunately it does not have regex option to identify a block, which would be required to identify your commented/uncommented block. If it helps, the blockinfile module can create a backup with the original content.

The docs on the galaxy page are a bit broken. See the github page for better formatting.

udondan
  • 57,263
  • 20
  • 190
  • 175