跳到主要内容

Ansible 问题

问题:

RuntimeError: Compression requires the (missing) zlib module

解决:

问题:

[DEPRECATION WARNING]: [defaults]hostfile option, The key is misleading as it can also be a list of hosts, a directory or a list of paths , use [defaults]

inventory=/path/to/file|dir instead. This feature will be removed in version 2.8. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

解决:

sudo vim /etc/ansible/ansible.cfg

hostfile = hosts 改成 inventory = hosts

问题:

to use the 'ssh' connection type with passwords, you must install the sshpass program

解决:

brew search sshpass

We won't add sshpass because it makes it too easy for novice SSH users to ruin SSH's security.

brew create https://sourceforge.net/projects/sshpass/files/sshpass/1.06/sshpass-1.06.tar.gz --force

brew install sshpass

问题:

[WARNING]: Found both group and host with same name: server209

解决:

group name 和 server name 不能相同,/etc/ansible/hosts 里改一个就好了

问题:

server97 | FAILED! => {
"changed": false,
"module_stderr": "Shared connection to 118.24.105.97 closed.\r\n",
"module_stdout": "Traceback (most recent call last):\r\n File \"/root/.ansible/tmp/ansible-tmp-1539431124.47-199554069981556/command.py\", line 17, in <module>\r\n import zipfile\r\nImportError: No module named zipfile\r\n",
"msg": "MODULE FAILURE",
"rc": 1
}

解决

问题:

ERROR! Vars in a Play must be specified as a dictionary, or a list of dictionaries

解决:

playbook 中变量要这样写 "{{ 'a': 80}}"