F5Networks / f5-ansible

Imperative Ansible modules for F5 BIG-IP products
GNU General Public License v3.0
376 stars 231 forks source link

Enhancement: support raw iControl REST calls similar to Ansible uri module #608

Closed chen23 closed 6 years ago

chen23 commented 6 years ago
ISSUE TYPE
COMPONENT NAME

new bigip_icontrol_rest_uri

SUMMARY

There should be a module to perform "raw" iControl REST calls with GET, PUT, PATCH, POST.

This would facilitate:

a.) getting raw data from BIG-IP b.) supporting endpoints that may not have an existing F5 Ansible module

This could be thought of similar to bigip_command, but for low-level iControl REST calls (leaving SOAP out of scope).

STEPS TO REPRODUCE

via the Python SDK you would want something like.

mgmt = ManagementRoot(bigip_ip, bigip_username, bigip_password, port=bigip_port)
session = mgmt._meta_data['bigip']._meta_data['icr_session']

Then you could have an Ansible module with semantics similar to the uri module.

- name: Create a chen deployment using iControlLX
  bigip_icontrol_rest_uri:
    url: https://bigip/mgmt/tm/chen/deploy
    method: POST
    user: your_username
    password: your_pass
    body: "{{ lookup('file','deploy.json') }}"
    force_basic_auth: yes
    status_code: 201
    body_format: json
EXPECTED RESULTS
ACTUAL RESULTS
realged13 commented 6 years ago

I was just thinking about this today. Following.

caphrim007 commented 6 years ago

To a large extent, this can be done today with ansible's uri module, though you will need a second task to get the authentication token.

realged13 commented 6 years ago

@caphrim007 Thanks for the tip, I will look into this.

caphrim007 commented 6 years ago

@realged13 see the example here https://github.com/F5Networks/f5-ansible/tree/devel/examples/0006-using-rest-api-directly

Note that this is not the recommended approach to automating the box as it carries with it a number of risks. Many of those risks are outlined in the example's README.

If this is still the approach that you want to take though, then I wont stop you.

realged13 commented 6 years ago

@caphrim007 Thanks. Not reallly ready to get into that yet, but just seeing if I could use it occasionally instead of doing the command method. Like I am having to create virtual servers, then run a command that modifys the protocol to use TCP.

caphrim007 commented 6 years ago

@realged13 sure, just dont be surprised if you are surprised by it :-)

closing as @chen23 is satisfied with the url examples