Common data in psd1 to avoid duplication

Tagged: 

This topic contains 3 replies, has 3 voices, and was last updated by Profile photo of Arie H Arie H 2 months, 2 weeks ago.

  • Author
    Posts
  • #54287
    Profile photo of
    Anonymous

    I have five nodes in my psd1 and all five node I need a key. Right now I have the key and value in all five nodes.
    Is there any way I can put this key in a common place and access in the individual nodes.

    Below is the example psd1. Here I have to provide value of ArcherAPIUserPasswd is all the node. I want to put this value in a common place and refer it in the individual nodes. How do I achieve this? Please node that I do not want to remove ArcherAPIUserPasswd from individual nodes.

    @{
    AllNodes= @(
                       @{
                          NodeName = "*" 
                                        
    		        
                         }
    
                        @{
    		         
    		         NodeName = "ArchrDvAOCWeb1"                
    		         Role  = "ClmOnlineWebServer"
                             ArcherAPIUser = "TsApiUser1"
    			 ArcherAPIUserPasswd = "MyPAssword1"
                             
                          }
    
    		    @{
    		         
    		         NodeName = "ArchrDvAOCWeb2"                
    		         Role  = "ClmOnlineWebServer"
                             ArcherAPIUser = "TsApiUser1"
    			 ArcherAPIUserPasswd = "MyPAssword1"
                             
                          }
    			@{
    		         
    		         NodeName = "ArchrDvAOCWeb1"                
    		         Role  = "ClmOnlineWebServer"
                             ArcherAPIUser = "TsApiUser1"
    			 ArcherAPIUserPasswd = "MyPAssword1"
                             
                          }
    			@{
    		         
    		         NodeName = "ArchrDvAOCWeb1"                
    		         Role  = "ClmOnlineWebServer"
                             ArcherAPIUser = "TsApiUser1"
    			 ArcherAPIUserPasswd = "MyPAssword1"
    		        
                          }
    
    
    )
    
  • #54288
    Profile photo of Nitin Gupta
    Nitin Gupta
    Participant

    I am not sure I understood your question, can you can elaborate a bit more?
    In general you can put the information shared across the nodes under section 'NodeName = "*"' without making any modification to your ps1 file. Node can override this value. An example to share common username across all nodes which is overridden by some nodes:

    @{
    AllNodes= @(
                       @{
                          NodeName = "*" 
                          ArcherAPIUser = "TsApiUser1"            
    		        
                         }
    
                        @{
    		         
    		         NodeName = "ArchrDvAOCWeb1"                
    		         Role  = "ClmOnlineWebServer"
    			 ArcherAPIUserPasswd = "MyPAssword1"
                             
                          }
    
    		    @{
    		         
    		         NodeName = "ArchrDvAOCWeb2"                
    		         Role  = "ClmOnlineWebServer"
    			 ArcherAPIUserPasswd = "MyPAssword1"
                             ArcherAPIUser = "TsApiUser2"
                             
                          }
    			@{
    		         
    		         NodeName = "ArchrDvAOCWeb1"                
    		         Role  = "ClmOnlineWebServer"
    			 ArcherAPIUserPasswd = "MyPAssword1"
                             ArcherAPIUser = "TsApiUser1"
                             
                          }
    			@{
    		         
    		         NodeName = "ArchrDvAOCWeb1"                
    		         Role  = "ClmOnlineWebServer"
    			 ArcherAPIUserPasswd = "MyPAssword1"
                             ArcherAPIUser = "TsApiUser3"
    		        
                          }
    
    
    )
    
    • This reply was modified 2 months, 2 weeks ago by Profile photo of Nitin Gupta Nitin Gupta.
  • #54293
    Profile photo of
    Anonymous

    I understand settings under NodeName = "*" will be accessible across all nodes.
    I want to access these values in same psd1 file.
    something like below. I want to have all common settings under one hash table and then refer it in individual nodes.

     @{
    		         
    		         NodeName = "ArchrDvAOCWeb2"                
    		         Role  = "ClmOnlineWebServer"
    			 ArcherAPIUserPasswd = <>
                             ArcherAPIUser = "TsApiUser2"
                             
                          }
    
  • #54294
    Profile photo of Arie H
    Arie H
    Participant

    As Nitin showed in the example he gave, everything that is under the "*" section will be done for all nodes that follow.

    You dont have to "reference" it in the node itself.

    If a for a specific node you dont want one of the keys to have that "general" value, you can set a different value on that specific node and it will overwrite what comes from the "*" section.

    So combining Nitin example and your code, you get this:

    @{
    AllNodes= @(
                  @{
                      NodeName = "*"
                      ArcherAPIUser = "TsApiUser1"
                      ArcherAPIUserPasswd = "MyPAssword1" 
                    }
    
                  @{
    		          NodeName = "ArchrDvAOCWeb1"                
    		          Role  = "ClmOnlineWebServer"
                   }
    
      		      @{
    		         
    		          NodeName = "ArchrDvAOCWeb2"                
    		          Role  = "ClmOnlineWebServer"
                   }
    			
                  @{
                      NodeName = "ArchrDvAOCWeb3"                
    		          Role  = "ClmOnlineWebServer"
                   }
    			  
                  @{
    		          NodeName = "ArchrDvAOCWeb4"                
    		          Role  = "ClmOnlineWebServer"
                              ArcherAPIUser = "TsApiUser2"
                              ArcherAPIUserPasswd = "MyPAssword2"
                   }
    )}
    

    Note the fourth node, I wanted to use a different user and password for example.

    • This reply was modified 2 months, 2 weeks ago by Profile photo of Arie H Arie H.
    • This reply was modified 2 months, 2 weeks ago by Profile photo of Arie H Arie H.

You must be logged in to reply to this topic.