Ansible'ascii'编解码器不能编码字符u'\ u2013'

时间:2017-11-20 23:22:38

标签: python amazon-ec2 centos ansible

我正试图用一些vars运行我的剧本:

ansible-playbook playbook.yml -–extra-vars "env=dev  app=appname 
instance_type=t2.micro  keypair=pem.pem  security_group=sg-XXXX domain=domain  type=microservice"

出于某种原因,它会引发以下错误:

ERROR! Unexpected Exception, this is probably a bug: 'ascii' codec can't encode character u'\u2013' in position 17: ordinal not in range(128)
Traceback (most recent call last):File "/usr/bin/ansible-playbook", 
line 105, in <module>cli.parse() File "/usr/lib/python2.7/site-
packages/ansible/cli/playbook.py", line 72, in parse super(PlaybookCLI, 
self).parse()File "/usr/lib/python2.7/site-packages/ansible/cli/__init__.py", line 567, in parse
self.options, self.args = self.parser.parse_args(self.args[1:])File "/usr/lib64/python2.7/optparse.py", 
line 1401, in parse_args
self.error(str(err))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in 
position 17: ordinal not in range(128)` 

我在不传递剧本的情况下运行相同的命令,但仍然会出现同样的错误。

这是使用-–extra-vars的正确方法吗?

1 个答案:

答案 0 :(得分:4)

停止从网络浏览器复制命令或剧本并自行输入。

你在某处有一个Unicode破折号(u'\u2013')。