我从我的前任那里继承了这个 ansible git。我无法让它工作,我想这是我缺少的一些基本的东西。它不断给我这个可爱的错误:ERROR! The tasks/main.yml file for role 'common' must contain a list of tasks
然后 Ansible 继续指向我的 common/tasks/main.yml 第一行的第一个字符(顺便说一下,我有 env vars 指向正确的 Ansible 目录和配置,不知道这是否是一个原因)
ERROR! The tasks/main.yml file for role 'common' must contain a list of tasks
The error appears to have been in
'/root/git/Ansible/playbooks/roles/common/tasks/main.yml': line 1, column 1, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: Installing Samba and etc...
^ here
结构:
+-Vault
+-playbooks/
--basic.yml
+-roles/
+-common/
+-handlers/main.yml
+-tasks/main.yml
+-templates/
--krb5.conf.jinja2
--realmd.conf.jinja2
--smb.conf.jinja2
--sssd.conf.jinja2
+-join/tasks/main.yml
+-prereq/tasks/main.yml
我猜重要的文件是playbooks/basic.yml
和playbooks/roles/common/tasks/main.yml
剧本/basic.yml
- name: Install basic AD stuff
hosts: all
become: yes
become_user: root
gather_facts: no
vars_prompt:
- name: "ad_admin_name"
prompt: "username for AD join"
private: no
- name: "ad_admin_password"
prompt: "password for AD"
private: yes
confirm: yes
roles:
- prereq
- common
- join
#The End
playbooks/roles/common/tasks/main.yml
---
- name: Installing Samba and etc...
apt:
name: "{{ packages }}"
state: present
vars:
packages:
- adcli
- libnss-sss
- libpam-sss
- libwbclient-sssd
- realmd
- sssd
- sssd-tools
- samba
- krb5-config
- krb5-user
- winbind
- libpam-winbind
- libnss-winbind
- cifs-utils
- name: "template krb5.conf"
template:
src: "krb5.conf.jinja2"
dest: "/etc/krb5.conf"
owner: "root"
group: "root"
mode: "0644"
backup: yes
- name: "template realmd.conf"
template:
src: "realmd.conf.jinja2"
dest: "/etc/realmd.conf"
owner: "root"
group: "root"
mode: "0644"
backup: yes
- name: "template sssd.conf"
template:
src: "sssd.conf.jinja2"
dest: "/etc/sssd/sssd.conf"
owner: "root"
group: "root"
mode: "0600"
backup: yes
notify: "sssd needs restart"
- name: "template smb.conf"
template:
src: "smb.conf.jinja2"
dest: "/etc/samba/smb.conf"
owner: "root"
group: "root"
mode: "0644"
backup: yes
roles/common/tasks/main.yml 的语法是可以的。你可以试试
测试剧本
可以肯定的是,我建议从任务名称中删除 3 个点“...”的序列。
引用YAML 基础知识