简体   繁体   English

TypeError: 'NoneType' object 在 ansible output 中不可迭代

[英]TypeError: 'NoneType' object is not iterable in ansible output

I have set up an ansible tower using the following docker image我已经使用以下 docker 图像设置了一个 ansible 塔

ybalt/ansible-tower:latest

After setting up I have upgraded the applications inside the container by设置完成后,我升级了容器内的应用程序

apt-get upgrade

After that following are the versions inside my conatiner之后是我的 conatiner 中的版本

ansible 2.7.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.12 (default, Jul 18 2016, 15:02:52) [GCC 4.8.4]

Then when I execute a script that uses the mail module in ansible the following error shown in the ansible tower output然后,当我执行一个使用 ansible 中的邮件模块的脚本时,以下错误显示在 ansible 塔 output

fatal: [Server]: FAILED! => {
    "changed": false, 
    "module_stderr": "Shared connection to x.x.x.x closed.\r\n", 
    "module_stdout": "\r\nTraceback (most recent call last):\r\n  File \"/home/ansible/.ansible/tmp/ansible-tmp-1549369654.27-211111564926363/AnsiballZ_mail.py\", line 113, in <module>\r\n    _ansiballz_main()\r\n  File \"/home/ansible/.ansible/tmp/ansible-tmp-1549369654.27-211111564926363/AnsiballZ_mail.py\", line 105, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/home/ansible/.ansible/tmp/ansible-tmp-1549369654.27-211111564926363/AnsiballZ_mail.py\", line 48, in invoke_module\r\n    imp.load_module('__main__', mod, module, MOD_DESC)\r\n  File \"/tmp/ansible_mail_payload_bQeVQh/__main__.py\", line 381, in <module>\r\n  File \"/tmp/ansible_mail_payload_bQeVQh/__main__.py\", line 330, in main\r\nTypeError: 'NoneType' object is not iterable\r\n", 
    "msg": "MODULE FAILURE\nSee stdo…

I have developed a seperate palybook with email configurations inorder to refer from an any playbook.我开发了一个单独的 palybook,配置为 email,以便从任何剧本中引用。 So the following is the variables that I have defined in the playbook所以以下是我在剧本中定义的变量

email_host: "smtp.sendgrid.net"
email_port: 587
email_username: "username"
email_password: "password"
email_to: "admin@example.com"
email_cc:
email_subject: "test"
email_body:
email_subtype: "html"
email_secure: "try"
email_from: "noreply@example.com ( Ansible Tower )"
email_bcc:
email_attach: 

Following is the way how i refer to the above email playbook from my other playbooks以下是我如何从其他剧本中引用上述 email 剧本的方式

- name: Email body on failure
  set_fact:
    email_body="Hi {{ tower_user_name }}, <br><br> Status - Failed
                                                                  <br> Issue - Build path or given build name doesn't exist
                                                                  <br> Suggested Solution - Check the validity of the build path or the build name.
                                                                  <br><br> Thank You"

- name: Sending an email
  include_role:
    name: email
    tasks_from: main.yml
  when: path_build_location.stat.exists == False

But when that section triggers and when a second play book tries to send an email. I get the above error.但是当该部分触发时,当第二本剧本试图发送 email 时。我收到上述错误。 Variables in my ansible config file are fully commented out and all are overidden by the ansible tower variables.我的 ansible 配置文件中的变量已被完全注释掉,并且所有变量都被 ansible 塔变量覆盖。 All the configurations are rechecked and are according to the ansible documentation.所有配置都经过重新检查并符合 ansible 文档。 I even can sent the notifications via the ansible tower but not through the mail module in ansible. But I expected to sent the mail automatically by the ansible script.我什至可以通过 ansible 塔发送通知,但不能通过 ansible 中的邮件模块发送通知。但我希望通过 ansible 脚本自动发送邮件。 But that didn't happen..但那没有发生..

Your actual error is in module_stdout TypeError: 'NoneType' object is not iterable .您的实际错误在 module_stdout TypeError: 'NoneType' object is not iterable中。 must be referring to a variable which is null or unknown variable type.必须引用 null 或未知变量类型的变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM