首页 > 解决方案 > 需要 ansible 库存文件详细信息

问题描述

有人可以帮我编写 ansible 库存文件以连接到 bitbucket - 克隆文件并放入 ansible 机器。

剧本

---
- hosts: bitbucketURL
  tasks:
    - git:
        repo: https://p-bitbucket.com:5999/projects/VIT/repos/sample-playbooks/browse/hello.txt
        dest: /home/xxx/demo/output/

库存文件

[bitbucketURL]
p-bitbucket.com:5999

[bitbucketURL:vars]
ansible_connection=winrm
ansible_user=xxx
ansible_pass=<passwd>

使用此剧本和库存文件时出现错误

-bash-4.2$ ansible-playbook -i inv demo_draft1.yml

PLAY [bitbucketURL] *****************************************************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************
fatal: [p-bitbucket.nl.eu.abnamro.com]: UNREACHABLE! => {"changed": false, "msg": "ssl: auth method ssl requires a password", "unreachable": true}
        to retry, use: --limit @/home/c55016a/demo/demo_draft1.retry

PLAY RECAP **************************************************************************************************************************************************
p-bitbucket.nl.eu.abnamro.com : ok=0    changed=0    unreachable=1    failed=0

请帮我用正确的参数编写一个正确的库存文件

标签: ansible

解决方案


您根本不需要库存。您需要做的就是将播放设置为执行localhost

---
- hosts: localhost
  connection: local
  gather_facts: false
  tasks:
    - git:
        repo: https://p-bitbucket.com:5999/projects/VIT/repos/sample-playbooks/browse/hello.txt
        dest: /home/xxx/demo/output/

也就是说,URL 应该指向 Git 存储库,而不是单个文件(如果hello.txt是单个文件)。


推荐阅读