-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
Update nxos_install_os module #40102
Update nxos_install_os module #40102
Conversation
@@ -0,0 +1,15 @@ | |||
--- |
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.
@trishnaguha I added this because as you know this is what we have to do for tasks to execute successfully following an upgrade. It's commented out in the actual call flow (see install_os.yaml
below) but I decided to include it for users that might make use of it.
data = module.params.get('provider') | ||
import os | ||
command_timer = os.environ.get('ANSIBLE_PERSISTENT_COMMAND_TIMEOUT') | ||
connect_timer = os.environ.get('ANSIBLE_PERSISTENT_CONNECT_TIMEOUT') |
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.
@mikewiebe this will only work if command_timeout/connect_timeout is set as ENV var, but won't work if someone sets the timeout in ansible.cfg within persistent_connection
section.
You can do the following instead.
+
+from ansible import constants as C
from ansible.module_utils.network.nxos.nxos import load_config, run_commands
from ansible.module_utils.network.nxos.nxos import nxos_argument_spec, check_args
from ansible.module_utils.basic import AnsibleModule
@@ -131,6 +133,8 @@ from ansible.module_utils.basic import AnsibleModule
def check_ansible_timer(module):
'''Check Ansible Timer Values'''
+ command_timer = C.PERSISTENT_COMMAND_TIMEOUT
+ connect_timer = C.PERSISTENT_CONNECT_TIMEOUT
This takes care of both the scenarios.
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.
Excellent. Thanks for the suggestion.
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" | ||
|
||
- name: run test cases (connection=network_cli) | ||
include: "{{ test_case_to_run }} ansible_connection=network_cli connection={}" |
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.
There's your problem, replace connection={}
with connection={{ cli }}
(or, again, anything really, as long as it's a dictionary) and #40027 will go away
(see #40027 (comment) for more info)
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.
Thanks. Will update.
The test
The test
The test
The test
The test
|
@trishnaguha Looks like ansibot does not like the |
@@ -124,25 +124,24 @@ | |||
|
|||
import re | |||
from time import sleep | |||
from ansible import constants as C |
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.
Imports from ansible
are not available to modules. Imports must be from ansible.module_utils
.
msg = msg + 'provider: "{{ connection | combine({\'timeout\': 500}) }}"' | ||
data = module.params.get('provider') | ||
command_timer = C.PERSISTENT_COMMAND_TIMEOUT | ||
connect_timer = C.PERSISTENT_CONNECT_TIMEOUT |
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.
These will need to be module parameters if they need to be configurable. Constants are not available to modules.
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.
@mattclay I am simply trying to make sure that users are setting the ANSIBLE_ PERSISTENT_COMMAND_TIMEOUT and ANSIBLE_ PERSISTENT_CONNECT_TIMEOUT high enough to be used with this module. This module controls Nexus upgrades so these need to be set in a way to avoid timeout issues. Can I change these timers inside an Ansible module directly? I thought that they were checked/used before we get to the module code.
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.
Modules do not have access to get or set configuration values. An action plugin should be able to check the configuration before invoking the module, but I don't think that is something we're doing with any other modules currently. You may want to bring this up in tomorrow's Network Working Group meeting on IRC to see what thoughts the network team has on this.
@mikewiebe Apologies for suggesting importing constants. |
@mikewiebe As discussed with @Qalthos, on addition to adding notes in module doc, you can check timer in nxos action plugin. I hope this will help you to achieve what you are trying to do in the module.
|
d78974c
to
69ed6c9
Compare
@trishnaguha I am done making the updates here. There are still issues with upgrading using connection type I added a layer of tests so that we can still run tests using |
1dff6ce
to
da22aa2
Compare
The module will exit with a failure message if the timer is | ||
not set to 500 seconds or higher. | ||
- This module requires both the ANSIBLE_PERSISTENT_CONNECT and | ||
ANSIBLE_PERSISTENT_COMMAND timers to be set to 600 seconds or higher. |
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.
Can you please change the env vars to ANSIBLE_PERSISTENT_COMMAND_TIMEOUT
and ANSIBLE_PERSISTENT_CONNECT_TIMEOUT
instead?
cherry-picked to 2.6 |
* Add nxos_install_os integration tests * Update call to check timers * Update check_ansible_timer method * Modify network_cli integration tests * Add timer check for nxos_install_os * Add comments for clear_persistent_sockets * Update connection info for tests * More updates * Restructure files for provider and non-provider testing * Update env var name and add check for ISSU switchover (cherry picked from commit 9f02630)
* httpapi fix nxos (#40806) * httpapi fix nxos Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * nxos_hsrp fix Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> (cherry picked from commit a7421e8) * fix nxos_vrf and migrate get_interface_type to module_utils (#40825) Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> (cherry picked from commit b4baa2d) * nxos_vlan fix (#40822) * nxos_vlan fix Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * uncomment mode test as nxapi now has get_capabilities Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> (cherry picked from commit 17b6ecf) * Update nxos_install_os module (#40102) * Add nxos_install_os integration tests * Update call to check timers * Update check_ansible_timer method * Modify network_cli integration tests * Add timer check for nxos_install_os * Add comments for clear_persistent_sockets * Update connection info for tests * More updates * Restructure files for provider and non-provider testing * Update env var name and add check for ISSU switchover (cherry picked from commit 9f02630)
* Add nxos_install_os integration tests * Update call to check timers * Update check_ansible_timer method * Modify network_cli integration tests * Add timer check for nxos_install_os * Add comments for clear_persistent_sockets * Update connection info for tests * More updates * Restructure files for provider and non-provider testing * Update env var name and add check for ISSU switchover
* Add nxos_install_os integration tests * Update call to check timers * Update check_ansible_timer method * Modify network_cli integration tests * Add timer check for nxos_install_os * Add comments for clear_persistent_sockets * Update connection info for tests * More updates * Restructure files for provider and non-provider testing * Update env var name and add check for ISSU switchover
SUMMARY
This update includes the following:
check_ansible_timer
method inside the module to make sure bothANSIBLE_PERSISTENT_COMMAND_TIMEOUT
andANSIBLE_PERSISTENT_CONNECTION_TIMEOUT
are set properly when using this module.local
,network_cli
andnxapi
.meta: end_play
has been added in the maininstall_os.yaml
playbook.ISSUE TYPE
COMPONENT NAME
nxos_install_os
ANSIBLE VERSION