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

Macports not recognized as package manager on OSX #31485

Closed
rdbisme opened this issue Oct 9, 2017 · 7 comments · Fixed by #31491
Closed

Macports not recognized as package manager on OSX #31485

rdbisme opened this issue Oct 9, 2017 · 7 comments · Fixed by #31491
Assignees
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bug This issue/PR relates to a bug. module This issue/PR relates to a module. python3 support:community This issue/PR relates to code supported by the Ansible community.

Comments

@rdbisme
Copy link

rdbisme commented Oct 9, 2017

ISSUE TYPE
  • Bug Report
COMPONENT NAME

macports, package modules

ANSIBLE VERSION
ansible 2.4.0.0
  config file = /Users/***/Dotfiles/ansible/ansible.cfg
  configured module search path = ['/Users/***/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/***/.envs/ansible/lib/python3.5/site-packages/ansible
  executable location = /Users/***/.envs/ansible/bin/ansible
  python version = 3.5.3 (default, Apr 23 2017, 18:09:27) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]

CONFIGURATION
DEFAULT_HOST_LIST(/Users/***/Dotfiles/ansible/ansible.cfg) = ['/Users/***/Dotfiles/ansible/hosts']
DEFAULT_ROLES_PATH(/Users/***/Dotfiles/ansible/ansible.cfg) = ['/Users/rubendibattista/Dotfiles/ansible/roles']
DEFAULT_STDOUT_CALLBACK(/Users/***/Dotfiles/ansible/ansible.cfg) = debug
OS / ENVIRONMENT

OSX 10.12.6

SUMMARY

When running a task using the package module, macports does not get recognized and the error Could not detect which package manager to use. Try gathering facts or setting the "use" option. is returned.

STEPS TO REPRODUCE

ansible-playbook pkg.yml

pkg.yml

- hosts: localhost
  tasks: 
    - name: Test Package
      package: 
        name: zsh
        state: present
      become: true
ansible localhost -m setup | grep pkg
        "ansible_pkg_mgr": "macports",
EXPECTED RESULTS

Ansible uses the macports module to install packages

ACTUAL RESULTS

Ansible raise an error not recognizing the installed macports as the right package manager to use

PLAY [localhost] ***********************************************************************************************************************************************************************************************

TASK [Gathering Facts] *****************************************************************************************************************************************************************************************
ok: [localhost]

TASK [Test Package] ********************************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {
    "changed": false,
    "failed": true
}

MSG:

Could not detect which package manager to use. Try gathering facts or setting the "use" option.

        to retry, use: --limit @/Users/rubendibattista/Dotfiles/ansible/pkg.retry

PLAY RECAP *****************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1
@sivel
Copy link
Member

sivel commented Oct 9, 2017

I believe the cause to your problem is in that you are not specifying a password to use with become

Due to some unknown reason, it looks like ansible cannot find ansible_pkg_mgr and is attempting to re-run setup.

You have supplied become: true, and this applies to the additional setup task as well, and ansible fails due to needing a sudo password.

Try adding --ask-become-pass and re-running this playbook.

needs_info

@sivel
Copy link
Member

sivel commented Oct 9, 2017

This shouldn't be happening though, at least not manifesting itself in this specific way. It looks as though #22849 broke using pre gathered facts, which forces the module to always fall back on a second setup run.

@ansibot
Copy link
Contributor

ansibot commented Oct 9, 2017

@ansibot ansibot added affects_2.4 This issue/PR affects Ansible v2.4 bug_report module This issue/PR relates to a module. needs_info This issue requires further information. Please answer any outstanding questions. python3 support:community This issue/PR relates to code supported by the Ansible community. labels Oct 9, 2017
@sivel
Copy link
Member

sivel commented Oct 9, 2017

cc @bcoca

Not sure why #22849 was done, but seems to be breaking the templating in package for getting the ansible_pkg_mgr, it always falls back to re-running setup.

Additionally, when re-running setup fails here with 'module_stdout': 'sudo: a password is required\r\n', we probably need to indicate that, as right now we swallow it, and get an ambiguous error.

@sivel sivel removed the needs_info This issue requires further information. Please answer any outstanding questions. label Oct 9, 2017
@rdbisme
Copy link
Author

rdbisme commented Oct 9, 2017

@sivel Correct. It was the password! (I recently switched laptop and in the other one I had sudo without password).

Sorry for the dumb problem...

@sivel
Copy link
Member

sivel commented Oct 9, 2017

Not a dumb problem really. It uncovered 2 potential bugs, or at least 1 bug and 1 place where we can do better.

@bcoca bcoca added this to TODO: Blocker in 2.4.x Blocker List Oct 9, 2017
bcoca added a commit to bcoca/ansible that referenced this issue Oct 9, 2017
@bcoca bcoca self-assigned this Oct 9, 2017
@abadger abadger reopened this Oct 9, 2017
abadger pushed a commit that referenced this issue Oct 9, 2017
@abadger
Copy link
Contributor

abadger commented Oct 9, 2017

Reopened as only one of the two issues uncovered by this was fixed. We'll need a new test case, though, as the user-visible problem should now be gone.

@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
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 bug This issue/PR relates to a bug. module This issue/PR relates to a module. python3 support:community This issue/PR relates to code supported by the Ansible community.
Projects
No open projects
2.4.x Blocker List
Done in 2.4.1
Development

Successfully merging a pull request may close this issue.

5 participants