Forum Discussion
modify/edit irule using ansible
Hi Dario,
My understanding now is with ansible it is not possible to modify/update existing irule. Is it possible in some other tools like tcl etc? Or do we have REST api for this?
Thanks in advance,
Ahmed
- JRahmFeb 05, 2020Admin
Hi AhmedBaig, ansible does the config management well, you give it an irule and it updates it. If you are asking about using an offline editor to pull down an irule, edit it on the fly, and "save" which updates the iRule on the BIG-IP, you can use the Eclipse plugin for that, or you can use the rest API to update the contents of an iRule directly. In fact, I even wrote a little demo app in python's flask environment that you can use a local docker container to edit your iRules with. Let me know which direction you are seeking and I'll point you to the right resources.
Update:
Example using the API with python below. That said, doing it this way is really no different than using ansible as you are not interactively changing the irule. You update it in a file and then use the API to push the update.
import requests, json def create_rule(bsess, burl, name, code): payload = {} payload['name'] = name payload['apiAnonymous'] = code bsess.post('%s/ltm/rule/' % burl, data=json.dumps(payload)) print('Rule %s created...' % name) b = requests.session() b.auth = ('admin', 'admin') b.verify = False b.headers.update({'Content-Type' : 'application/json'}) b_url = 'https://192.168.102.5/mgmt/tm' with open('myirule.tcl', 'r') as irule: mycode = irule.read() irule.close() create_rule(b, b_url, 'myirule', mycode)
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com