Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix boolean defaults. #1343

Merged
merged 1 commit into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions plugins/doc_fragments/influxdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class ModuleDocFragment(object):
description:
- Use https instead of http to connect to InfluxDB server.
type: bool
default: false
timeout:
description:
- Number of seconds Requests will wait for client to establish a connection.
Expand All @@ -68,6 +69,7 @@ class ModuleDocFragment(object):
description:
- Use UDP to connect to InfluxDB server.
type: bool
default: false
udp_port:
description:
- UDP port to connect to InfluxDB server.
Expand Down
1 change: 1 addition & 0 deletions plugins/doc_fragments/ovirt_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class ModuleDocFragment(object):
Only the attributes of the current entity. User can configure to fetch other
attributes of the nested entities by specifying C(nested_attributes).
type: bool
default: false
nested_attributes:
description:
- Specifies list of the attributes which should be fetched from the API.
Expand Down
1 change: 0 additions & 1 deletion plugins/modules/cloud/docker/docker_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
- Deprecated. Will be removed in community.general 2.0.0. Set I(recreate) to C(options-changed) instead
for the same behavior of setting I(force) to C(yes).
type: bool
default: no

recreate:
description:
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/cloud/google/gc_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
description:
- Whether versioning is enabled or disabled (note that once versioning is enabled, it can only be suspended)
type: bool
default: false

requirements:
- "python >= 2.6"
Expand Down
1 change: 0 additions & 1 deletion plugins/modules/cloud/google/gce.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@
- if set to C(yes), instances will be preemptible and time-limited.
(requires libcloud >= 0.20.0)
type: bool
default: 'no'
disk_size:
type: int
description:
Expand Down
2 changes: 0 additions & 2 deletions plugins/modules/cloud/google/gce_pd.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
description:
- do not destroy the disk, merely detach it from an instance
type: bool
default: 'no'
instance_name:
type: str
description:
Expand Down Expand Up @@ -87,7 +86,6 @@
description:
- If C(yes), deletes the volume when instance is terminated
type: bool
default: 'no'
image_family:
type: str
description:
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/cloud/memset/memset_zone_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
choices: [ A, AAAA, CNAME, MX, NS, SRV, TXT ]
relative:
type: bool
default: false
description:
- If set then the current domain is added onto the address field for C(CNAME), C(MX), C(NS)
and C(SRV)record types.
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/cloud/ovirt/ovirt_vm_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
- "If I(true) all the attributes of the virtual machines should be
included in the response."
type: bool
default: false
case_sensitive:
description:
- "If I(true) performed search will take case into account."
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/cloud/rackspace/rax_clb.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def main():
timeout=dict(type='int', default=30),
type=dict(choices=['PUBLIC', 'SERVICENET'], default='PUBLIC'),
vip_id=dict(),
wait=dict(type='bool'),
wait=dict(type='bool', default=False),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait is passed on into cloud_load_balancer, and is there only tested for being truthy:

Therefore False and None are treated the same way.

wait_timeout=dict(type='int', default=300),
)
)
Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/cloud/rackspace/rax_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@
Private containers, if previously made public, can have live objects
available until the TTL on cached objects expires
type: bool
default: false
public:
description:
- Used to set a container as public, available via the Cloud Files CDN
type: bool
default: false
region:
type: str
description:
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/cloud/rackspace/rax_mon_alarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
- If yes, create this alarm, but leave it in an inactive state. Defaults to
no.
type: bool
default: false
metadata:
type: dict
description:
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/cloud/rackspace/rax_mon_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
description:
- If "yes", ensure the check is created, but don't actually use it yet.
type: bool
default: false
metadata:
type: dict
description:
Expand Down
1 change: 0 additions & 1 deletion plugins/modules/clustering/consul/consul_kv.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
- If the key represents a prefix, each entry with the prefix can be
retrieved by setting this to C(yes).
type: bool
default: 'no'
retrieve:
description:
- If the I(state) is C(present) and I(value) is set, perform a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
description:
- Sets the retention policy as default retention policy.
type: bool
default: false
extends_documentation_fragment:
- community.general.influxdb

Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/database/postgresql/postgresql_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def main():
name=dict(type='str', required=True),
db=dict(type='str', aliases=['login_db']),
value=dict(type='str'),
reset=dict(type='bool'),
reset=dict(type='bool', default=False),
session_role=dict(type='str'),
trust_input=dict(type='bool', default=True),
)
Expand Down
2 changes: 0 additions & 2 deletions plugins/modules/identity/ipa/ipa_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,9 @@
description:
- If set C("True") with state as C("absent"), then removes DNS records of the host managed by FreeIPA DNS.
- This option has no effect for states other than "absent".
default: false
type: bool
random_password:
description: Generate a random password to be used in bulk enrollment.
default: False
type: bool
extends_documentation_fragment:
- community.general.ipa.documentation
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/net_tools/haproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
- Continue only after the status changes to 'MAINT'.
- This overrides the shutdown_sessions option.
type: bool
default: false
host:
description:
- Name of the backend host to change.
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/packaging/os/pkgutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
- To allow the update process to downgrade packages to match what is present in the repository, set this to C(yes).
- This is useful for rolling back to stable from testing, or similar operations.
type: bool
default: false
version_added: 1.2.0
notes:
- In order to check the availability of packages, the catalog cache under C(/var/opt/csw/pkgutil) may be refreshed even in check mode.
Expand Down
1 change: 0 additions & 1 deletion plugins/modules/packaging/os/redhat_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
- Upon successful registration, auto-consume available subscriptions
- Added in favor of deprecated autosubscribe in 2.5.
type: bool
default: no
aliases: [autosubscribe]
activationkey:
description:
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/packaging/os/svr4pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
- Install/Remove category instead of a single package.
required: false
type: bool
default: false
'''

EXAMPLES = '''
Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/packaging/os/swupd.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
description:
- Updates the OS to the latest version.
type: bool
default: false
url:
description:
- Overrides both I(contenturl) and I(versionurl).
Expand All @@ -58,6 +59,7 @@
description:
- Verify content for OS version.
type: bool
default: false
versionurl:
description:
- URL for version string download.
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/storage/glusterfs/gluster_peer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
required: true
force:
type: bool
default: "false"
default: false
description:
- Applicable only while removing the nodes from the pool. gluster
will refuse to detach a node from the pool if any one of the node
Expand Down Expand Up @@ -141,7 +141,7 @@ def call_peer_commands(self):
def main():
module = AnsibleModule(
argument_spec=dict(
force=dict(type='bool', required=False),
force=dict(type='bool', required=False, default=False),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Force is only tested for truthy in

self.force = 'force' if self.module.params.get('force') else ''
, so False and None are treated the same way.

nodes=dict(type='list', required=True),
state=dict(type='str', choices=['absent', 'present'],
default='present'),
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/storage/glusterfs/gluster_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
- If brick is being created in the root partition, module will fail.
Set force to true to override this behaviour.
type: bool
default: false
notes:
- Requires cli tools for GlusterFS on servers.
- Will add new bricks, but not remove them.
Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/storage/netapp/na_cdot_license.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@
description:
- Remove licenses that have no controller affiliation in the cluster.
type: bool
default: false
felixfontein marked this conversation as resolved.
Show resolved Hide resolved

remove_expired:
description:
- Remove licenses that have expired in the cluster.
type: bool
default: false

serial_number:
description:
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/system/java_cert.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
description:
- Create keystore if it does not exist.
type: bool
default: false
keystore_type:
description:
- Keystore type (JCEKS, JKS).
Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/system/open_iscsi.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@
to manual, hence combined with C(auto_node_startup=yes) will always return
a changed state.
type: bool
default: false
show_nodes:
description:
- Whether the list of nodes in the persistent iSCSI database should be returned by the module.
type: bool
default: false
'''

EXAMPLES = r'''
Expand Down
3 changes: 3 additions & 0 deletions plugins/modules/system/puppet.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,17 @@
description:
- Whether to print a transaction summary.
type: bool
default: false
verbose:
description:
- Print extra information.
type: bool
default: false
debug:
description:
- Enable full debugging.
type: bool
default: false
requirements:
- puppet
author:
Expand Down
1 change: 0 additions & 1 deletion plugins/modules/system/svc.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
- Should a 'down' file exist or not, if it exists it disables auto startup.
Defaults to no. Downed does not imply stopped.
type: bool
default: no
enabled:
description:
- Whether the service is enabled or not, if disabled it also implies stopped.
Expand Down
3 changes: 3 additions & 0 deletions plugins/modules/system/ufw.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
description:
- Log new connections matched to this rule
type: bool
default: false
from_ip:
description:
- Source IP address.
Expand Down Expand Up @@ -120,6 +121,7 @@
description:
- Delete rule.
type: bool
default: false
interface:
description:
- Specify interface for the rule. The direction (in or out) used
Expand Down Expand Up @@ -149,6 +151,7 @@
description:
- Apply the rule to routed/forwarded packets.
type: bool
default: false
comment:
description:
- Add a comment to the rule. Requires UFW version >=0.35.
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/system/vdo.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
a new volume, and cannot be changed for an existing
volume.
type: bool
default: false
growphysical:
description:
- Specifies whether to attempt to execute a growphysical
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/web_infrastructure/django_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def main():

apps=dict(default=None, required=False),
cache_table=dict(default=None, required=False, type='str'),
clear=dict(default=None, required=False, type='bool'),
clear=dict(default=False, required=False, type='bool'),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All options in specific_boolean_params are only tested for being truthy, so None and False are teated the same way.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I think it is better to remove it, but other than that, using a default that is actually in the domain of values for the specified type does look better.

database=dict(default=None, required=False, type='str'),
failfast=dict(default=False, required=False, type='bool', aliases=['fail_fast']),
fixtures=dict(default=None, required=False, type='str'),
Expand Down