1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Module consistency and make daisy chaining work with invalid arguments detection.

This commit is contained in:
Michael DeHaan 2012-08-01 00:21:36 -04:00
parent db9955d3df
commit 0a3ebdb6d5
7 changed files with 15 additions and 17 deletions

View file

@ -20,16 +20,11 @@ playbooks:
inventory: inventory:
* inventory file can use a line of the form base[beg:end]tail to define a
set of hosts, where [beg:end] defines a numerical range. 'beg' can be a
a string padded with zero(s) to the left. If so provided, it acts as
a formatting hint during hostname expansion. The hint must be confirmed
by having an 'end' that has the same length as 'beg'
* groups variable available as a hash to return the hosts in each group name * groups variable available as a hash to return the hosts in each group name
* in YAML inventory, hosts can list their groups in inverted order now also (see tests/yaml_hosts) * in YAML inventory, hosts can list their groups in inverted order now also (see tests/yaml_hosts)
* YAML inventory is deprecated and will be removed in 0.7 * YAML inventory is deprecated and will be removed in 0.7
* ec2 inventory script * ec2 inventory script
* support ranges of hosts in the host file * support ranges of hosts in the host file, like www[001-100].example.com (supports leading zeros and also not)
modules: modules:

View file

@ -31,7 +31,7 @@ def add_path_info(kwargs):
path = kwargs['path'] path = kwargs['path']
if os.path.exists(path): if os.path.exists(path):
(user, group) = user_and_group(path) (user, group) = user_and_group(path)
kwargs['user'] = user kwargs['owner'] = user
kwargs['group'] = group kwargs['group'] = group
st = os.stat(path) st = os.stat(path)
kwargs['mode'] = oct(stat.S_IMODE(st[stat.ST_MODE])) kwargs['mode'] = oct(stat.S_IMODE(st[stat.ST_MODE]))
@ -209,13 +209,10 @@ def set_mode_if_different(path, mode, changed):
def rmtree_error(func, path, exc_info): def rmtree_error(func, path, exc_info):
module_fail_json(path=path, msg='failed to remove directory') module_fail_json(path=path, msg='failed to remove directory')
# ===========================================
# go...
def main(): def main():
global module global module
module = AnsibleModule( module = AnsibleFileModule(
argument_spec = dict( argument_spec = dict(
state = dict(choices=['file','directory','link','absent'], default='file'), state = dict(choices=['file','directory','link','absent'], default='file'),
path = dict(aliases=['dest', 'name'], required=True), path = dict(aliases=['dest', 'name'], required=True),
@ -351,6 +348,12 @@ def main():
# this is magic, see lib/ansible/module_common.py # this is magic, see lib/ansible/module_common.py
#<<INCLUDE_ANSIBLE_MODULE_COMMON>> #<<INCLUDE_ANSIBLE_MODULE_COMMON>>
class AnsibleFileModule(AnsibleModule):
def _check_invalid_arguments(self):
# needed to support daisy chaining
pass
main() main()

View file

@ -142,7 +142,7 @@ def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec = dict( argument_spec = dict(
dest=dict(required=True), dest=dict(required=True),
repo=dict(required=True), repo=dict(required=True, aliases=['name']),
version=dict(default='HEAD'), version=dict(default='HEAD'),
remote=dict(default='origin') remote=dict(default='origin')
) )

View file

@ -70,7 +70,7 @@ def main():
login_user=dict(default=None), login_user=dict(default=None),
login_password=dict(default=None), login_password=dict(default=None),
login_host=dict(default="localhost"), login_host=dict(default="localhost"),
db=dict(required=True), db=dict(required=True, aliases=['name']),
encoding=dict(default=""), encoding=dict(default=""),
collation=dict(default=""), collation=dict(default=""),
state=dict(default="present", choices=["absent", "present"]), state=dict(default="present", choices=["absent", "present"]),

View file

@ -164,7 +164,7 @@ def main():
login_user=dict(default=None), login_user=dict(default=None),
login_password=dict(default=None), login_password=dict(default=None),
login_host=dict(default="localhost"), login_host=dict(default="localhost"),
user=dict(required=True), user=dict(required=True, aliases=['name']),
password=dict(default=None), password=dict(default=None),
host=dict(default="localhost"), host=dict(default="localhost"),
state=dict(default="present", choices=["absent", "present"]), state=dict(default="present", choices=["absent", "present"]),

View file

@ -57,7 +57,7 @@ def main():
login_user=dict(default="postgres"), login_user=dict(default="postgres"),
login_password=dict(default=""), login_password=dict(default=""),
login_host=dict(default=""), login_host=dict(default=""),
db=dict(required=True), db=dict(required=True, aliases=['name']),
owner=dict(default=""), owner=dict(default=""),
template=dict(default=""), template=dict(default=""),
encoding=dict(default=""), encoding=dict(default=""),

View file

@ -106,7 +106,7 @@ def main():
login_user=dict(default="postgres"), login_user=dict(default="postgres"),
login_password=dict(default=""), login_password=dict(default=""),
login_host=dict(default=""), login_host=dict(default=""),
user=dict(required=True), user=dict(required=True, aliases=['name']),
password=dict(default=None), password=dict(default=None),
state=dict(default="present", choices=["absent", "present"]), state=dict(default="present", choices=["absent", "present"]),
db=dict(required=True), db=dict(required=True),