簡體   English   中英

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

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

我已經使用以下 docker 圖像設置了一個 ansible 塔

ybalt/ansible-tower:latest

設置完成后,我升級了容器內的應用程序

apt-get upgrade

之后是我的 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]

然后,當我執行一個使用 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…

我開發了一個單獨的 palybook,配置為 email,以便從任何劇本中引用。 所以以下是我在劇本中定義的變量

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: 

以下是我如何從其他劇本中引用上述 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

但是當該部分觸發時,當第二本劇本試圖發送 email 時。我收到上述錯誤。 我的 ansible 配置文件中的變量已被完全注釋掉,並且所有變量都被 ansible 塔變量覆蓋。 所有配置都經過重新檢查並符合 ansible 文檔。 我什至可以通過 ansible 塔發送通知,但不能通過 ansible 中的郵件模塊發送通知。但我希望通過 ansible 腳本自動發送郵件。 但那沒有發生..

您的實際錯誤在 module_stdout TypeError: 'NoneType' object is not iterable中。 必須引用 null 或未知變量類型的變量。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM