#Service-policy creation isn't working

1 messages · Page 1 of 1 (latest)

quartz light
#

Hello! I'm getting below error message when creating service policy
Error:
fatal: [localhost]: FAILED! => changed=false
invocation:
module_args:
additional_services: null
cert_filepath: null
feature_flags: null
force_ontap_version: null
hostname: test-nas
http_port: null
https: true
ipspace: null
key_filepath: null
known_services:
- cluster_core
- intercluster_core
- management_core
- management_autosupport
- management_bgp
- management_ems
- management_https
- management_http
- management_ssh
- management_portmap
- data_core
- data_nfs
- data_cifs
- data_flexcache
- data_iscsi
- data_s3_server
- data_dns_server
- data_fpolicy_client
- management_ntp_client
- management_dns_client
- management_ad_client
- management_ldap_client
- management_nis_client
- management_snmp_server
- management_rsh_server
- management_telnet_server
- management_ntp_server
- data_nvme_tcp
- backup_ndmp_control
name: test_policy
ontapi: null
password: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
scope: null
services:
- management_core
- management_autosupport
- management_ssh
- management_https
- management_portmap
- management_ems
state: present
use_rest: auto
username: admin
validate_certs: false
vserver: test-nas
msg: 'Error in create_service_policy: calling: network/ip/service-policies: got {''message'': ''Service policy cannot be created because SVM "test-nas" does not exist.'', ''code'': ''53281941'', ''target'': ''svm.name''}.'

gaunt crescent
#

Is there a vserver called test-nas on the host?

quartz light
#

yes

#

ONTAP: 9.8P11
Collections: netapp.ontap 22.2.0
Playbook:

  • name: Create service policy
    netapp.ontap.na_ontap_service_policy:
    state: present
    name: "{{ service_policy_name }}"
    services:
    - management_core
    - management_autosupport
    - management_ssh
    - management_https
    - management_portmap
    - management_ems
    vserver: "{{ cluster }}"
    <<: *login
#

vars:
username: admin
cluster: test-nas
hostname: test-nas

service_policy_name: test_policy

gaunt crescent
#

can you double check, that error message is coming directly from ONTAP it self telling us there is no SVM called test-nas on the host you've given

misty atlas
#

is test-nas a vserver or cluster name?
If its cluster name, vserver should be omitted to create service policy at cluster level

quartz light
#

The service policy I'm creating is at cluster level

#

I tried having scope: cluster and it didn't work either

misty atlas
#

can you try without setting vserver

#

cluster is assumed is vserver is not set

quartz light
#

It errored out saying it needs either ipspace or vserver listed.

quartz light
misty atlas
quartz light
#

there is no ipspace parameter in ontap 9.8

misty atlas
#

any error if used ipspace?

quartz light
#

what should list for ipspace?

misty atlas
#

usually its Default
ipspace: Default

#

or network ipspace show command to get the test-nas cluster ipspace.

quartz light
#

using ipspace default

#

worked

#
  • name: Create service policy
    netapp.ontap.na_ontap_service_policy:
    state: present
    name: "{{ service_policy_name }}"
    services:
    - management_core
    - management_autosupport
    - management_ssh
    - management_https
    - management_portmap
    - management_ems
    ipspace: Default
    <<: *login
quartz light
#

since allowed addresses doesn't support REST, I should be using restcli to get this configured correct?

#
  • name: Add allowed addresses to management ssh service
    netapp.ontap.na_ontap_rest_cli:
    command: 'network/interface/service-policy'
    verb: PATCH
    params: {'policy': "{{ service_policy_name }}", 'service': 'management-ssh'}
    body: {'allowed-addresses': "{{ allowed_addresses }}"}
    <<: *login
#

does the playbook code look ok?

quartz light
#

getting below error for the above playbook code

#

fatal: [localhost]: FAILED! => changed=false
msg: 'Error: {''message'': ''Invalid JSON input. Expecting "allowed-addresses" to be an array.'', ''code'': ''262254'', ''target'': ''allowed-addresses''}'

distant raptor
#

"{{ allowed_addresses }}"} should be a list, not a string. What do you have in the variable?

quartz light
#

list of ip address

#

allowed_addresses: 10.10.10.0/24 (example ip address)

distant raptor
#

Can you try: body: {'allowed-addresses': ["{{ allowed_addresses }}"]}
You need to build the JSON.

quartz light
#

ok let me try

#

I can add only one subnet but if i want to add more subnets then it errors out with below error
fatal: [localhost]: FAILED! => changed=false
msg: 'Error: {''message'': ''failed to set field "allowed-addresses[0]" to "10.10.10.0/24, 11.11.11.0./24"'', ''code'': ''2'', ''target'': ''allowed-addresses[0]''}'

#

allowed_addresses: 10.10.10.0/24, 11.11.11.0/24

distant raptor
#

You have an extra dot in the second address. Though the message indicates the first.

#

But I see the issue. Maybe:
"[{{ allowed_addresses }}]"

quartz light
#

thats the typo when i sent this message out as i want to hide the actual addresses.

distant raptor
#

It's a JSON formatting issue

#

It sees 10.10.10.0/24, 11.11.11.0./24 as a single string, not a list of strings.

quartz light
#

yes, any ideas on getting this work?

distant raptor
#

Start with
body: {'allowed-addresses': ["10.10.10.0/24", "11.11.11.0./24"]}
and once that works, switch to using variables

quartz light
#

ok sure

#

It works fine with how its listed above but I need to use allowed addresses to be a variable entry as we have multiple subnets that needs to be applied based on geo location of the cluster

distant raptor
#

There is a to_json filter in Ansible. I have not used it, but this may be what you need here.

quartz light
#

ok thanks @distant raptor

quartz light
#

using to_json and from_json i was able to figure this out. Thank you for your help and feedback @distant raptor