summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--changelogs/fragments/60530-facts-info-rename.yaml2
-rw-r--r--docs/docsite/rst/porting_guides/porting_guide_2.9.rst2
-rw-r--r--lib/ansible/modules/cloud/digital_ocean/_digital_ocean_sshkey_facts.py (renamed from lib/ansible/modules/cloud/digital_ocean/digital_ocean_sshkey_facts.py)8
-rw-r--r--lib/ansible/modules/cloud/digital_ocean/digital_ocean_sshkey_info.py93
4 files changed, 104 insertions, 1 deletions
diff --git a/changelogs/fragments/60530-facts-info-rename.yaml b/changelogs/fragments/60530-facts-info-rename.yaml
new file mode 100644
index 0000000000..61c581bbe3
--- /dev/null
+++ b/changelogs/fragments/60530-facts-info-rename.yaml
@@ -0,0 +1,2 @@
+minor_changes:
+- The ``digital_ocean_sshkey_facts`` module has been deprecated. Use ``digital_ocean_sshkey_info`` instead.
diff --git a/docs/docsite/rst/porting_guides/porting_guide_2.9.rst b/docs/docsite/rst/porting_guides/porting_guide_2.9.rst
index 2b3cfed696..7bbf1685a1 100644
--- a/docs/docsite/rst/porting_guides/porting_guide_2.9.rst
+++ b/docs/docsite/rst/porting_guides/porting_guide_2.9.rst
@@ -62,6 +62,8 @@ Deprecation notices
The following modules will be removed in Ansible 2.13. Please update update your playbooks accordingly.
+* digital_ocean_sshkey_facts use :ref:`digital_ocean_sshkey_info <digital_ocean_sshkey_info_module>` instead.
+
* junos_interface use :ref:`junos_interfaces <junos_interfaces_module>` instead.
* junos_l2_interface use :ref:`junos_l2_interfaces <junos_l2_interfaces_module>` instead.
diff --git a/lib/ansible/modules/cloud/digital_ocean/digital_ocean_sshkey_facts.py b/lib/ansible/modules/cloud/digital_ocean/_digital_ocean_sshkey_facts.py
index 91721315e0..e5fd42e9e9 100644
--- a/lib/ansible/modules/cloud/digital_ocean/digital_ocean_sshkey_facts.py
+++ b/lib/ansible/modules/cloud/digital_ocean/_digital_ocean_sshkey_facts.py
@@ -9,7 +9,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
-ANSIBLE_METADATA = {'status': ['preview'],
+ANSIBLE_METADATA = {'status': ['deprecated'],
'supported_by': 'community',
'metadata_version': '1.1'}
@@ -17,6 +17,10 @@ ANSIBLE_METADATA = {'status': ['preview'],
DOCUMENTATION = '''
---
module: digital_ocean_sshkey_facts
+deprecated:
+ removed_in: '2.13'
+ why: Deprecated in favour of C(_info) module.
+ alternative: Use M(digital_ocean_sshkey_info) instead.
short_description: DigitalOcean SSH keys facts
description:
- Fetch DigitalOcean SSH keys facts.
@@ -91,6 +95,8 @@ def main():
supports_check_mode=False,
)
+ module.deprecate("The 'digital_ocean_sshkey_facts' module has been deprecated, use the new 'digital_ocean_sshkey_info' module", version='2.13')
+
core(module)
diff --git a/lib/ansible/modules/cloud/digital_ocean/digital_ocean_sshkey_info.py b/lib/ansible/modules/cloud/digital_ocean/digital_ocean_sshkey_info.py
new file mode 100644
index 0000000000..fd01924bae
--- /dev/null
+++ b/lib/ansible/modules/cloud/digital_ocean/digital_ocean_sshkey_info.py
@@ -0,0 +1,93 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# Copyright: Ansible Project
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
+
+ANSIBLE_METADATA = {'status': ['preview'],
+ 'supported_by': 'community',
+ 'metadata_version': '1.1'}
+
+
+DOCUMENTATION = '''
+---
+module: digital_ocean_sshkey_info
+short_description: Gather information about DigitalOcean SSH keys
+description:
+ - This module can be used to gather information about DigitalOcean SSH keys.
+ - This module replaces the C(digital_ocean_sshkey_facts) module.
+version_added: "2.9"
+author: "Patrick Marques (@pmarques)"
+extends_documentation_fragment: digital_ocean.documentation
+notes:
+ - Version 2 of DigitalOcean API is used.
+requirements:
+ - "python >= 2.6"
+'''
+
+
+EXAMPLES = '''
+- digital_ocean_sshkey_info:
+ oauth_token: "{{ my_do_key }}"
+ register: ssh_keys
+
+- set_fact:
+ pubkey: "{{ item.public_key }}"
+ loop: "{{ ssh_keys.data|json_query(ssh_pubkey) }}"
+ vars:
+ ssh_pubkey: "[?name=='ansible_ctrl']"
+
+- debug:
+ msg: "{{ pubkey }}"
+'''
+
+
+RETURN = '''
+# Digital Ocean API info https://developers.digitalocean.com/documentation/v2/#list-all-keys
+data:
+ description: List of SSH keys on DigitalOcean
+ returned: success and no resource constraint
+ type: dict
+ sample: [
+ {
+ "id": 512189,
+ "fingerprint": "3b:16:bf:e4:8b:00:8b:b8:59:8c:a9:d3:f0:19:45:fa",
+ "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example",
+ "name": "My SSH Public Key"
+ }
+ ]
+'''
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.digital_ocean import DigitalOceanHelper
+
+
+def core(module):
+ rest = DigitalOceanHelper(module)
+
+ response = rest.get("account/keys")
+ status_code = response.status_code
+ json = response.json
+ if status_code == 200:
+ module.exit_json(changed=False, data=json['ssh_keys'])
+ else:
+ module.fail_json(msg='Error fetching SSH Key information [{0}: {1}]'.format(
+ status_code, response.json['message']))
+
+
+def main():
+ module = AnsibleModule(
+ argument_spec=DigitalOceanHelper.digital_ocean_argument_spec(),
+ supports_check_mode=True,
+ )
+
+ core(module)
+
+
+if __name__ == '__main__':
+ main()