Use common file argument system previously implemented by @sivel for rax modules on the file modules as well (copy/file/template).
Application to other cloud providers would make very good sense.
This commit is contained in:
parent
7b5f89ec7c
commit
1fa19e29e8
4 changed files with 14 additions and 63 deletions
|
@ -63,17 +63,26 @@ def get_docstring(filename, verbose=False):
|
||||||
else:
|
else:
|
||||||
fragment_name, fragment_var = fragment_slug, 'DOCUMENTATION'
|
fragment_name, fragment_var = fragment_slug, 'DOCUMENTATION'
|
||||||
|
|
||||||
fragment_class = utils.plugins.fragment_loader.get(fragment_name)
|
|
||||||
if fragment_class:
|
if fragment_slug != 'doesnotexist':
|
||||||
|
fragment_class = utils.plugins.fragment_loader.get(fragment_name)
|
||||||
|
assert fragment_class is not None
|
||||||
|
|
||||||
fragment_yaml = getattr(fragment_class, fragment_var, '{}')
|
fragment_yaml = getattr(fragment_class, fragment_var, '{}')
|
||||||
fragment = yaml.safe_load(fragment_yaml)
|
fragment = yaml.safe_load(fragment_yaml)
|
||||||
|
|
||||||
if fragment.has_key('notes'):
|
if fragment.has_key('notes'):
|
||||||
notes = fragment.pop('notes')
|
notes = fragment.pop('notes')
|
||||||
if notes:
|
if notes:
|
||||||
if not doc.has_key('notes'):
|
if not doc.has_key('notes'):
|
||||||
doc['notes'] = []
|
doc['notes'] = []
|
||||||
doc['notes'].extend(notes)
|
doc['notes'].extend(notes)
|
||||||
|
|
||||||
|
if 'options' not in fragment.keys():
|
||||||
|
raise Exception("missing options in fragment, possibly misformatted?")
|
||||||
|
|
||||||
for key, value in fragment.items():
|
for key, value in fragment.items():
|
||||||
|
|
||||||
if not doc.has_key(key):
|
if not doc.has_key(key):
|
||||||
doc[key] = value
|
doc[key] = value
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -83,11 +83,8 @@ options:
|
||||||
defaults.
|
defaults.
|
||||||
required: false
|
required: false
|
||||||
version_added: "1.5"
|
version_added: "1.5"
|
||||||
others:
|
|
||||||
description:
|
|
||||||
- all arguments accepted by the M(file) module also work here
|
|
||||||
required: false
|
|
||||||
author: Michael DeHaan
|
author: Michael DeHaan
|
||||||
|
extends_documentation_fragment: files.DOCUMENTATION
|
||||||
notes:
|
notes:
|
||||||
- The "copy" module recursively copy facility does not scale to lots (>hundreds) of files.
|
- The "copy" module recursively copy facility does not scale to lots (>hundreds) of files.
|
||||||
For alternative, see synchronize module, which is a wrapper around rsync.
|
For alternative, see synchronize module, which is a wrapper around rsync.
|
||||||
|
|
|
@ -33,6 +33,7 @@ DOCUMENTATION = '''
|
||||||
module: file
|
module: file
|
||||||
version_added: "historical"
|
version_added: "historical"
|
||||||
short_description: Sets attributes of files
|
short_description: Sets attributes of files
|
||||||
|
extends_documentation_fragment: files
|
||||||
description:
|
description:
|
||||||
- Sets attributes of files, symlinks, and directories, or removes
|
- Sets attributes of files, symlinks, and directories, or removes
|
||||||
files/symlinks/directories. Many other modules support the same options as
|
files/symlinks/directories. Many other modules support the same options as
|
||||||
|
@ -58,24 +59,6 @@ options:
|
||||||
required: false
|
required: false
|
||||||
default: file
|
default: file
|
||||||
choices: [ file, link, directory, hard, touch, absent ]
|
choices: [ file, link, directory, hard, touch, absent ]
|
||||||
mode:
|
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
choices: []
|
|
||||||
description:
|
|
||||||
- mode the file or directory should be, such as 0644 as would be fed to I(chmod)
|
|
||||||
owner:
|
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
choices: []
|
|
||||||
description:
|
|
||||||
- name of the user that should own the file/directory, as would be fed to I(chown)
|
|
||||||
group:
|
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
choices: []
|
|
||||||
description:
|
|
||||||
- name of the group that should own the file/directory, as would be fed to I(chown)
|
|
||||||
src:
|
src:
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: null
|
||||||
|
@ -83,34 +66,6 @@ options:
|
||||||
description:
|
description:
|
||||||
- path of the file to link to (applies only to C(state= link or hard)). Will accept absolute,
|
- path of the file to link to (applies only to C(state= link or hard)). Will accept absolute,
|
||||||
relative and nonexisting (with C(force)) paths. Relative paths are not expanded.
|
relative and nonexisting (with C(force)) paths. Relative paths are not expanded.
|
||||||
seuser:
|
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
choices: []
|
|
||||||
description:
|
|
||||||
- user part of SELinux file context. Will default to system policy, if
|
|
||||||
applicable. If set to C(_default), it will use the C(user) portion of the
|
|
||||||
policy if available
|
|
||||||
serole:
|
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
choices: []
|
|
||||||
description:
|
|
||||||
- role part of SELinux file context, C(_default) feature works as for I(seuser).
|
|
||||||
setype:
|
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
choices: []
|
|
||||||
description:
|
|
||||||
- type part of SELinux file context, C(_default) feature works as for I(seuser).
|
|
||||||
selevel:
|
|
||||||
required: false
|
|
||||||
default: "s0"
|
|
||||||
choices: []
|
|
||||||
description:
|
|
||||||
- level part of the SELinux file context. This is the MLS/MCS attribute,
|
|
||||||
sometimes known as the C(range). C(_default) feature works as for
|
|
||||||
I(seuser).
|
|
||||||
recurse:
|
recurse:
|
||||||
required: false
|
required: false
|
||||||
default: "no"
|
default: "no"
|
||||||
|
@ -118,13 +73,6 @@ options:
|
||||||
version_added: "1.1"
|
version_added: "1.1"
|
||||||
description:
|
description:
|
||||||
- recursively set the specified file attributes (applies only to state=directory)
|
- recursively set the specified file attributes (applies only to state=directory)
|
||||||
force:
|
|
||||||
required: false
|
|
||||||
default: "no"
|
|
||||||
choices: [ "yes", "no" ]
|
|
||||||
description:
|
|
||||||
- 'force the creation of the symlinks when the destination exists and is a file (so, we need to unlink the
|
|
||||||
"path" file and create symlink to the "src" file in place of it).'
|
|
||||||
notes:
|
notes:
|
||||||
- See also M(copy), M(template), M(assemble)
|
- See also M(copy), M(template), M(assemble)
|
||||||
requirements: [ ]
|
requirements: [ ]
|
||||||
|
|
|
@ -47,10 +47,6 @@ options:
|
||||||
required: false
|
required: false
|
||||||
default: ""
|
default: ""
|
||||||
version_added: "1.2"
|
version_added: "1.2"
|
||||||
others:
|
|
||||||
description:
|
|
||||||
- all arguments accepted by the M(file) module also work here, as well as the M(copy) module (except the the 'content' parameter).
|
|
||||||
required: false
|
|
||||||
notes:
|
notes:
|
||||||
- "Since Ansible version 0.9, templates are loaded with C(trim_blocks=True)."
|
- "Since Ansible version 0.9, templates are loaded with C(trim_blocks=True)."
|
||||||
|
|
||||||
|
@ -59,6 +55,7 @@ notes:
|
||||||
which changes the variable interpolation markers to [% var %] instead of {{ var }}. This is the best way to prevent evaluation of things that look like, but should not be Jinja2. raw/endraw in Jinja2 will not work as you expect because templates in Ansible are recursively evaluated."
|
which changes the variable interpolation markers to [% var %] instead of {{ var }}. This is the best way to prevent evaluation of things that look like, but should not be Jinja2. raw/endraw in Jinja2 will not work as you expect because templates in Ansible are recursively evaluated."
|
||||||
|
|
||||||
requirements: []
|
requirements: []
|
||||||
|
extends_documentation_fragment: files.DOCUMENTATION
|
||||||
author: Michael DeHaan
|
author: Michael DeHaan
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue