validate-modules: Fix net_tools modules (#52489)

This PR includes:

* Fixes to open validate-modules issues
* Adding parameter types
This commit is contained in:
Dag Wieers 2019-02-25 13:27:35 +01:00 committed by GitHub
parent cb67235eab
commit 4670e41a30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 499 additions and 466 deletions

View file

@ -7,8 +7,6 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type
# see examples/playbooks/get_url.yml
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
'supported_by': 'core'}
@ -162,6 +160,11 @@ options:
- If C(client_cert) contains both the certificate and key, this option is not required.
type: path
version_added: '2.4'
http_agent:
description:
- Header to identify as, generally appears in web server logs.
type: str
default: ansible-httpget
# informational: requirements for nodes
extends_documentation_fragment:
- files

View file

@ -27,6 +27,7 @@ options:
- The file on the remote system to fetch. This I(must) be a file, not a directory.
type: path
required: true
aliases: [ path ]
notes:
- This module returns an 'in memory' base64 encoded version of the file, take into account that this will require at least twice the RAM as the
original file size.

View file

@ -32,14 +32,16 @@ options:
- A path of where to download the file to (if desired). If I(dest) is a
directory, the basename of the file on the remote server will be used.
type: path
user:
url_username:
description:
- A username for the module to use for Digest, Basic or WSSE authentication.
type: str
password:
aliases: [ user ]
url_password:
description:
- A password for the module to use for Digest, Basic or WSSE authentication.
type: str
aliases: [ password ]
body:
description:
- The body of the http request/response to the web service. If C(body_format) is set
@ -102,7 +104,7 @@ options:
description:
- A list of valid, numeric, HTTP status codes that signifies success of the request.
type: list
default: 200
default: [ 200 ]
timeout:
description:
- The socket level timeout in seconds
@ -174,6 +176,11 @@ options:
description:
- Path to Unix domain socket to use for connection
version_added: '2.8'
http_agent:
description:
- Header to identify as, generally appears in web server logs.
type: str
default: ansible-httpget
notes:
- The dependency on httplib2 was removed in Ansible 2.1.
- The module returns all the HTTP headers in lower-case.
@ -190,9 +197,8 @@ EXAMPLES = r'''
uri:
url: http://www.example.com
# Check that a page returns a status 200 and fail if the word AWESOME is not
# in the page contents.
- uri:
- name: Check that a page returns a status 200 and fail if the word AWESOME is not in the page contents
uri:
url: http://www.example.com
return_content: yes
register: this
@ -201,18 +207,16 @@ EXAMPLES = r'''
- name: Create a JIRA issue
uri:
url: https://your.jira.example.com/rest/api/2/issue/
method: POST
user: your_username
password: your_pass
method: POST
body: "{{ lookup('file','issue.json') }}"
force_basic_auth: yes
status_code: 201
body_format: json
# Login to a form based webpage, then use the returned cookie to
# access the app in later tasks
- uri:
- name: Login to a form based webpage, then use the returned cookie to access the app in later tasks
uri:
url: https://your.form.based.auth.example.com/index.php
method: POST
body_format: form-urlencoded
@ -223,8 +227,8 @@ EXAMPLES = r'''
status_code: 302
register: login
# Same, but now using a list of tuples
- uri:
- name: Login to a form based webpage using a list of tuples
uri:
url: https://your.form.based.auth.example.com/index.php
method: POST
body_format: form-urlencoded
@ -235,7 +239,8 @@ EXAMPLES = r'''
status_code: 302
register: login
- uri:
- name: Connect to website using a previously stored cookie
uri:
url: https://your.form.based.auth.example.com/dashboard.php
method: GET
return_content: yes
@ -245,24 +250,24 @@ EXAMPLES = r'''
- name: Queue build of a project in Jenkins
uri:
url: http://{{ jenkins.host }}/job/{{ jenkins.job }}/build?token={{ jenkins.token }}
method: GET
user: "{{ jenkins.user }}"
password: "{{ jenkins.password }}"
method: GET
force_basic_auth: yes
status_code: 201
- name: POST from contents of local file
uri:
url: "https://httpbin.org/post"
url: https://httpbin.org/post
method: POST
src: file.json
- name: POST from contents of remote file
uri:
url: "https://httpbin.org/post"
url: https://httpbin.org/post
method: POST
src: /path/to/my/file.json
remote_src: true
remote_src: yes
'''
RETURN = r'''
@ -301,7 +306,6 @@ import os
import shutil
import sys
import tempfile
import traceback
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import PY2, iteritems, string_types
@ -327,7 +331,7 @@ def write_file(module, url, dest, content, resp):
except Exception as e:
os.remove(tmpsrc)
msg = format_message("Failed to create temporary content file: %s" % to_native(e), resp)
module.fail_json(msg=msg, exception=traceback.format_exc(), **resp)
module.fail_json(msg=msg, **resp)
f.close()
checksum_src = None
@ -368,7 +372,7 @@ def write_file(module, url, dest, content, resp):
except Exception as e:
os.remove(tmpsrc)
msg = format_message("failed to copy %s to %s: %s" % (tmpsrc, dest, to_native(e)), resp)
module.fail_json(msg=msg, exception=traceback.format_exc(), **resp)
module.fail_json(msg=msg, **resp)
os.remove(tmpsrc)
@ -449,7 +453,7 @@ def uri(module, url, dest, body, body_format, method, headers, socket_timeout):
})
data = open(src, 'rb')
except OSError:
module.fail_json(msg='Unable to open source file %s' % src, exception=traceback.format_exc(), elapsed=0)
module.fail_json(msg='Unable to open source file %s' % src, elapsed=0)
else:
data = body