smartos_image_facts: rename to smartos_image_info (#60915)

* Rename smartos_image_facts -> smartos_image_info

* Add changelog.
This commit is contained in:
Felix Fontein 2019-08-27 22:43:10 +02:00 committed by Sloane Hertel
parent e176023c6b
commit 2db4e044ab
5 changed files with 36 additions and 12 deletions

View file

@ -0,0 +1,3 @@
minor_changes:
- The ``smartos_image_facts`` module has been renamed to ``smartos_image_info``.
When called with the new name, the module no longer returns ``ansible_facts``.

View file

@ -453,6 +453,9 @@ be removed in Ansible 2.13. Please update update your playbooks accordingly.
To access return values, :ref:`register a variable <registered_variables>`. To access return values, :ref:`register a variable <registered_variables>`.
* The ``redshift_facts`` module was renamed to :ref:`redshift_info <redshift_info_module>`. * The ``redshift_facts`` module was renamed to :ref:`redshift_info <redshift_info_module>`.
* The ``route53_facts`` module was renamed to :ref:`route53_info <route53_info_module>`. * The ``route53_facts`` module was renamed to :ref:`route53_info <route53_info_module>`.
* The ``smartos_image_facts`` module was renamed to :ref:`smartos_image_info <ali_instance_info_module>`.
When called with the new name, the module no longer returns ``ansible_facts``.
To access return values, :ref:`register a variable <registered_variables>`.
* The ``vertica_facts`` module was renamed to :ref:`vertica_info <vertica_info_module>`. * The ``vertica_facts`` module was renamed to :ref:`vertica_info <vertica_info_module>`.
When called with the new name, the module no longer returns ``ansible_facts``. When called with the new name, the module no longer returns ``ansible_facts``.
To access return values, :ref:`register a variable <registered_variables>`. To access return values, :ref:`register a variable <registered_variables>`.

View file

@ -0,0 +1 @@
smartos_image_info.py

View file

@ -15,11 +15,12 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: smartos_image_facts module: smartos_image_info
short_description: Get SmartOS image details. short_description: Get SmartOS image details.
description: description:
- Retrieve facts about all installed images on SmartOS. Facts will be - Retrieve information about all installed images on SmartOS.
inserted to the ansible_facts key. - This module was called C(smartos_image_facts) before Ansible 2.9, returning C(ansible_facts).
Note that the M(smartos_image_info) module no longer returns C(ansible_facts)!
version_added: "2.2" version_added: "2.2"
author: Adam Števko (@xen0l) author: Adam Števko (@xen0l)
options: options:
@ -32,22 +33,31 @@ options:
''' '''
EXAMPLES = ''' EXAMPLES = '''
# Return facts about all installed images. # Return information about all installed images.
- smartos_image_facts: - smartos_image_info:
register: result
# Return all private active Linux images. # Return all private active Linux images.
- smartos_image_facts: filters="os=linux state=active public=false" - smartos_image_info: filters="os=linux state=active public=false"
register: result
# Show, how many clones does every image have. # Show, how many clones does every image have.
- smartos_image_facts: - smartos_image_info:
register: result
- debug: msg="{{ smartos_images[item]['name'] }}-{{smartos_images[item]['version'] }} - debug: msg="{{ result.smartos_images[item]['name'] }}-{{ result.smartos_images[item]['version'] }}
has {{ result.smartos_images[item]['clones'] }} VM(s)"
with_items: "{{ result.smartos_images.keys() | list }}"
# When the module is called as smartos_image_facts, return values are published
# in ansible_facts['smartos_images'] and can be used as follows.
# Note that this is deprecated and will stop working in Ansible 2.13.
- debug: msg="{{ smartos_images[item]['name'] }}-{{ smartos_images[item]['version'] }}
has {{ smartos_images[item]['clones'] }} VM(s)" has {{ smartos_images[item]['clones'] }} VM(s)"
with_items: "{{ smartos_images.keys() }}" with_items: "{{ smartos_images.keys() | list }}"
''' '''
RETURN = ''' RETURN = '''
# this module returns ansible_facts
''' '''
import json import json
@ -95,12 +105,19 @@ def main():
), ),
supports_check_mode=False, supports_check_mode=False,
) )
is_old_facts = module._name == 'smartos_image_facts'
if is_old_facts:
module.deprecate("The 'smartos_image_facts' module has been renamed to 'smartos_image_info', "
"and the renamed one no longer returns ansible_facts", version='2.13')
image_facts = ImageFacts(module) image_facts = ImageFacts(module)
data = dict(smartos_images=image_facts.return_all_installed_images()) data = dict(smartos_images=image_facts.return_all_installed_images())
module.exit_json(ansible_facts=data) if is_old_facts:
module.exit_json(ansible_facts=data)
else:
module.exit_json(**data)
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -2045,7 +2045,7 @@ lib/ansible/modules/cloud/scaleway/_scaleway_volume_facts.py validate-modules:E3
lib/ansible/modules/cloud/scaleway/scaleway_volume_info.py validate-modules:E338 lib/ansible/modules/cloud/scaleway/scaleway_volume_info.py validate-modules:E338
lib/ansible/modules/cloud/smartos/imgadm.py validate-modules:E317 lib/ansible/modules/cloud/smartos/imgadm.py validate-modules:E317
lib/ansible/modules/cloud/smartos/imgadm.py validate-modules:E338 lib/ansible/modules/cloud/smartos/imgadm.py validate-modules:E338
lib/ansible/modules/cloud/smartos/smartos_image_facts.py validate-modules:E338 lib/ansible/modules/cloud/smartos/smartos_image_info.py validate-modules:E338
lib/ansible/modules/cloud/smartos/vmadm.py validate-modules:E322 lib/ansible/modules/cloud/smartos/vmadm.py validate-modules:E322
lib/ansible/modules/cloud/smartos/vmadm.py validate-modules:E324 lib/ansible/modules/cloud/smartos/vmadm.py validate-modules:E324
lib/ansible/modules/cloud/smartos/vmadm.py validate-modules:E326 lib/ansible/modules/cloud/smartos/vmadm.py validate-modules:E326