Ansible Playbook创建BitBucket存储库
我正试图通过Ansible Playbook创建一个BitBucket存储库。 但是,使用RestAPI运行以下命令可以正常工作:Ansible Playbook创建BitBucket存储库,ansible,Ansible,我正试图通过Ansible Playbook创建一个BitBucket存储库。 但是,使用RestAPI运行以下命令可以正常工作: curl -u user:Password \ -d '@data.json' \ -X POST \ -H "Content-Type: application/json" \ http:// https://api.bitbucket.org/1.0/projects/SUN/repos JSON包括以下内容: {"na
curl -u user:Password \
-d '@data.json' \
-X POST \
-H "Content-Type: application/json" \
http:// https://api.bitbucket.org/1.0/projects/SUN/repos
JSON包括以下内容:
{"name": "my-repo",
"scmId": "git",
"forkable": true}
我尝试了各种方法将这个curl命令转换成ansible playbook,但总是失败,出现不同的错误
- hosts: localhost
tasks:
- name: Create a Bitbucket Repo
uri:
url: https://api.bitbucket.org/1.0/projects/SUN/repos
method: POST
user: user
password: password
src: data.json
force_basic_auth: yes
status_code: 201
body_format: json
当离开“任务”时,它说剧本需要是一个剧本列表。
删除任务时,它会说“uri”不是有效属性
有人能就本例中剧本的结构提出建议吗
非常感谢通常,“任务需要是一个列表”消息表示您
- 在任务之前忘记了一个
(破折号)-
- hosts: localhost tasks name: # no dash here. uri: # ...
- 误解了某事
我重新格式化了你的代码。对我来说,它看起来还可以,因为它已重新格式化。仔细检查你的剧本。但是您确实需要
任务:
关键字,否则您肯定会收到您提到的第二条错误消息。请尝试模块。是的,我有。事实证明,该问题存在于库存文件中。谢谢你的建议!非常感谢您的回答。最后,我的代码在编辑了主机文件后运行。结果表明,我需要在ansible\u SSH\u user=xxx和ansible\u SSH\u pass=xxx之后添加_SSH