Ansible URI 在第一个 运行 的 Gitlab CI 管道中不起作用
Ansible URI not working in Gitlab CI pipeline in first run
我目前面临一个奇怪的问题,我无法猜测是什么原因造成的。
我编写了一些小的 Ansible 脚本来测试 Kafka 架构注册表和连接器是否通过调用它们的 API 运行ning。
我可以 运行 在我的本地机器上成功地使用那些 Ansible 剧本。但是,当 运行 在 Gitlab CI 管道中使用它们时(我使用与 gitlab 运行ner 相同的本地机器),connect_test 总是因以下错误而中断:
fatal: [xx.xxx.x.x]: FAILED! => {"changed": false, "elapsed": 0, "msg": "Status code was -1 and not [200]: Request failed: <urlopen error [Errno 111] Connection refused>", "redirected": false, "status": -1, "url": "http://localhost:8083"}
奇怪的是,当我单击 CI 管道中的重试按钮时,这个失败的作业会起作用。
有人知道这个问题吗?非常感谢您的帮助。
schema_test.yml
---
- name: Test schema-registry
hosts: SCHEMA
become: yes
become_user: root
tasks:
- name: list schemas
uri:
url: http://localhost:8081/subjects
register: schema
- debug:
msg: "{{ schema }}"
connect_test.yml
---
- name: Test connect
hosts: CONNECT
become: yes
become_user: root
tasks:
- name: check connect
uri:
url: http://localhost:8083
register: connect
- debug:
msg: "{{ connect }}"
.gitlab-ci.yml
test-connect:
stage: test
script:
- ansible-playbook connect_test.yml
tags:
- gitlab-runner
test-schema:
stage: test
script:
- ansible-playbook schema_test.yml
tags:
- gitlab-runner
更新
我用 shell 替换了 URI 模块。结果,我看到了相同的行为。管道的初始 运行 将失败,重试作业将修复它
也许您正在重新启动之前工作中的服务,请记住,kafka connect 在重新启动后通常需要更多时间才能可用。重新启动服务一分钟左右后,尝试暂停 ansible。
我目前面临一个奇怪的问题,我无法猜测是什么原因造成的。
我编写了一些小的 Ansible 脚本来测试 Kafka 架构注册表和连接器是否通过调用它们的 API 运行ning。
我可以 运行 在我的本地机器上成功地使用那些 Ansible 剧本。但是,当 运行 在 Gitlab CI 管道中使用它们时(我使用与 gitlab 运行ner 相同的本地机器),connect_test 总是因以下错误而中断:
fatal: [xx.xxx.x.x]: FAILED! => {"changed": false, "elapsed": 0, "msg": "Status code was -1 and not [200]: Request failed: <urlopen error [Errno 111] Connection refused>", "redirected": false, "status": -1, "url": "http://localhost:8083"}
奇怪的是,当我单击 CI 管道中的重试按钮时,这个失败的作业会起作用。
有人知道这个问题吗?非常感谢您的帮助。
schema_test.yml
---
- name: Test schema-registry
hosts: SCHEMA
become: yes
become_user: root
tasks:
- name: list schemas
uri:
url: http://localhost:8081/subjects
register: schema
- debug:
msg: "{{ schema }}"
connect_test.yml
---
- name: Test connect
hosts: CONNECT
become: yes
become_user: root
tasks:
- name: check connect
uri:
url: http://localhost:8083
register: connect
- debug:
msg: "{{ connect }}"
.gitlab-ci.yml
test-connect:
stage: test
script:
- ansible-playbook connect_test.yml
tags:
- gitlab-runner
test-schema:
stage: test
script:
- ansible-playbook schema_test.yml
tags:
- gitlab-runner
更新
我用 shell 替换了 URI 模块。结果,我看到了相同的行为。管道的初始 运行 将失败,重试作业将修复它
也许您正在重新启动之前工作中的服务,请记住,kafka connect 在重新启动后通常需要更多时间才能可用。重新启动服务一分钟左右后,尝试暂停 ansible。