#How to run nodeshell commands without using na_ontap_command module

1 messages · Page 1 of 1 (latest)

gray ingot
#

Hello!

Can we continue to use na_ontap_command module in future ONTAP releases or should I convert below task to na_ontap_rest_cli or na_ontap_restit modules? if so, need some help in converting from na_ontap_command. Thank you for the help!

  • name: Update aggregate nosnap
    na_ontap_command:
    command: ['node', 'run', '-node', "{{ item.node }}", '-command',
    'aggr', 'options', "{{ item.aggregate }}", 'nosnap', 'on']
    <<: *clusterlogin
    with_items: "{{ aggr_options }}"
    when: aggr_options is defined
    tags:
    - nosnap
limpid spruce
#

No. 9.12.1 will be the final version to support ZAPI. na_ontap_command will not work with 9.13 or later version. This is why we recommend to use REST for any new playbook if you using a recent version of ONTAP.

#

From the REST API documentation The REST API also does not support CLI commands that create a new shell (like "run" and "vserver context").

So no, this is not possible with na_ontap_rest_cli. For desperate cases, we have na_ontap_ssh. It can run commands over SSH.

But you should have to use systemshell to configure any ONTAP feature. Or you should open a support case.

gray ingot
#

ok that was my understanding as well w/re to support for na_ontap_command module so want to get this converted to REST supported modules. Let me try na_ontap_ssh module and see if this works.

#

Ok, I used na_ontap_ssh module the play seems to completed fine but the change on node didn't happen. Sharing playbook and output of the playbook run. I'm not sure what's missing in the playbook. Any help will be appreciated.

  • name: Run command to set nosnap on aggr
    na_ontap_ssh_command:
    command: 'node run -node {{ item.node }} -command aggr options {{ item.aggregate }} nosnap off'
    <<: *login
    with_items: "{{ aggr_options }}"
    register: result
    when: aggr_options is defined
    tags:
    - nosnap

changed: [localhost] => (item={'node': 'test-nas-n09', 'aggregate': 'aggr0_n09'}) => changed=true
ansible_loop_var: item
invocation:
module_args:
accept_unknown_host_keys: false
cert_filepath: null
command: node run -node test-nas-n09 -command aggr options aggr0_n09 nosnap off
exclude_lines: ''
feature_flags: null
force_ontap_version: null
hostname: test-nas
http_port: null
https: true
include_lines: ''
key_filepath: null
ontapi: null
password: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
privilege: null
service_processor: false
use_rest: auto
username: admin
validate_certs: false
item:
aggregate: aggr0_n09
node: test-nas-n09
stderr: ''
stderr_lines: <omitted>
stdout: |2-

Last login time: 1/17/2023 09:15:59
Unsuccessful login attempts since last login: 1

stdout_lines: <omitted>
stdout_lines_filtered: []

limpid spruce
#

It worked for me. You should see some output changed: [localhost] => {"changed": true, "stderr": "", "stderr_lines": [], "stdout": "\nLast login time: 1/17/2023 18:23:06\n1 entry was acted on.\n\nNode: laurentn-test-create-1-01\n\n", "stdout_lines": ["", "Last login time: 1/17/2023 18:23:06", "1 entry was acted on.", "", "Node: laurentn-test-create-1-01", ""], "stdout_lines_filtered": ["1 entry was acted on.", "Node: laurentn-test-create-1-01"]}

#

Maybe you could try without a loop first.

gray ingot
#

Ok sure will try and let you know. Thanks @limpid spruce

gray ingot
#

@limpid spruce Its working fine now. It was something to do with test cluster and I was to successfully test it on another cluster. I'll go ahead and use na_ontap_ssh_command for all my nodeshell commands that are currently using na_ontap_command as this is supported beyond ONTAP 9.12.1