将 Git 凭据传递给 Ansible 会引发错误
Passing Git credentials to Ansible throwing an error
我正在关注此页面,Clone a private git repository with Ansible (using password prompt) 来解决我的需求。在我的剧本 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
也在 YAML lint 上,但似乎无法找到出现错误的原因。
您不能在任务级别使用 vars_prompt
,只能在剧本级别使用。
如果您的 main.yml
是角色的一部分,您应该将提示块移动到包含您的角色的上层剧本。
我正在关注此页面,Clone a private git repository with Ansible (using password prompt) 来解决我的需求。在我的剧本 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
也在 YAML lint 上,但似乎无法找到出现错误的原因。
您不能在任务级别使用 vars_prompt
,只能在剧本级别使用。
如果您的 main.yml
是角色的一部分,您应该将提示块移动到包含您的角色的上层剧本。