0
我正在關注此頁面Clone a private git repository with Ansible (using password prompt)以解決我的需求。重複使用相同的模板在我的劇本main.yml
,其內容爲將Git憑據傳遞給Ansible拋出錯誤
---
- 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
我使用可用
ansible-playbook main.yml --syntax-check
,並在YAML lint語法檢查選項驗證了yml
,但似乎無法找到原因被認爲是錯誤的原因。
偉大的觀察!正在檢查我是否可以將其移至上一層。除了使用'vars_prompt'之外,還有另外一種方法來實現這個嗎? – Inian
Ansible首先是**自動化工具**。因此儘可能避免交互式活動,使用extra-vars,環境變量將其他數據傳遞到您的劇本中。 –
感謝您的領導。完全刪除了該方法,決定使用包含憑據的加密var文件。謝謝 – Inian