Ansible - login to 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.0u001b[39m to u001b[92m7.39.2u001b[39m.rnheroku: Enter your login credentialsrnEmail u001b[33m[myemail@gmail.com]u001b[39m: u001b[2Ku001b[GPassword: ***********", "stdout_lines": [" u001b[33m›u001b[39m   Warning: heroku update available from u001b[92m7.39.0u001b[39m to u001b[92m7.39.2u001b[39m.", "heroku: Enter your login credentials", "Email u001b[33m[myemail@gmail.com]u001b[39m: u001b[2Ku001b[GPassword: ***********"]}

有人知道我为什么会犯那个错误吗?

我花了两天时间做这件事,我向社区询问了anisible,但不幸的是它失败了。我做了一个替代退出,即使用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

#!/usr/bin/expect
spawn heroku login -i
expect -re "Email*"
send "EMAIL";
send "r"
expect -re "Pass*"
send "PASSWORD";
sleep 1
send "r"
interact

expect模块的默认超时为30秒。从stdout中可以看出,expect对这两个提示都做出了响应。

登录时间可能超过了默认超时时间。增加任务的超时,

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

相关内容

  • 没有找到相关文章

最新更新