Software Development Kit (SDK) and API Discussions
Software Development Kit (SDK) and API Discussions
I think I have checked all the avaiable document/links to try to get my CDOT 9.4 Sim working with Ansible. I can't run any ansible command or playbook to NetApp.
My Netapp: CDOT 9.4 Sim or 9.1P6 (same issue)
My Ansible: I have copied all the netapp related file from /usr/lib/python2.7/site-packages/ansible to home/ansible/.ansible/plugins.
[ansible@hklsap14 netapp]$ ansible --version
ansible 2.6.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/ansible/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /bin/ansible
python version = 2.7.5 (default, Aug 2 2016, 04:20:16) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]
I have create the ssh pairs so I can ssh to CDOT without issue:
[ansible@hklsap14 netapp]$ ssh 10.69.6.121 version
NetApp Release 9.4: Fri Jun 08 22:50:12 UTC 2018
See the Ansible error:'
[ansible@hklsap14 netapp]$ ansible -m na_ontap_svm -a "name=ansibleVServer root_volume=vol1 root_volume_aggregate=aggr0_sgfasdr101_01 root_volume_security_style=ntfs" netapp -vvv
ansible 2.6.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/ansible/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /bin/ansible
python version = 2.7.5 (default, Aug 2 2016, 04:20:16) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]
Using /etc/ansible/ansible.cfg as config file
Parsed /etc/ansible/hosts inventory source with ini plugin
META: ran handlers
<10.69.6.121> ESTABLISH SSH CONNECTION FOR USER: None
<10.69.6.121> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/ansible/.ansible/cp/089fc91cf5 10.69.6.121 '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''
<10.69.6.121> (255, '\x07\r\nError: "/bin/sh" is not a recognized command\r\n\r\n', '')
10.69.6.121 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: ",
"unreachable": true
}
[ansible@hklsap14 netapp]$ ansible-playbook main.yml -vvvv
ansible-playbook 2.6.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/ansible/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /bin/ansible-playbook
python version = 2.7.5 (default, Aug 2 2016, 04:20:16) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
Parsed /etc/ansible/hosts inventory source with ini plugin
ERROR! Syntax Error while loading YAML.
mapping values are not allowed in this context
The error appears to have been in '/home/ansible/script/playbook/netapp/main.yml': line 24, column 17, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
na_cdot_svm:
^ here
Difficult without the actual playbook - it does state you have a syntax error. But sounds like you might be trying to connect directly to ONTAP which is not how the Netapp modules work. The modules connect through Python from the Ansible machine so there's no ssh session. So the top of your playbook would look something like this:
name: ONTAP
hosts: localhost
gather_facts: no
connection: local
...and then the task calls would have the hostname, username, and password
I suggest you look at the articles on netapp.io for details on installing the latest modules, example playbooks, etc. You definitely want the new modules!
https://netapp.io/2018/05/05/ansible-support-receives-massively-expanded-ontap-modules/
https://netapp.io/2018/06/08/sample-ansible-playbook-ontap-nfs-export-provision-and-present/
https://netapp.io/2018/07/11/switching-to-ansible-from-wfa/
There's also a link at the top of the netapp.io site to join the NetApp Slack channels - for Ansible you'll want #configurationmgmt
Yes, without the playbook this is hard to check. However I can se you are trying to use a na_cdot_svm module.. these are outdated and being removed from ansible in a future release. We have a set of 33 new and improved modules that you can get with ansible 2.6 or side load from our site. See here for more information. https://netapp.io/2018/05/05/ansible-support-receives-massively-expanded-ontap-modules/
Thanks for your reply. orginally, I didn't follow the link you mentioned cause I thought all the modules should be already updated as Netapp modules has been added to Ansible release by default.
Anyway, I followed the link to download updated module. Same result. I tried both na_ontap_svm and na_cdot_svm modeule. Here is the YMAL file:
---
- name: Sample Playbook
hosts: netapp
gather_facts: no
connection: local
vars:
netapp_hostname: 1.1.1.1 # Your hostname
netapp_username: admin # Username
netapp_password: 123456 # Password
tasks:
- name: Create SVM
na_cdot_svm:
state: present
name: ansibleVServer
root_volume: vol1
root_volume_aggregate: aggr0_sgfasdr101_01
root_volume_security_style: mixed
hostname: "{{ netapp_hostname }}"
username: "{{ netapp_username }}"
password: "{{ netapp_password }}"
the hosts: netapp line needs to be changed to hosts: localhost. The host connection is called out in the task configuration, however you are asking ansible to do a test ahead of time that ONTAP is not able to do being it doens't have the sh shell that ansible will look for.
Even I changed it to localhost, still had the issue. After several times attampt, it turned out to be related to indentention. I am new to ansible and also python. So had no experience for the syntax.