読者です 読者をやめる 読者になる 読者になる

ゆるふわカウンターアタック

Qiitaっぽい時はQiitaで、slideshareっぽい時はslideshareで、preziっぽい時はpreziで、ブログっぽい時はここで

Centos6でAnsibleを1から2にしたら 「ERROR! Unexpected Exception: 'AnsibleLoader' object has no attribute 'dispose'」

Ansible2をCentOS6にインスト 今までは1.9系でした

yum install python-jinja2-26 --enablerepo=epel
yum --enablerepo=epel-testing install ansible

とりあえずsudo:yesは以下にしとこう become: yes become_user: root

そしてAnsibleを1.9から2.0にしたら以下エラーが出た

[root@ansiblesvr01 ansible]# ansible-playbook -vvv test.yml -i ./hosts --check
/usr/lib64/python2.6/site-packages/pycrypto-2.6.1-py2.6-linux-x86_64.egg/Crypto/Util/number.py:57: PowmInsecureWarning: Not using mpz_powm_sec.  You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.
  _warn("Not using mpz_powm_sec.  You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.", PowmInsecureWarning)
Using /etc/ansible.cfg as config file
ERROR! Unexpected Exception: 'AnsibleLoader' object has no attribute 'dispose'
the full traceback was:

Traceback (most recent call last):
  File "/usr/bin/ansible-playbook", line 86, in <module>
    sys.exit(cli.run())
  File "/usr/lib/python2.6/site-packages/ansible/cli/playbook.py", line 128, in run
    inventory = Inventory(loader=loader, variable_manager=variable_manager, host_list=self.options.inventory)
  File "/usr/lib/python2.6/site-packages/ansible/inventory/__init__.py", line 85, in __init__
    self.parse_inventory(host_list)
  File "/usr/lib/python2.6/site-packages/ansible/inventory/__init__.py", line 141, in parse_inventory
    group.vars = combine_vars(group.vars, self.get_group_variables(group.name))
  File "/usr/lib/python2.6/site-packages/ansible/inventory/__init__.py", line 506, in get_group_variables
    self._vars_per_group[groupname] = self._get_group_variables(groupname, vault_password=vault_password)
  File "/usr/lib/python2.6/site-packages/ansible/inventory/__init__.py", line 524, in _get_group_variables
    vars = combine_vars(vars, self.get_group_vars(group))
  File "/usr/lib/python2.6/site-packages/ansible/inventory/__init__.py", line 704, in get_group_vars
    return self._get_hostgroup_vars(host=None, group=group, new_pb_basedir=new_pb_basedir)
  File "/usr/lib/python2.6/site-packages/ansible/inventory/__init__.py", line 743, in _get_hostgroup_vars
    results = combine_vars(results, self._variable_manager.add_group_vars_file(base_path, self._loader))
  File "/usr/lib/python2.6/site-packages/ansible/vars/__init__.py", line 560, in add_group_vars_file
    (name, data) = self._load_inventory_file(path, loader)
  File "/usr/lib/python2.6/site-packages/ansible/vars/__init__.py", line 528, in _load_inventory_file
    data = loader.load_from_file(new_path)
  File "/usr/lib/python2.6/site-packages/ansible/parsing/dataloader.py", line 114, in load_from_file
    parsed_data = self.load(data=file_data, file_name=file_name, show_content=show_content)
  File "/usr/lib/python2.6/site-packages/ansible/parsing/dataloader.py", line 93, in load
    new_data = self._safe_load(new_data, file_name=file_name)
  File "/usr/lib/python2.6/site-packages/ansible/parsing/dataloader.py", line 150, in _safe_load
    loader.dispose()
AttributeError: 'AnsibleLoader' object has no attribute 'dispose'

どうやらlibyamlが先に入ってないとダメなようで、今回入ってなかったので一度Ansible2をアンインストールして、 そのあとにlibyamlを入れてからAnsible2を入れ直した。 libyamlだけ追加で入れてもダメでした。おそらくライブラリを見てる先が変わってしまってるのかな

ちなみにpython-yamlはAnsibleと依存関係があり同時にインストされます

[root@ansiblesvr001 ansible]# rpm -qa | grep yaml
python-yaml-3.09-3.el6.rf.x86_64
libyaml-0.1.3-4.el6_6.x86_64