Enforce that the WAR will be undeployed from the server

    name
        The context path to undeploy.
    url : http://localhost:8080/manager
        The URL of the server with the Tomcat Manager webapp.
    timeout : 180
        Timeout for HTTP request to the Tomcat Manager.

    Example:

    .. code-block:: yaml

        jenkins:
          tomcat.undeployed:
            - name: /ran
            - require:
              - service: application-service

def undeployed(name,
               url='http://localhost:8080/manager',
               timeout=180):
    '''
    Enforce that the WAR will be undeployed from the server

    name
        The context path to undeploy.
    url : http://localhost:8080/manager
        The URL of the server with the Tomcat Manager webapp.
    timeout : 180
        Timeout for HTTP request to the Tomcat Manager.

    Example:

    .. code-block:: yaml

        jenkins:
          tomcat.undeployed:
            - name: /ran
            - require:
              - service: application-service
    '''

    # Prepare
    ret = {'name': name,
           'result': True,
           'changes': {},
           'comment': ''}

    if not __salt__['tomcat.status'](url, timeout):
        ret['comment'] = 'Tomcat Manager does not respond'
        ret['result'] = False
        return ret

    try:
        version = __salt__['tomcat.ls'](url, timeout)[name]['version']
        ret['changes'] = {'undeploy': version}
    except KeyError:
        return ret

    # Test
    if __opts__['test']:
        ret['result'] = None
        return ret

    undeploy = __salt__['tomcat.undeploy'](name, url, timeout=timeout)
    if undeploy.startswith('FAIL'):
        ret['result'] = False
        ret['comment'] = undeploy
        return ret

    return ret