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

ansible_pkg_mgr is "unknown" on OpenBSD since 2.4 #30623

Closed
sparunakian opened this issue Sep 20, 2017 · 5 comments · Fixed by #30725
Closed

ansible_pkg_mgr is "unknown" on OpenBSD since 2.4 #30623

sparunakian opened this issue Sep 20, 2017 · 5 comments · Fixed by #30725
Assignees
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bsd BSD community bug This issue/PR relates to a bug. c:module_utils/facts needs_info This issue requires further information. Please answer any outstanding questions. packaging Packaging category support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Milestone

Comments

@sparunakian
Copy link
Contributor

Hi,

ISSUE TYPE
  • Bug Report
COMPONENT NAME

Facts

ANSIBLE VERSION
ansible 2.4.0.0
  config file = /home/stephane/.ansible.cfg
  configured module search path = [u'/home/stephane/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.13 (default, Jul 21 2017, 03:24:34) [GCC 7.1.1 20170630]
CONFIGURATION
ANSIBLE_SSH_CONTROL_PATH(/home/stephane/.ansible.cfg) = %(directory)s/%%h-%%r
ANSIBLE_SSH_PIPELINING(/home/stephane/.ansible.cfg) = True
CACHE_PLUGIN(/home/stephane/.ansible.cfg) = jsonfile
CACHE_PLUGIN_CONNECTION(/home/stephane/.ansible.cfg) = ~/.cache/ansible/
CACHE_PLUGIN_TIMEOUT(/home/stephane/.ansible.cfg) = 39600
DEFAULT_GATHERING(/home/stephane/.ansible.cfg) = smart
DEFAULT_HOST_LIST(/home/stephane/.ansible.cfg) = [u'/home/stephane/ansible/inventory']
DEFAULT_LOG_PATH(/home/stephane/.ansible.cfg) = /tmp/ansible.log
DEFAULT_ROLES_PATH(/home/stephane/.ansible.cfg) = [u'/home/stephane/ansible/roles']
DEFAULT_SQUASH_ACTIONS(/home/stephane/.ansible.cfg) = ['apk', 'apt', 'dnf', 'homebrew', 'pacman', 'pkgng', 'yum', 'zypper']
DEFAULT_VAULT_PASSWORD_FILE(/home/stephane/.ansible.cfg) = /home/stephane/ansible/scripts/get_vault_password.sh
RETRY_FILES_ENABLED(/home/stephane/.ansible.cfg) = False
OS / ENVIRONMENT

Ansible running from ArchLinux, managing an OpenBSD machine.

SUMMARY

Since Ansible 2.4, the ansible_pkg_mgr fact is set to unknown, instead of openbsd_pkg (<= Ansible 2.3.2.0). As the package module uses this variable to choose the package manager to invoke, it became unusable on OpenBSD.

STEPS TO REPRODUCE

Execute the following command with an OpenBSD machine as a target:

ansible openbsd_machine -m setup -a "filter=ansible_pkg_mgr"
EXPECTED RESULTS
openbsd_machine | SUCCESS => {
    "ansible_facts": {
        "ansible_pkg_mgr": "openbsd_pkg"
    }, 
    "changed": false
}
ACTUAL RESULTS
openbsd_machine | SUCCESS => {
    "ansible_facts": {
        "ansible_pkg_mgr": "unknown"
    }, 
    "changed": false, 
    "failed": false
}

Let me know if I can be of any help concerning this issue.

Regards

@ansibot ansibot added affects_2.4 This issue/PR affects Ansible v2.4 bug_report needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Sep 20, 2017
@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Sep 20, 2017
@bcoca
Copy link
Member

bcoca commented Sep 20, 2017

cc @alikins

@alikins
Copy link
Contributor

alikins commented Sep 20, 2017

@sparunakian What does the 'ansible_system' fact end up being set to? The pkg_mgr fact collection code has a special case for ansible_system='OpenBSD' to set pkg_mgr='openbsd_pkg'

If you can provide the full output of 'ansible openbsd_machine -m setup.py' (all of the facts without filters) that may be useful.

When you use the 'package' module, how does it fail? If possible, please provide a copy of the output from running with verbosity set to '-vvv' or higher (either 'ansible' or 'ansible-playbook' against a host showing the problem, whichever is easier)

@alikins alikins added the needs_info This issue requires further information. Please answer any outstanding questions. label Sep 20, 2017
@alikins alikins self-assigned this Sep 20, 2017
@alikins alikins added this to the 2.4.0 milestone Sep 20, 2017
@alikins
Copy link
Contributor

alikins commented Sep 20, 2017

My suspicion is this is related to the order the facts are collected in, and that 'ansible_system' may not be known when the pkg_mgr fact is collected. There is currently no explicit partial ordering for the facts collection so the ordering may be random which could cause the 'ansible_system' to be unknown when pkg_mgr is determined. If thats the case, I need to go ahead and implement some ordering to the collectors to generally fix this.

@bcoca
Copy link
Member

bcoca commented Sep 20, 2017

also dependencies, since now you can avoid collecting 'platform' information

bcoca added a commit to bcoca/ansible that referenced this issue Sep 22, 2017
this allows for proper dependencies on facts already collected
fixes ansible#30753
fixes ansible#30623
alikins added a commit that referenced this issue Sep 22, 2017
* Fix pkg_mgr fact on OpenBSD

Add a OpenBSDPkgMgrFactCollector that hardcodes pkg_mgr
to 'openbsd_pkg'. The ansible collector will choose the
OpenBSD collector if the system is OpenBSD and the 'Generic'
one otherwise.

This removes PkgMgrFactCollectors depenency on the
'system' fact being in collected_facts, which also
avoids ordering issues (if the pkg mgr fact is collected
before the system fact...)

Fixes #30623

(cherry picked from commit 12404f4)
alikins added a commit that referenced this issue Sep 22, 2017
* Fix pkg_mgr fact on OpenBSD

Add a OpenBSDPkgMgrFactCollector that hardcodes pkg_mgr
to 'openbsd_pkg'. The ansible collector will choose the
OpenBSD collector if the system is OpenBSD and the 'Generic'
one otherwise.

This removes PkgMgrFactCollectors depenency on the
'system' fact being in collected_facts, which also
avoids ordering issues (if the pkg mgr fact is collected
before the system fact...)

Fixes #30623
@sparunakian
Copy link
Contributor Author

Thank you for the fix, it works fine now on devel! Are your requests in #30623 (comment) still required? I did not have time to do that before, but I can do it now.

alikins added a commit that referenced this issue Sep 28, 2017
* Fix fact failures cause by ordering of collectors

Some fact collectors need info collected by other facts.
(for ex, service_mgr needs to know 'ansible_system').
This info is passed to the Collector.collect method via
the 'collected_facts' info.

But, the order the fact collectors were running in is
not a set order, so collectors like service_mgr could
run before the PlatformFactCollect ('ansible_system', etc),
so the 'ansible_system' fact would not exist yet. 

Depending on the collector and the deps, this can result
in incorrect behavior and wrong or missing facts.

To make the ordering of the collectors more consistent
and predictable, the code that builds that list is now
driven by the order of collectors in default_collectors.py,
and the rest of the code tries to preserve it.

* Flip the loops when building collector names

iterate over the ordered default_collectors list
selecting them for the final list in order instead
of driving it from the unordered collector_names set.

This lets the list returned by select_collector_classes
to stay in the same order as default_collectors.collectors

For collectors that have implicit deps on other fact collectors,
the default collectors can be ordered to include those early.

* default_collectors.py now uses a handful of sub lists of
collectors that can be ordered in default_collectors.collectors.

fixes #30753
fixes #30623
alikins added a commit that referenced this issue Sep 28, 2017
* Fix fact failures cause by ordering of collectors

Some fact collectors need info collected by other facts.
(for ex, service_mgr needs to know 'ansible_system').
This info is passed to the Collector.collect method via
the 'collected_facts' info.

But, the order the fact collectors were running in is
not a set order, so collectors like service_mgr could
run before the PlatformFactCollect ('ansible_system', etc),
so the 'ansible_system' fact would not exist yet.

Depending on the collector and the deps, this can result
in incorrect behavior and wrong or missing facts.

To make the ordering of the collectors more consistent
and predictable, the code that builds that list is now
driven by the order of collectors in default_collectors.py,
and the rest of the code tries to preserve it.

* Flip the loops when building collector names

iterate over the ordered default_collectors list
selecting them for the final list in order instead
of driving it from the unordered collector_names set.

This lets the list returned by select_collector_classes
to stay in the same order as default_collectors.collectors

For collectors that have implicit deps on other fact collectors,
the default collectors can be ordered to include those early.

* default_collectors.py now uses a handful of sub lists of
collectors that can be ordered in default_collectors.collectors.

fixes #30753
fixes #30623

(cherry picked from commit 95abc1d)
prasadkatti pushed a commit to prasadkatti/ansible that referenced this issue Oct 1, 2017
* Fix pkg_mgr fact on OpenBSD

Add a OpenBSDPkgMgrFactCollector that hardcodes pkg_mgr
to 'openbsd_pkg'. The ansible collector will choose the
OpenBSD collector if the system is OpenBSD and the 'Generic'
one otherwise.

This removes PkgMgrFactCollectors depenency on the
'system' fact being in collected_facts, which also
avoids ordering issues (if the pkg mgr fact is collected
before the system fact...)

Fixes ansible#30623
prasadkatti pushed a commit to prasadkatti/ansible that referenced this issue Oct 1, 2017
* Fix fact failures cause by ordering of collectors

Some fact collectors need info collected by other facts.
(for ex, service_mgr needs to know 'ansible_system').
This info is passed to the Collector.collect method via
the 'collected_facts' info.

But, the order the fact collectors were running in is
not a set order, so collectors like service_mgr could
run before the PlatformFactCollect ('ansible_system', etc),
so the 'ansible_system' fact would not exist yet. 

Depending on the collector and the deps, this can result
in incorrect behavior and wrong or missing facts.

To make the ordering of the collectors more consistent
and predictable, the code that builds that list is now
driven by the order of collectors in default_collectors.py,
and the rest of the code tries to preserve it.

* Flip the loops when building collector names

iterate over the ordered default_collectors list
selecting them for the final list in order instead
of driving it from the unordered collector_names set.

This lets the list returned by select_collector_classes
to stay in the same order as default_collectors.collectors

For collectors that have implicit deps on other fact collectors,
the default collectors can be ordered to include those early.

* default_collectors.py now uses a handful of sub lists of
collectors that can be ordered in default_collectors.collectors.

fixes ansible#30753
fixes ansible#30623
BondAnthony pushed a commit to BondAnthony/ansible that referenced this issue Oct 5, 2017
* Fix pkg_mgr fact on OpenBSD

Add a OpenBSDPkgMgrFactCollector that hardcodes pkg_mgr
to 'openbsd_pkg'. The ansible collector will choose the
OpenBSD collector if the system is OpenBSD and the 'Generic'
one otherwise.

This removes PkgMgrFactCollectors depenency on the
'system' fact being in collected_facts, which also
avoids ordering issues (if the pkg mgr fact is collected
before the system fact...)

Fixes ansible#30623
BondAnthony pushed a commit to BondAnthony/ansible that referenced this issue Oct 5, 2017
* Fix fact failures cause by ordering of collectors

Some fact collectors need info collected by other facts.
(for ex, service_mgr needs to know 'ansible_system').
This info is passed to the Collector.collect method via
the 'collected_facts' info.

But, the order the fact collectors were running in is
not a set order, so collectors like service_mgr could
run before the PlatformFactCollect ('ansible_system', etc),
so the 'ansible_system' fact would not exist yet. 

Depending on the collector and the deps, this can result
in incorrect behavior and wrong or missing facts.

To make the ordering of the collectors more consistent
and predictable, the code that builds that list is now
driven by the order of collectors in default_collectors.py,
and the rest of the code tries to preserve it.

* Flip the loops when building collector names

iterate over the ordered default_collectors list
selecting them for the final list in order instead
of driving it from the unordered collector_names set.

This lets the list returned by select_collector_classes
to stay in the same order as default_collectors.collectors

For collectors that have implicit deps on other fact collectors,
the default collectors can be ordered to include those early.

* default_collectors.py now uses a handful of sub lists of
collectors that can be ordered in default_collectors.collectors.

fixes ansible#30753
fixes ansible#30623
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bsd BSD community bug This issue/PR relates to a bug. c:module_utils/facts needs_info This issue requires further information. Please answer any outstanding questions. packaging Packaging category support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants