Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty string when setup / collecting facter facts #72731

Closed
arnoldy200 opened this issue Nov 26, 2020 · 6 comments
Closed

Empty string when setup / collecting facter facts #72731

arnoldy200 opened this issue Nov 26, 2020 · 6 comments
Labels
affects_2.10 This issue/PR affects Ansible v2.10 bot_closed bug This issue/PR relates to a bug. module This issue/PR relates to a module. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team. system System category

Comments

@arnoldy200
Copy link

arnoldy200 commented Nov 26, 2020

SUMMARY

ansible windows -m setup -a 'filter=env*'

[WARNING]: Error when collecting facter facts: Join-Path : Cannot bind argument to parameter 'Path' because it is an
empty string. At line:4 char:47 + $facterPath = Join-Path -Path $_ -ChildPath facter.ex ... +
~~ + CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException +
FullyQualifiedErrorId :
ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand at
, : line 4 at , : line 3

This is the code which causes the warning:

@{
    Subsets = 'facter'
    Code = {
        # Get-Command can be slow to enumerate the paths, do this ourselves
        $facterDir = $env:PATH -split ([IO.Path]::PathSeparator) | Where-Object {
            $facterPath = Join-Path -Path $_ -ChildPath facter.exe
            Test-Path -LiteralPath $facterPath
        } | Select-Object -First 1

        if ($facterDir) {
            # Get JSON from Facter, and parse it out.
            $facter = Join-Path -Path $facterDir -ChildPath facter.exe
            $facterOutput = &$facter -j
            $facts = "$facterOutput" | ConvertFrom-Json

            ForEach($fact in $facts.PSObject.Properties) {
                $ansibleFacts."facter_$($fact.Name)" = $fact.Value
            }
        }
    }
},

At line:4 char:47 is $_
Should we check empty string first?

ISSUE TYPE
  • Bug Report
COMPONENT NAME

ansible/windows/plugins/modules/setup.ps1

ANSIBLE VERSION
ansible 2.10.3
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/osboxes/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.8 (default, Nov 16 2020, 16:55:22) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
CONFIGURATION
DEFAULT_LOCAL_TMP(/etc/ansible/ansible.cfg) = /home/osboxes/.ansible/tmp/ansible-local-20337_ks78ncx
HOST_KEY_CHECKING(/etc/ansible/ansible.cfg) = False
INTERPRETER_PYTHON(/etc/ansible/ansible.cfg) = /usr/bin/python3.6
OS / ENVIRONMENT

Ansible Server:
centos-release-7-9.2009.0.el7.centos.x86_64

Windows Host:
OS: Microsoft Windows 10 Pro
Version: Version 10.0.19041.630
PowerShell Version: 5.1.19041.610
.NET Version: 4.8.04084

STEPS TO REPRODUCE

ansible windows -m setup -a 'filter=env*'


EXPECTED RESULTS
ACTUAL RESULTS

[WARNING]: Error when collecting facter facts: Join-Path : Cannot bind argument to parameter 'Path' because it is an
empty string. At line:4 char:47 + $facterPath = Join-Path -Path $_ -ChildPath facter.ex ... +
~~ + CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException +
FullyQualifiedErrorId :
ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand at
, : line 4 at , : line 3


@ansibot
Copy link
Contributor

ansibot commented Nov 26, 2020

Files identified in the description:
None

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added affects_2.10 This issue/PR affects Ansible v2.10 bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Nov 26, 2020
@ansibot
Copy link
Contributor

ansibot commented Nov 26, 2020

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added module This issue/PR relates to a module. system System category labels Nov 26, 2020
@mkrizek
Copy link
Contributor

mkrizek commented Nov 27, 2020

!component =lib/ansible/modules/windows/setup.ps1

@ansibot
Copy link
Contributor

ansibot commented Nov 27, 2020

Files identified in the description:

  • lib/ansible/modules/windows/setup.ps1

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Nov 27, 2020

Thank you very much for your interest in Ansible. Ansible has migrated much of the content into separate repositories to allow for more rapid, independent development. We are closing this issue/PR because this content has been moved to one or more collection repositories.

For further information, please see:
https://github.com/ansible/ansibullbot/blob/master/docs/collection_migration.md

@ansibot ansibot closed this as completed Nov 27, 2020
@mkrizek mkrizek removed the needs_triage Needs a first human triage before being processed. label Nov 27, 2020
@mickaeltr
Copy link

mickaeltr commented Dec 15, 2020

Hi @arnoldy200,
We are seeing the same WARNING on some servers. Did you solve this issue?
I think the related Ansible module is now hosted here: https://github.com/ansible-collections/ansible.windows/
Thanks

UPDATE: it probably comes from your PATH containing ;;, a leading or trailing ';' and it will be fixed thanks to ansible-collections/ansible.windows#160

@ansible ansible locked and limited conversation to collaborators Dec 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.10 This issue/PR affects Ansible v2.10 bot_closed bug This issue/PR relates to a bug. module This issue/PR relates to a module. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team. system System category
Projects
None yet
Development

No branches or pull requests

4 participants