首页 > 解决方案 > Ansible - 登录 Heroku

问题描述

通常使用终端登录是这样的

sudo heroku login --interactive
Email: My email
Password: My password
Login Successful!

这是我的角色

- name: Heroku login
  expect:
    command: heroku login --interactive
    responses:
      (?i)Email: '{{ heroku_email }}'
      (?i)Password: '{{ heroku_password }}'

30秒后我得到了

fatal: [localhost]: FAILED! => {"changed": true, "cmd": "heroku login --interactive", "delta": "0:00:31.545693", "end": "2020-04-02 20:06:40.838040", "msg": "command exceeded timeout", "rc": null, "start": "2020-04-02 20:06:09.292347", "stdout": " \u001b[33m›\u001b[39m   Warning: heroku update available from \u001b[92m7.39.0\u001b[39m to \u001b[92m7.39.2\u001b[39m.\r\nheroku: Enter your login credentials\r\nEmail \u001b[33m[myemail@gmail.com]\u001b[39m: \u001b[2K\u001b[GPassword: ***********", "stdout_lines": [" \u001b[33m›\u001b[39m   Warning: heroku update available from \u001b[92m7.39.0\u001b[39m to \u001b[92m7.39.2\u001b[39m.", "heroku: Enter your login credentials", "Email \u001b[33m[myemail@gmail.com]\u001b[39m: \u001b[2K\u001b[GPassword: ***********"]}

有人知道我为什么会收到这个错误吗?

标签: ansibleheroku-cli

解决方案


我花了两天时间做这个,我问社区 ansble 但不幸的是它失败了。我做了一个替代退出,即使用expect 脚本登录。它看起来像这样:

#!/usr/bin/expect

spawn heroku login -i

sleep 1

send "HEROKU_EMAIL";

send "\r"

sleep 1

send "HEROKU_PASSWORD"

sleep 1

send "\r"

sleep 2

interact

如果有人想要整个角色,请点击下面的链接

https://github.com/BElluu/Ansible-Heroku-Deploy


推荐阅读