1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ansible で yum module が動かなくなった

Posted at

特定のホストだけ yum module が動かなくなってて困ってた

local
$ ansible HOST002 -i hosts/hosts-dir/ -m yum -a "name=vim" -C
HOST002 | FAILED! => {
    "changed": false,
    "failed": true,
    "msg": "python2 bindings for rpm are needed for this module. python2 yum module is needed for this  module"
}

調べても「yum ないんじゃね?(on Ubuntu)」ばかりで途方にくれていたが、結局 pyenv で入れた python を指定してしまっていただけだった。

local
$ ansible remote-servers -i hosts/hosts-dir/ -m shell -b -a "python --version"
HOST003 | SUCCESS | rc=0 >> ←動いてるほう
Python 2.6.6

HOST002 | SUCCESS | rc=0 >> ←動かないほう
Python 2.7.11

過去の自分がヤンチャした形跡

remote
$ sudo ls -l /usr/bin/python
lrwxrwxrwx 1 root root 29  9月 21 12:15 2017 /usr/bin/python -> /usr/local/pyenv/shims/python

これをシステムデフォルトの python (python 2.6.6) に戻したら動いた

remote
$ sudo cp /usr/bin/python2.6 /usr/bin/python
local
$ ansible HOST002 -i hosts/hosts-dir/ -m yum -a "name=vim" -C
HOST002 | SUCCESS => {
    "changed": false,
    "msg": "",
    "rc": 0,
    "results": [
        "vim-enhanced-2:7.2.411-1.8.el6.x86_64 providing vim is already installed"
    ]
}

多分 pyenv で入れた python でも yum に繋がるようにできれば解決するんだろうけど、どうすればいいのかはよく分からないままだった……
それか Ansible で起動される python のパスを直接指定できれば解決するか

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?