DexterPOSH / PSRemotely

Remote operations validation framework, exposes a DSL to wrap existing Pester/PoshSpec based validation tests.
http://psremotely.readthedocs.io/en/latest/
MIT License
46 stars 7 forks source link

ConfigurationData Connectivity via IP Address #47

Closed iainbrighton closed 7 years ago

iainbrighton commented 7 years ago

When attempting to perform tests against computers that may be in a different Active Directory domain (isolated lab environment), then name resolution may not work from PSRemotely host machine. Ideally, I would like to be able to use the source configuration document used to deploy the lab, to be used by PSRemotely to run post deployment/operational tests.

Take the following configuration as an example:

# Configuration data
$ConfigData = @{
    AllNodes = @(
        @{
            NodeName='*';
            DomainFQDN='dexter.lab';
        },
        @{
            NodeName="Compute-11";
            ServiceName = 'vmms';
            Type='Compute';
            IPAddress = '192.168.1.2';
        },
        @{
            NodeName='Storage-12';
            ServiceName = 'bits';
            Type='Storage';
            IPAddress = '192.168.1.3';
        }
    )
}

# PSRemotely tests
PSRemotely -ConfigurationData $ConfigData {
    Node $AllNodes.Where({$PSItem.Type -eq 'Compute'}).NodeName {
        Describe 'Bits Service test' {

            $Service = Get-Service -Name $node.ServiceName # See the use of $node variable here

            It "Should have a service named bits" {
                $Service | Should Not BeNullOrEmpty
            }

            it 'Should be running' {
                $Service.Status | Should be 'Running'
            }
        }       
    }
}

I would like to be able to instruct PSRemotely to connect using the node's IPAddress node parameter, not the node name. In Lability there is a -PreferNodeProperty <string> parameter (not sure that's the best name) that instructs Lability to use the node's IPAddress property and not the node's name for connectivity.

Is this something that would be of benefit to add? if so, what needs to be done to implement it?!

DexterPOSH commented 7 years ago

@iainbrighton this is a superb idea. I might have missed that aspect of Lability, (inspired by your module, we use DSC style config data 😉 ) I had to use IPv4 and IPv6 Addresses in our internal deployments and I was mostly content with using string manipulation for the node name translations.

If I remember correctly, we have a bare minimum support for specifying credentials in the node property (it follows some precedence) but this makes absolute sense.

I will assign this to me and start working on it (let me take a look at how you have implemented this). I guess you need this at the earliest 😄

Taking a look at the code and will get back on what needs to be done to add this feature.

iainbrighton commented 7 years ago

DOH! Looking at it, that functionality is only in my Labillity CI development branch. However, the idea first surfaced here https://github.com/iainbrighton/PSDEVOPS/blob/master/Get-LabStatus.ps1#L42-L53

DexterPOSH commented 7 years ago

This looks good. I have started modifying the code to support this. Will soon push the changes,

DexterPOSH commented 7 years ago

Made some progress today with this, will work on adding integration tests for the same.

DexterPOSH commented 7 years ago

@iainbrighton Pushed some code to the 'dev' branch with the prefer node property support. Need to add some more tests and documentation around it.

DexterPOSH commented 7 years ago

This looks almost complete to me after today's commit to the Dev branch. I can now go back and visit some of my tests and refactor them.

Thanks @iainbrighton for the idea, I will merge the dev branch with the master over the weekend.

DexterPOSH commented 7 years ago

@iainbrighton Pushed the v1.0.3 with the support for PreferNodeProperty to PSGallery.