The transition to NetApp MS Azure AD B2C is complete. If you missed the pre-registration, you will be invited to register at next log in.
Please note that access to your NetApp data may take up to 1 hour.
To learn more, read the FAQ and watch the video.
Need assistance? Complete this form and select “Registration Issue” as the Feedback Category.

Active IQ Unified Manager Discussions

Function / command to append data to config files (rc, hosts...)?

solal

Hi guys.

are you aware of / used before a function or command to append new data to configuration files (i.e like /etc/usermap.cfg and /etc/passwd) in WFA?

Thanks in advance,

Solal.

1 ACCEPTED SOLUTION

arndt

I wrote a command to add an SSH publickey to a 7 Mode storage system, and I used API calls that just append to a file to get this done:

https://communities.netapp.com/docs/DOC-29903

You could copy the above command and modify it to meet your needs.  Hope that helps,

Mike

View solution in original post

6 REPLIES 6

arndt

I wrote a command to add an SSH publickey to a 7 Mode storage system, and I used API calls that just append to a file to get this done:

https://communities.netapp.com/docs/DOC-29903

You could copy the above command and modify it to meet your needs.  Hope that helps,

Mike

View solution in original post

solal

Thanks guys.

I got another example from Anatoly that really helped as well:

You can use ONTAP toolkit cmdlets Read-NcDirectory, Read-NcFile, Write-NcFile inside the command in WFA in order to do it

Example:

# connect to controller

Get-WFALogger -Info -message $("Connecting to " + $Cluster)

Connect-WfaCluster $Cluster

Read-NcDirectory -Path /vol/vs1_root/.vsadmin/config/etc -VserverContext vs1

Read-NcFile -Path /vol/vs1_root/.vsadmin/config/etc/master.passwd -VserverContext vs1

$data = "nobody2:*:65535:65535::::::"

Write-NcFile -Path /vol/vs1_root/.vsadmin/config/etc/master.passwd -Data $data -Append -VserverContext vs1

solal

That's my final one that works in a workflow:

param (

  [parameter(Mandatory=$true, HelpMessage="Array name or IP address")]

  [string]$Array,

  [parameter(Mandatory=$true, HelpMessage="Full path to filer or vfiler requested file, example: hosts")]

  [string]$FilePath,

  [parameter(Mandatory=$true, HelpMessage="New Line to enter to the configuration file. One line at a time.")]

  [string]$LineEntered

)

# connect to controller

Connect-WfaController -Array $Array

$rootvol=Get-NaVolRoot

$fullpath="/vol/" + $rootvol.Name + "/etc/" + $FilePath

# Write the line to the file.

Write-NaFile -Path $fullpath -Append -Data $("`n" + "$LineEntered" + "`n")

   # End of Command

Vinu

Hi Solal,

 

 

I am not able to append data in configuration files like as /etc/rc, /etc/hosts, /etc/exports...etc,    i am trying to go through your attachment but it is not opening .

 

So please tell me how can i append data in files.

 

Is there any command for copying and creating files and directories like as cp and mkdir?

 

 

Regards

 

Vinod

sinhaa

Thanks for sharing Solal. Very useful information.

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

adaikkap

Hi Solal,

     Can you elaborate on what you are trying to do and why you need this ? This may help understand the need better and propose other solutions as well.

Regards

adai

Announcements
NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner
Public