将Git凭据传递给Ansible引发错误
我跟随这一页,以解决我的要求。在我的剧本将Git凭据传递给Ansible引发错误,ansible,yaml,ansible-2.x,Ansible,Yaml,Ansible 2.x,我跟随这一页,以解决我的要求。在我的剧本main.yml中重新使用了相同的模板,其内容如下 --- - name: move CentOS repo definitions outside temp copy: src: "{{ item }}" dest: /etc/yum.repos.d/ owner: "root" mode: 0600 with_fileglob: - /etc/yum.repos.d/temp/* become: tr
main.yml
中重新使用了相同的模板,其内容如下
---
- name: move CentOS repo definitions outside temp
copy:
src: "{{ item }}"
dest: /etc/yum.repos.d/
owner: "root"
mode: 0600
with_fileglob:
- /etc/yum.repos.d/temp/*
become: true
- name: passing git credentials for cloning the repos
vars_prompt:
- name: "githubuser"
prompt: "Enter your github username"
private: no
- name: "githubpassword"
prompt: "Enter your github password"
private: yes
下面还有一些。我面临一个错误
The error appears to have been in '/tmp/.../tasks/main.yml': line 12, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: passing git credentials for cloning the repos
^ here
The error appears to have been in '/tmp/.../tasks/main.yml': line 12, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: passing git credentials for cloning the repos
^ here
我使用可用的语法检查选项验证了yml
ansible-playbook main.yml --syntax-check
也在上,但似乎无法找到看到错误的原因。您不能在任务级别使用
vars\u提示符,只能在剧本级别使用
如果您的main.yml
是角色的一部分,您应该将提示块移动到包含您的角色的更高级别的剧本中。很好的观察!我正在检查是否可以把它移到上层。除了使用vars\u prompt
,还有其他方法可以实现这一点吗?Ansible首先是一种自动化工具。因此,尽可能避免交互式活动,使用额外的变量和环境变量将额外的数据传递到您的剧本中。感谢您的介绍。完全删除了该方法,决定使用包含凭据的加密var文件。谢谢