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?
Asked
Active
Viewed 2,808 times
1 Answers
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
-
1Thanks!! I created a regex expression and used replace module, it just works well!! – hellodk Feb 17 '16 at 06:32