LoginSignup
10
4

More than 3 years have passed since last update.

Amazon Linux で ansible がdnfを推し始めて困ってます

Posted at

ネットのスレを見るとansible2.8から dnf 推しになっている模様
回避方法として set_factにてdnfではなくyumを使うように強制せよとの事
えーansible_facts とか使ったことないんだけど。巷にもこの件情報無いし..試してみるか

設定前

   - name: Yum update packages
     yum: name=* state=latest
     become: yes

実行結果

TASK [Yum update packages] ************************************************************************************************************************************* 
fatal: [xxxxx]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": false, "cmd": "dnf install -y python2-dnf", "msg": "[Errno 2] No such file or directory", "rc": 2}

/var/log/secure を見ても確かにdnf 実行してるぽい

May 27 08:37:41 ec sudo:   xxx: ... /usr/bin/python ... tmp/ansible-tmp-1558913860.05-16888652605385/AnsiballZ_dnf.py

/usr/local/bin/dnf から /usr/bin/yum にリンク、程度の小賢しい手は通用しなかったので...まあ悪手ですしね。
ネットの有識者様が言われるがままPlaybookにset_fact設定を追加してみる

 tasks:
   - set_fact:
       ansible_facts:
         pkg_mgr: yum
   - name: Yum update packages
     yum: name=* state=latest
     become: yes

実行結果

TASK [Yum update packages] *************************************************************************************************************************************
ok: [xxxxx]

おおぅ...logでもyum実行するように変更されたぽい

May 29 15:21:09 ec sudo:   xxx: ... /usr/bin/python ... tmp/ansible-tmp-1559110868.54-279035084250927/AnsiballZ_yum.py
10
4
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
10
4