-
Notifications
You must be signed in to change notification settings - Fork 341
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
VMware: add new module vmware_host_iscsi #224
VMware: add new module vmware_host_iscsi #224
Conversation
8f5a1bc
to
a65060c
Compare
recheck |
recheck |
The CI issue seems to be legit:
|
f348dc1
to
7d1787d
Compare
recheck |
2 similar comments
recheck |
recheck |
Hi @sky-joker, the govcsim tests are broken. I'm working on that. |
recheck |
3 similar comments
recheck |
recheck |
recheck |
fix: ansible-collections#159 fix flake8 F401 error add prepare of integration test for iSCSI task fix block syntax error add changelog file
e2f28a4
to
44888be
Compare
@@ -0,0 +1,2 @@ | |||
minor_changes: | |||
- vmware_host_iscsi - new code module for a new feature for manage the iSCSI configuration of ESXi host |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest instead: a new module for the ESXi hosts that is dedicated to the management of the iSCSI configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your suggestions.
I have fixed :)
@@ -0,0 +1,50 @@ | |||
# Test code for the vmware_host_logbundle module. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vmware_host_logbundle
-> vmware_host_iscsi
, but I don't think need the header anyway since it's error prone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed the header, should I remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah it's fine.
password: "{{ vcenter_password }}" | ||
validate_certs: no | ||
esxi_hostname: "{{ esxi1 }}" | ||
state: disabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add some assert
to validate the results?
address: 100.64.0.2 | ||
state: absent | ||
|
||
- vmware_host_iscsi: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, this reset the host to its initial state. Can you call the task from always
section. This way, we will be sure we restore the test environment after a failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sky-joker can you address this comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your comment.
I've removed a rest_iscsi_config_tasks.yml
, and I have moved the tests that weren't duplicated in reset_iscsi_config_tasks.yml
to iscsi_module_test_tasks.ym
So, the playbook for the reset process is no longer needed.
I'm sorry if the answer is not what you expected.
- vmk0 | ||
vmhba_name: "{{ vmhba_name }}" | ||
send_target: | ||
address: 100.64.0.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a but confused because you call the file reset_iscsi_config_tasks.yml
, but you actually set some new configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tasks performed by reset_iscsi_config_tasks
have been moved toconnect_to_vcenter_tasks.yml
and connect_to_esxi_tasks.yml
.
Because of that, I have removed reset_iscsi_config_tasksl.yml
file.
Thank you @goneri for reviewing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are testing a new storage and I had to try to automate the deployment process. I was really happy to find this PR! (thanks @sky-joker). And I took the opportunity of the review to provide my feed back.
So consider my review more like a functional test than a code review.
- "'device' in item" | ||
- "'isSoftwareBased' in item and item.isSoftwareBased is sameas true" | ||
|
||
- include_tasks: connect_to_vcenter_tasks.yml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
connect_to_vcenter_tasks.yml
and connect_to_esxi_tasks.yml
are really similar. Maybe it could be re-factored to one file with generic variable names for the connections (hostname
, username
and password
).
- include_tasks: connect_tasks.yml
vars:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
- include_tasks: reset_iscsi_config_tasks.yml
- include_tasks: connect_tasks.yml
vars:
hostname: "{{ esxi1 }}"
username: "{{ esxi_user }}"
password: "{{ esxi_password }}"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surely this is more concise.
I'm going to combine the test files into one.
password: "{{ vcenter_password }}" | ||
validate_certs: no | ||
esxi_hostname: "{{ esxi1 }}" | ||
state: disabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I understood it, the ESXi need a reboot after disabling the iSCSI Software Adapter.
Note that I have no idea, if it's possible and/or a good idea to reboot the node and wait for host to be back in the middle of the integration tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I understood it, the ESXi need a reboot after disabling the iSCSI Software Adapter.
You're right.
But in the integration test environment, there is no target for iSCSI.
For that reason, I've decided that as long as the iSCSI settings are in ESXi, it's OK.
- config.storageDevice.hostBusAdapter | ||
register: gather_facts_host_bus_adapters_result | ||
|
||
- name: set iSCSI hba name to vmhba_name variable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not trivial to get a simple fact like a device name.
except Exception as e: | ||
self.module.fail_json(msg="Failed to remove a port bind: %s" % to_native(e)) | ||
|
||
if result['changed'] is True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be very handy to get the config returned even there was no change (except if that's a bad practice in modules).
Taking my test scenario, I use first vmware_host_iscsi
to enable the software adapter. From the register of that tasks, I get the vmhba_name
to call a second time the vmware_host_iscsi
module to set the Dynamic target for instance (see playbook snip here under). But this will fail in case the iSCSI Software adapter is already enabled as the iscsi_properties
are not returned (see the outputs here under).
An other possibility could be to provide a module like vmware_hosts_iscsi_facts
. (Note that I saw in the integration tests that you get the vmhba_name
but I don't find that handy at all)
Snip of my test playbook
- name: Enable iSCSI Software adapter on esxi nodes
vmware_host_iscsi:
hostname: "{{ ansible_host }}"
username: "{{ ansible_user }}"
password: "{{ ansible_ssh_pass }}"
esxi_hostname: "{{ ansible_host }}"
validate_certs: no
state: enabled
register: node_iscsi_adapt
delegate_to: localhost
- name: Print iscsi adapter
debug:
var: node_iscsi_adapt
- name: Configure iSCSI dynamic targets of esxi nodes
vmware_host_iscsi:
hostname: "{{ ansible_host }}"
username: "{{ ansible_user }}"
password: "{{ ansible_ssh_pass }}"
esxi_hostname: "{{ ansible_host }}"
validate_certs: no
state: present
iscsi_config:
vmhba_name: "{{ node_iscsi_adapt.iscsi_properties.vmhba_name }}"
send_target:
- address: "{{ nimble_iscsi_ip1 }}"
- address: "{{ nimble_iscsi_ip2 }}"
register: cnode_iscsi_config
delegate_to: localhost
Output on change
TASK [Enable iSCSI Software adapter on nodes] ***********************************************************************************************************************************************************************************************
Tuesday 16 June 2020 11:46:59 +0200 (0:00:02.176) 0:00:02.324 **********
changed: [node03 -> localhost]
TASK [Print iscsi adapter] *******************************************************************************************************************************************************************************************************************
Tuesday 16 June 2020 11:47:03 +0200 (0:00:03.968) 0:00:06.292 **********
ok: [node03] =>
node_iscsi_adapt:
changed: true
failed: false
iscsi_properties:
iscsi_alias: ''
iscsi_authentication_properties:
_vimtype: vim.host.InternetScsiHba.AuthenticationProperties
chapAuthEnabled: false
chapAuthenticationType: chapProhibited
chapInherited: null
chapName: ''
chapSecret: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
mutualChapAuthenticationType: chapProhibited
mutualChapInherited: null
mutualChapName: ''
mutualChapSecret: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
iscsi_enabled: true
iscsi_name: iqn.1998-01.com.vmware:node03-02f56186
iscsi_send_targets: []
iscsi_static_targets: []
port_bind: []
vmhba_name: vmhba64
Output on status 'ok'
TASK [Enable iSCSI Software adapter on nodes] ***********************************************************************************************************************************************************************************************
Tuesday 16 June 2020 11:46:08 +0200 (0:00:00.194) 0:00:00.194 **********
ok: [node01 -> localhost]
TASK [Print iscsi adapter] *******************************************************************************************************************************************************************************************************************
Tuesday 16 June 2020 11:46:11 +0200 (0:00:03.803) 0:00:03.998 **********
ok: [node01] =>
node_iscsi_adapt:
changed: false
failed: false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay :)
I'll be creating a vmware_host_iscsi_info
module (It may take some time, but ...)
ansible-collections#224 (comment) ansible-collections#224 (comment) ansible-collections#224 (comment) delete a reset_iscsi_config_tasks.yml
Thank you @xenlo for the feedback! |
recheck |
2 similar comments
recheck |
recheck |
ready_for_review |
@@ -0,0 +1,50 @@ | |||
# Test code for the vmware_host_logbundle module. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah it's fine.
address: 100.64.0.2 | ||
state: absent | ||
|
||
- vmware_host_iscsi: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sky-joker can you address this comment?
Thank you @sky-joker for your contribution :-). |
Thank you @goneri :) |
VMware: add new module vmware_host_iscsi Reviewed-by: https://github.com/apps/ansible-zuul
Depends-On: ansible/ansible-zuul-jobs#563
SUMMARY
This PR adds a module that Manages iSCSI config of ESXi.
fix: #159
ISSUE TYPE
COMPONENT NAME
vmware_host_iscsi
ADDITIONAL INFORMATION
tested with vCenter6.7/ESXi6.7