mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Port arg specs from type='str' to type='path'
This commit is contained in:
parent
dc69af50dc
commit
75eed6a51a
12 changed files with 27 additions and 40 deletions
|
@ -543,7 +543,7 @@ def main():
|
||||||
argument_spec.update(
|
argument_spec.update(
|
||||||
dict(
|
dict(
|
||||||
bucket=dict(required=True),
|
bucket=dict(required=True),
|
||||||
dest=dict(default=None),
|
dest=dict(default=None, type='path'),
|
||||||
encrypt=dict(default=True, type='bool'),
|
encrypt=dict(default=True, type='bool'),
|
||||||
expiry=dict(default=600, type='int', aliases=['expiration']),
|
expiry=dict(default=600, type='int', aliases=['expiration']),
|
||||||
headers=dict(type='dict'),
|
headers=dict(type='dict'),
|
||||||
|
@ -593,9 +593,6 @@ def main():
|
||||||
src = module.params.get('src')
|
src = module.params.get('src')
|
||||||
ignore_nonexistent_bucket = module.params.get('ignore_nonexistent_bucket')
|
ignore_nonexistent_bucket = module.params.get('ignore_nonexistent_bucket')
|
||||||
|
|
||||||
if dest:
|
|
||||||
dest = os.path.expanduser(dest)
|
|
||||||
|
|
||||||
object_canned_acl = ["private", "public-read", "public-read-write", "aws-exec-read", "authenticated-read", "bucket-owner-read", "bucket-owner-full-control"]
|
object_canned_acl = ["private", "public-read", "public-read-write", "aws-exec-read", "authenticated-read", "bucket-owner-read", "bucket-owner-full-control"]
|
||||||
bucket_canned_acl = ["private", "public-read", "public-read-write", "authenticated-read"]
|
bucket_canned_acl = ["private", "public-read", "public-read-write", "authenticated-read"]
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,7 @@ class AzureRMStorageBlob(AzureRMModuleBase):
|
||||||
blob=dict(type='str', aliases=['blob_name']),
|
blob=dict(type='str', aliases=['blob_name']),
|
||||||
blob_type=dict(type='str', default='block', choices=['block', 'page']),
|
blob_type=dict(type='str', default='block', choices=['block', 'page']),
|
||||||
container=dict(required=True, type='str', aliases=['container_name']),
|
container=dict(required=True, type='str', aliases=['container_name']),
|
||||||
dest=dict(type='str'),
|
dest=dict(type='path'),
|
||||||
force=dict(type='bool', default=False),
|
force=dict(type='bool', default=False),
|
||||||
resource_group=dict(required=True, type='str', aliases=['resource_group_name']),
|
resource_group=dict(required=True, type='str', aliases=['resource_group_name']),
|
||||||
src=dict(type='str'),
|
src=dict(type='str'),
|
||||||
|
@ -329,7 +329,7 @@ class AzureRMStorageBlob(AzureRMModuleBase):
|
||||||
return self.results
|
return self.results
|
||||||
|
|
||||||
def get_container(self):
|
def get_container(self):
|
||||||
result = dict()
|
result = {}
|
||||||
container = None
|
container = None
|
||||||
if self.container:
|
if self.container:
|
||||||
try:
|
try:
|
||||||
|
@ -443,8 +443,6 @@ class AzureRMStorageBlob(AzureRMModuleBase):
|
||||||
|
|
||||||
def dest_is_valid(self):
|
def dest_is_valid(self):
|
||||||
if not self.check_mode:
|
if not self.check_mode:
|
||||||
self.dest = os.path.expanduser(self.dest)
|
|
||||||
self.dest = os.path.expandvars(self.dest)
|
|
||||||
if not os.path.basename(self.dest):
|
if not os.path.basename(self.dest):
|
||||||
# dest is a directory
|
# dest is a directory
|
||||||
if os.path.isdir(self.dest):
|
if os.path.isdir(self.dest):
|
||||||
|
|
|
@ -250,7 +250,7 @@ class LoginManager(DockerBaseClass):
|
||||||
:return: None
|
:return: None
|
||||||
'''
|
'''
|
||||||
|
|
||||||
path = os.path.expanduser(self.config_path)
|
path = self.config_path
|
||||||
if not self.config_file_exists(path):
|
if not self.config_file_exists(path):
|
||||||
self.create_config_file(path)
|
self.create_config_file(path)
|
||||||
|
|
||||||
|
@ -298,7 +298,7 @@ def main():
|
||||||
email=dict(type='str'),
|
email=dict(type='str'),
|
||||||
reauthorize=dict(type='bool', default=False, aliases=['reauth']),
|
reauthorize=dict(type='bool', default=False, aliases=['reauth']),
|
||||||
state=dict(type='str', default='present', choices=['present', 'absent']),
|
state=dict(type='str', default='present', choices=['present', 'absent']),
|
||||||
config_path=dict(type='str', default='~/.docker/config.json', aliases=['self.config_path', 'dockercfg_path']),
|
config_path=dict(type='path', default='~/.docker/config.json', aliases=['self.config_path', 'dockercfg_path']),
|
||||||
)
|
)
|
||||||
|
|
||||||
required_if = [
|
required_if = [
|
||||||
|
|
|
@ -124,7 +124,6 @@ from ansible.module_utils.rax import rax_argument_spec, rax_clb_node_to_dict, ra
|
||||||
|
|
||||||
|
|
||||||
def _activate_virtualenv(path):
|
def _activate_virtualenv(path):
|
||||||
path = os.path.expanduser(path)
|
|
||||||
activate_this = os.path.join(path, 'bin', 'activate_this.py')
|
activate_this = os.path.join(path, 'bin', 'activate_this.py')
|
||||||
with open(activate_this) as f:
|
with open(activate_this) as f:
|
||||||
code = compile(f.read(), activate_this, 'exec')
|
code = compile(f.read(), activate_this, 'exec')
|
||||||
|
@ -159,7 +158,7 @@ def main():
|
||||||
port=dict(type='int'),
|
port=dict(type='int'),
|
||||||
state=dict(default='present', choices=['present', 'absent']),
|
state=dict(default='present', choices=['present', 'absent']),
|
||||||
type=dict(choices=['primary', 'secondary']),
|
type=dict(choices=['primary', 'secondary']),
|
||||||
virtualenv=dict(),
|
virtualenv=dict(type='path'),
|
||||||
wait=dict(default=False, type='bool'),
|
wait=dict(default=False, type='bool'),
|
||||||
wait_timeout=dict(default=30, type='int'),
|
wait_timeout=dict(default=30, type='int'),
|
||||||
weight=dict(type='int'),
|
weight=dict(type='int'),
|
||||||
|
|
|
@ -365,11 +365,10 @@ def main():
|
||||||
lc_collate=dict(default=""),
|
lc_collate=dict(default=""),
|
||||||
lc_ctype=dict(default=""),
|
lc_ctype=dict(default=""),
|
||||||
state=dict(default="present", choices=["absent", "present", "dump", "restore"]),
|
state=dict(default="present", choices=["absent", "present", "dump", "restore"]),
|
||||||
target=dict(default=""),
|
target=dict(default="", type="path"),
|
||||||
target_opts=dict(default=""),
|
target_opts=dict(default=""),
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=argument_spec,
|
argument_spec=argument_spec,
|
||||||
supports_check_mode=True
|
supports_check_mode=True
|
||||||
|
@ -412,8 +411,6 @@ def main():
|
||||||
if target == "":
|
if target == "":
|
||||||
target = "{0}/{1}.sql".format(os.getcwd(), db)
|
target = "{0}/{1}.sql".format(os.getcwd(), db)
|
||||||
target = os.path.expanduser(target)
|
target = os.path.expanduser(target)
|
||||||
else:
|
|
||||||
target = os.path.expanduser(target)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pgutils.ensure_libs(sslrootcert=module.params.get('ssl_rootcert'))
|
pgutils.ensure_libs(sslrootcert=module.params.get('ssl_rootcert'))
|
||||||
|
|
|
@ -175,7 +175,7 @@ def main():
|
||||||
archive = False
|
archive = False
|
||||||
successes = []
|
successes = []
|
||||||
|
|
||||||
for i, path in enumerate(paths):
|
for path in paths:
|
||||||
path = os.path.expanduser(os.path.expandvars(path))
|
path = os.path.expanduser(os.path.expandvars(path))
|
||||||
|
|
||||||
# Expand any glob characters. If found, add the expanded glob to the
|
# Expand any glob characters. If found, add the expanded glob to the
|
||||||
|
@ -191,7 +191,7 @@ def main():
|
||||||
|
|
||||||
# Only attempt to expand the exclude paths if it exists
|
# Only attempt to expand the exclude paths if it exists
|
||||||
if exclude_paths:
|
if exclude_paths:
|
||||||
for i, exclude_path in enumerate(exclude_paths):
|
for exclude_path in exclude_paths:
|
||||||
exclude_path = os.path.expanduser(os.path.expandvars(exclude_path))
|
exclude_path = os.path.expanduser(os.path.expandvars(exclude_path))
|
||||||
|
|
||||||
# Expand any glob characters. If found, add the expanded glob to the
|
# Expand any glob characters. If found, add the expanded glob to the
|
||||||
|
|
|
@ -148,7 +148,6 @@ def main():
|
||||||
# Create type object as namespace for module params
|
# Create type object as namespace for module params
|
||||||
p = type('Params', (), module.params)
|
p = type('Params', (), module.params)
|
||||||
|
|
||||||
p.src = os.path.expanduser(p.src)
|
|
||||||
if not os.access(p.src, os.R_OK):
|
if not os.access(p.src, os.R_OK):
|
||||||
module.fail_json(msg="src %s doesn't exist or not readable" % (p.src))
|
module.fail_json(msg="src %s doesn't exist or not readable" % (p.src))
|
||||||
|
|
||||||
|
|
|
@ -353,7 +353,7 @@ def main():
|
||||||
dest = dict(required=True),
|
dest = dict(required=True),
|
||||||
dest_port = dict(default=None, type='int'),
|
dest_port = dict(default=None, type='int'),
|
||||||
delete = dict(default='no', type='bool'),
|
delete = dict(default='no', type='bool'),
|
||||||
private_key = dict(default=None),
|
private_key = dict(type='path', default=None),
|
||||||
rsync_path = dict(default=None),
|
rsync_path = dict(default=None),
|
||||||
_local_rsync_path = dict(default='rsync', type='path'),
|
_local_rsync_path = dict(default='rsync', type='path'),
|
||||||
_substitute_controller = dict(default='no', type='bool'),
|
_substitute_controller = dict(default='no', type='bool'),
|
||||||
|
@ -467,7 +467,7 @@ def main():
|
||||||
if is_rsh_needed(source, dest):
|
if is_rsh_needed(source, dest):
|
||||||
ssh_cmd = [module.get_bin_path('ssh', required=True), '-S', 'none']
|
ssh_cmd = [module.get_bin_path('ssh', required=True), '-S', 'none']
|
||||||
if private_key is not None:
|
if private_key is not None:
|
||||||
ssh_cmd.extend(['-i', os.path.expanduser(private_key) ])
|
ssh_cmd.extend(['-i', private_key])
|
||||||
# If the user specified a port value
|
# If the user specified a port value
|
||||||
# Note: The action plugin takes care of setting this to a port from
|
# Note: The action plugin takes care of setting this to a port from
|
||||||
# inventory if the user didn't specify an explicit dest_port
|
# inventory if the user didn't specify an explicit dest_port
|
||||||
|
|
|
@ -326,7 +326,6 @@ def uri(module, url, dest, body, body_format, method, headers, socket_timeout):
|
||||||
# we'll reset back to the supplied value soon
|
# we'll reset back to the supplied value soon
|
||||||
follow_redirects = module.params['follow_redirects']
|
follow_redirects = module.params['follow_redirects']
|
||||||
module.params['follow_redirects'] = False
|
module.params['follow_redirects'] = False
|
||||||
dest = os.path.expanduser(dest)
|
|
||||||
if os.path.isdir(dest):
|
if os.path.isdir(dest):
|
||||||
# first check if we are redirected to a file download
|
# first check if we are redirected to a file download
|
||||||
_, redir_info = fetch_url(module, url, data=body,
|
_, redir_info = fetch_url(module, url, data=body,
|
||||||
|
|
|
@ -337,7 +337,7 @@ def write_changes(module, lines, dest):
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
dest=dict(default='/etc/network/interfaces', required=False),
|
dest=dict(default='/etc/network/interfaces', required=False, type='path'),
|
||||||
iface=dict(required=False),
|
iface=dict(required=False),
|
||||||
option=dict(required=False),
|
option=dict(required=False),
|
||||||
value=dict(required=False),
|
value=dict(required=False),
|
||||||
|
@ -348,8 +348,7 @@ def main():
|
||||||
supports_check_mode=True
|
supports_check_mode=True
|
||||||
)
|
)
|
||||||
|
|
||||||
dest = os.path.expanduser(module.params['dest'])
|
dest = module.params['dest']
|
||||||
|
|
||||||
iface = module.params['iface']
|
iface = module.params['iface']
|
||||||
option = module.params['option']
|
option = module.params['option']
|
||||||
value = module.params['value']
|
value = module.params['value']
|
||||||
|
|
|
@ -178,7 +178,7 @@ def main():
|
||||||
host=dict(),
|
host=dict(),
|
||||||
username=dict(),
|
username=dict(),
|
||||||
password=dict(no_log=True),
|
password=dict(no_log=True),
|
||||||
ssh_key_data=dict(no_log=True),
|
ssh_key_data=dict(no_log=True, type='path'),
|
||||||
ssh_key_unlock=dict(no_log=True),
|
ssh_key_unlock=dict(no_log=True),
|
||||||
authorize=dict(type='bool', default=False),
|
authorize=dict(type='bool', default=False),
|
||||||
authorize_password=dict(no_log=True),
|
authorize_password=dict(no_log=True),
|
||||||
|
@ -223,7 +223,6 @@ def main():
|
||||||
|
|
||||||
if params['ssh_key_data']:
|
if params['ssh_key_data']:
|
||||||
filename = params['ssh_key_data']
|
filename = params['ssh_key_data']
|
||||||
filename = os.path.expanduser(filename)
|
|
||||||
if not os.path.exists(filename):
|
if not os.path.exists(filename):
|
||||||
module.fail_json(msg='file not found: %s' % filename)
|
module.fail_json(msg='file not found: %s' % filename)
|
||||||
if os.path.isdir(filename):
|
if os.path.isdir(filename):
|
||||||
|
|
|
@ -148,7 +148,7 @@ def _ensure_virtualenv(module):
|
||||||
if venv_param is None:
|
if venv_param is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
vbin = os.path.join(os.path.expanduser(venv_param), 'bin')
|
vbin = os.path.join(venv_param, 'bin')
|
||||||
activate = os.path.join(vbin, 'activate')
|
activate = os.path.join(vbin, 'activate')
|
||||||
|
|
||||||
if not os.path.exists(activate):
|
if not os.path.exists(activate):
|
||||||
|
@ -224,10 +224,10 @@ def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
command=dict(default=None, required=True),
|
command=dict(default=None, required=True),
|
||||||
app_path=dict(default=None, required=True),
|
app_path=dict(default=None, required=True, type='path'),
|
||||||
settings=dict(default=None, required=False),
|
settings=dict(default=None, required=False),
|
||||||
pythonpath=dict(default=None, required=False, aliases=['python_path']),
|
pythonpath=dict(default=None, required=False, aliases=['python_path']),
|
||||||
virtualenv=dict(default=None, required=False, aliases=['virtual_env']),
|
virtualenv=dict(default=None, required=False, type='path', aliases=['virtual_env']),
|
||||||
|
|
||||||
apps=dict(default=None, required=False),
|
apps=dict(default=None, required=False),
|
||||||
cache_table=dict(default=None, required=False),
|
cache_table=dict(default=None, required=False),
|
||||||
|
@ -244,7 +244,7 @@ def main():
|
||||||
)
|
)
|
||||||
|
|
||||||
command = module.params['command']
|
command = module.params['command']
|
||||||
app_path = os.path.expanduser(module.params['app_path'])
|
app_path = module.params['app_path']
|
||||||
virtualenv = module.params['virtualenv']
|
virtualenv = module.params['virtualenv']
|
||||||
|
|
||||||
for param in specific_params:
|
for param in specific_params:
|
||||||
|
@ -278,7 +278,7 @@ def main():
|
||||||
if module.params[param]:
|
if module.params[param]:
|
||||||
cmd = '%s %s' % (cmd, module.params[param])
|
cmd = '%s %s' % (cmd, module.params[param])
|
||||||
|
|
||||||
rc, out, err = module.run_command(cmd, cwd=os.path.expanduser(app_path))
|
rc, out, err = module.run_command(cmd, cwd=app_path)
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
if command == 'createcachetable' and 'table' in err and 'already exists' in err:
|
if command == 'createcachetable' and 'table' in err and 'already exists' in err:
|
||||||
out = 'Already exists.'
|
out = 'Already exists.'
|
||||||
|
|
Loading…
Reference in a new issue