Jump to content
Welcome to our new Citrix community!
  • Ansible for NetScaler Nitro API operations

    • Validation Status: Validated
      Summary: Nitro Request module to perform Nitro API operations on various NetScaler endpoints
      Has Video?: No

    NetScaler Ansible modules can be used for automating NetScaler configurations. It also contains a generic module called citrix_adc_nitro_request which doesn’t target a particular endpoint instead can be used to perform NITRO API operations on various endpoints.

    Using Nitro Request Ansible module

    Let’s go through the example and understand the  execution of citrix_adc_nitro_request module
        - name: Get lb vserver      delegate_to: localhost      register: result      citrix_adc_nitro_request:        nsip: "{{ nsip }}"        nitro_user: "{{ nitro_user }}"        nitro_pass: "{{ nitro_pass }}"        operation: get        resource: lbvserver        name: lbvs1

    As we can see there is a group of attributes that are common among all ansible NetScaler modules for connecting to the target NetScaler. After these, we have the operation attribute which is the key to the execution of the module. It instructs the module which operation to perform. In our case we want the get operation to get information for a particular NITRO object. After that, we have the attributes that will determine which object will be fetched. In our case, we want the resource lbvserver with the name lbvs1. The result is stored in the result variable for further processing by subsequent modules. We could for example print out its contents with the debug module.

    Supported Operations

    Apart from the get operation the citrix_adc_nitro_resource module supports the following operations:
    • add
    • update
    • Get
    • get_by_args
    • get_filtered
    • get_all
    • delete
    • delete_by_args
    • count
    • mas_login
    • save_config
    • action
    The add operation is used to create a new NITRO object.

    The update operation is used to update an existing object

    The get* operations are used to retrieve information for an object. They are differentiated by how we define the choice criteria for object retrieval.

    The delete and delete_by_args operations are used to delete existing objects.

    The count operation is used to return the count of a NITRO object.

    The mas_login operation is used to retrieve the authentication token from an ADM to use in subsequent calls where the ADM will be used as a NITRO API proxy.

    The save_config operation is used to save the configuration on the target NetScaler.

    Finally, the action operation is used to perform an action against a NITRO endpoint. The action can vary. For example. one action would be to enable a basic server.


    It is worth noting that nitro_request will try to do as little as possible of processing apart from the operation it is instructed to do. In this way, you can think of it as a thin wrapper around the Ansible URI module. It mainly will provide a more convenient and intuitive interface to perform an HTTP operation. As a consequence of that it will always report a changed state as it will not do any processing to determine if an actual configuration change took place in the target Netscaler.


    Despite these limitations, it is useful in its own right and also can be combined with the citrix_adc_nitro_resource module to perform more complex tasks. For example, we could use the nitro_resource module to create a server and then the nitro_request module to enable or disable the server. An example playbook of that is shown below where we create a server and then proceed to disable it.

    Although it is a bit artificial as an example it showcases how the two generic modules could be combined to achieve the desired configuration.

    - hosts: citrix_adc  gather_facts: False  vars_files:    - deps/workflows.yaml  collections:    - citrix.adc  tasks:    - name: Setup server      delegate_to: localhost      citrix_adc_nitro_resource:        nsip: "{{ nsip }}"        nitro_user: "{{ nitro_user }}"        nitro_pass: "{{ nitro_pass }}"        validate_certs: "{{ validate_certs }}"        state: present        workflow: "{{ workflow.server }}"        resource:          name: test-server          ipaddress:    - name: Disable server      delegate_to: localhost      register: result      citrix_adc_nitro_request:        nsip: "{{ nsip }}"        nitro_user: "{{ nitro_user }}"        nitro_pass: "{{ nitro_pass }}"        validate_certs: "{{ validate_certs }}"        operation: action        action: disable        resource: server        attributes:          name: test-server          delay: 30          graceful: !!str yes

    Useful Resources :






    User Feedback

    Recommended Comments

    There are no comments to display.

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

  • Create New...