From 119b6d73dd6a8d240fd9f3190189389818fbdeae Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Fri, 11 Oct 2013 08:45:13 -0400 Subject: [PATCH] Remove examples of module antipattern of setting the choices array for boolean types. --- library/cloud/digital_ocean | 4 ++-- library/cloud/linode | 2 +- library/cloud/rax | 2 +- library/cloud/rax_clb | 2 +- library/cloud/route53 | 2 +- library/net_infrastructure/dnsmadeeasy | 2 -- library/notification/mqtt | 2 +- library/packaging/yum | 3 +-- library/packaging/zypper | 2 +- library/system/group | 2 +- library/system/service | 2 +- library/system/user | 2 +- library/web_infrastructure/htpasswd | 2 +- 13 files changed, 13 insertions(+), 16 deletions(-) diff --git a/library/cloud/digital_ocean b/library/cloud/digital_ocean index cd485aedf9..54aee3c0df 100644 --- a/library/cloud/digital_ocean +++ b/library/cloud/digital_ocean @@ -373,8 +373,8 @@ def main(): region_id = dict(type='int'), ssh_key_ids = dict(default=''), id = dict(aliases=['droplet_id'], type='int'), - unique_name = dict(type='bool', choices=BOOLEANS, default='no'), - wait = dict(type='bool', choices=BOOLEANS, default='yes'), + unique_name = dict(type='bool', default='no'), + wait = dict(type='bool', default=True), wait_timeout = dict(default=300, type='int'), ssh_pub_key = dict(type='str'), ), diff --git a/library/cloud/linode b/library/cloud/linode index 555bfebea8..8c71e55f65 100644 --- a/library/cloud/linode +++ b/library/cloud/linode @@ -444,7 +444,7 @@ def main(): password = dict(type='str'), ssh_pub_key = dict(type='str'), swap = dict(type='int', default=512), - wait = dict(type='bool', choices=BOOLEANS, default=True), + wait = dict(type='bool', default=True), wait_timeout = dict(default=300), ) ) diff --git a/library/cloud/rax b/library/cloud/rax index 7596b6ab72..997a7a28b6 100644 --- a/library/cloud/rax +++ b/library/cloud/rax @@ -247,7 +247,7 @@ def main(): key_name = dict(aliases = ['keypair']), files = dict(type='dict', default={}), region = dict(), - wait = dict(type='bool', choices=BOOLEANS), + wait = dict(type='bool'), wait_timeout = dict(default=300), ) ) diff --git a/library/cloud/rax_clb b/library/cloud/rax_clb index 32736f8b60..9b850e9c81 100644 --- a/library/cloud/rax_clb +++ b/library/cloud/rax_clb @@ -196,7 +196,7 @@ def main(): type=dict(choices=['primary', 'secondary']), username=dict(), virtualenv=dict(), - wait=dict(default=False, choices=BOOLEANS, type='bool'), + wait=dict(default=False, type='bool'), wait_timeout=dict(default=30, type='int'), weight=dict(type='int'), ), diff --git a/library/cloud/route53 b/library/cloud/route53 index e5f23c1a3e..f279a1390b 100644 --- a/library/cloud/route53 +++ b/library/cloud/route53 @@ -155,7 +155,7 @@ def main(): value = dict(required=False), aws_secret_key = dict(aliases=['ec2_secret_key', 'secret_key'], no_log=True, required=False), aws_access_key = dict(aliases=['ec2_access_key', 'access_key'], required=False), - overwrite = dict(required=False, choices=BOOLEANS, type='bool') + overwrite = dict(required=False, type='bool') ) ) diff --git a/library/net_infrastructure/dnsmadeeasy b/library/net_infrastructure/dnsmadeeasy index a08855ca81..4fc341926d 100644 --- a/library/net_infrastructure/dnsmadeeasy +++ b/library/net_infrastructure/dnsmadeeasy @@ -263,8 +263,6 @@ def main(): 'A', 'AAAA', 'CNAME', 'HTTPRED', 'MX', 'NS', 'PTR', 'SRV', 'TXT']), record_value=dict(required=False), record_ttl=dict(required=False, default=1800, type='int'), - #redirecttype=dict(required=False,default='Hidden Frame Masked',choices=[ 'Hidden Frame Masked', 'Standard 301', 'Standard 302' ]), - #hardlink=dict(requred=False, default=False, type='bool', choices=BOOLEANS) ), required_together=( ['record_value', 'record_ttl', 'record_type'] diff --git a/library/notification/mqtt b/library/notification/mqtt index 5e25e66843..26a5f43019 100644 --- a/library/notification/mqtt +++ b/library/notification/mqtt @@ -144,7 +144,7 @@ def main(): payload = dict(required = True), client_id = dict(default = None), qos = dict(default="0", choices=["0", "1", "2"]), - retain = dict(default='no', choices=BOOLEANS, type='bool'), + retain = dict(default=False, type='bool'), username = dict(default = None), password = dict(default = None), ), diff --git a/library/packaging/yum b/library/packaging/yum index b7dd5029d4..cc801564cf 100644 --- a/library/packaging/yum +++ b/library/packaging/yum @@ -711,8 +711,7 @@ def main(): disablerepo=dict(), list=dict(), conf_file=dict(default=None), - disable_gpg_check=dict(required=False, default="no", - choices=BOOLEANS, type='bool'), + disable_gpg_check=dict(required=False, default="no", type='bool'), ), required_one_of = [['name','list']], mutually_exclusive = [['name','list']], diff --git a/library/packaging/zypper b/library/packaging/zypper index c2e1c95c79..ae6efbb230 100644 --- a/library/packaging/zypper +++ b/library/packaging/zypper @@ -177,7 +177,7 @@ def main(): argument_spec = dict( name = dict(required=True, aliases=['pkg']), state = dict(required=False, default='present', choices=['absent', 'installed', 'latest', 'present', 'removed']), - disable_gpg_check = dict(required=False, default='no', choices=BOOLEANS, type='bool'), + disable_gpg_check = dict(required=False, default='no', type='bool'), ), supports_check_mode = False ) diff --git a/library/system/group b/library/system/group index a4f68cd7fe..2b19fab18b 100644 --- a/library/system/group +++ b/library/system/group @@ -341,7 +341,7 @@ def main(): state=dict(default='present', choices=['present', 'absent'], type='str'), name=dict(required=True, type='str'), gid=dict(default=None, type='str'), - system=dict(default='no', choices=['yes', 'no'], type='bool'), + system=dict(default=False, type='bool'), ), supports_check_mode=True ) diff --git a/library/system/service b/library/system/service index 75c791dd88..b21d3f508d 100644 --- a/library/system/service +++ b/library/system/service @@ -1108,7 +1108,7 @@ def main(): state = dict(choices=['running', 'started', 'stopped', 'restarted', 'reloaded']), sleep = dict(required=False, type='int', default=None), pattern = dict(required=False, default=None), - enabled = dict(choices=BOOLEANS, type='bool'), + enabled = dict(type='bool'), runlevel = dict(required=False, default='default'), arguments = dict(aliases=['args'], default=''), ), diff --git a/library/system/user b/library/system/user index fe13cd6048..9dbc330586 100644 --- a/library/system/user +++ b/library/system/user @@ -1372,7 +1372,7 @@ def main(): # following options are specific to usermod append=dict(default='no', type='bool'), # following are specific to ssh key generation - generate_ssh_key=dict(choices=BOOLEANS, type='bool'), + generate_ssh_key=dict(type='bool'), ssh_key_bits=dict(default=ssh_defaults['bits'], type='str'), ssh_key_type=dict(default=ssh_defaults['type'], type='str'), ssh_key_file=dict(default=None, type='str'), diff --git a/library/web_infrastructure/htpasswd b/library/web_infrastructure/htpasswd index a634fb6273..3de636d376 100644 --- a/library/web_infrastructure/htpasswd +++ b/library/web_infrastructure/htpasswd @@ -178,7 +178,7 @@ def main(): password=dict(required=False, default=None), crypt_scheme=dict(required=False, default=None), state=dict(required=False, default="present"), - create=dict(type='bool', choices=BOOLEANS, default='yes'), + create=dict(type='bool', default='yes'), ) module = AnsibleModule(argument_spec=arg_spec,