mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Do domain resolution for portal (#461)
* Do domain resolution for portal iscsiadm support domain resolution (ex: iscsiadm -m discovery -t sendtargets -p iscsi.chiehmin.com). However, open_iscsi module will try to match the portal with discovered results which will never matched cause the discovered results use IP to represent node. This patch do portal DNS resolution first to solve this situation. Signed-off-by: Chieh-Min Wang <chiehminw@synology.com> * Update changelogs/fragments/461-resolve-domain-for-iscsi-portal.yml Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
This commit is contained in:
parent
48409f6584
commit
2aa84f07f1
2 changed files with 17 additions and 2 deletions
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- open_iscsi - allow ``portal`` parameter to be a domain name by resolving the portal ip address beforehand (https://github.com/ansible-collections/community.general/pull/461).
|
|
@ -21,7 +21,7 @@ requirements:
|
|||
options:
|
||||
portal:
|
||||
description:
|
||||
- The IP address of the iSCSI target.
|
||||
- The domain name or IP address of the iSCSI target.
|
||||
type: str
|
||||
aliases: [ ip ]
|
||||
port:
|
||||
|
@ -72,11 +72,17 @@ options:
|
|||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Perform a discovery on sun.com and show available target nodes
|
||||
open_iscsi:
|
||||
show_nodes: yes
|
||||
discover: yes
|
||||
portal: sun.com
|
||||
|
||||
- name: Perform a discovery on 10.1.2.3 and show available target nodes
|
||||
open_iscsi:
|
||||
show_nodes: yes
|
||||
discover: yes
|
||||
portal: 10.1.2.3
|
||||
ip: 10.1.2.3
|
||||
|
||||
# NOTE: Only works if exactly one target is exported to the initiator
|
||||
- name: Discover targets on portal and login to the one available
|
||||
|
@ -98,6 +104,7 @@ EXAMPLES = r'''
|
|||
|
||||
import glob
|
||||
import os
|
||||
import socket
|
||||
import time
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
@ -270,6 +277,12 @@ def main():
|
|||
|
||||
# parameters
|
||||
portal = module.params['portal']
|
||||
if portal:
|
||||
try:
|
||||
portal = socket.getaddrinfo(portal, None)[0][4][0]
|
||||
except socket.gaierror:
|
||||
module.fail_json(msg="Portal address is incorrect")
|
||||
|
||||
target = module.params['target']
|
||||
port = module.params['port']
|
||||
login = module.params['login']
|
||||
|
|
Loading…
Reference in a new issue