Достаточно ли правильного файла YAML для правильного ansible playbook, синтаксис при выполнении роли? - PullRequest
1 голос
/ 14 марта 2020
ERROR!
"unexpected parameter type in action: class 'ansible.parsing.yaml.objects.AnsibleSequence'"

The error appears to be in '/home/ansible/march/roles/apache/tasks/apt.yml': line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:
---
- hosts: all
  ^ here

Сборник пьес (apt.yml), содержащий:

---
- hosts: all
  become: yes
  tasks:
  - name: uninstall git
    apt:
      name: git
      state: absent
  - name: update
    apt:
      update-cache: yes

1 Ответ

0 голосов
/ 14 марта 2020

Q: "Ошибка, по-видимому, в /home/ansible/march/roles/apache/tasks/apt.yml ': строка 2, ..."

A: Директивы hosts и tasks являются действительными ключевыми словами в пьесе , но не в роли .

- hosts: all
  become: yes
  tasks:

Q: "Достаточно ли правильного файла YAML для правильной Ansible playbook ...?"

A: Это не так, очевидно. Сценарий, представленный в вопросе, является синтаксически правильным. ansible-lint apt.yml, yamllint apt.yml и ansible-playbook apt.yml --syntax-check сообщают об отсутствии ошибок.

Книга воспроизведения была протестирована с инвентарем

shell> cat hosts
linux:
  hosts:
    test_01:
      ansible_host: 10.1.0.11

Книга воспроизведения работает как положено

shell> ansible-playbook apt.yml -C

PLAY [all] ***

TASK [Gathering Facts] ***
ok: [test_01]

TASK [uninstall git] ***
changed: [test_01]

TASK [update] ***
changed: [test_01]

PLAY RECAP ***
test_01: ok=3 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
...