3
respostas

Problemas com sintaxe da aula 02 (segundo video)

Estou usando o ansible v.2.5.1.

Ao executar o playbook

---
- hosts: all
  tasks:
    - apt: 
      name: php5
      state: latest
    become: yes

pego a seguinte mensagem de erro:

lamps@pc:~/dev/ansible$ ansible-playbook provisioning.yml -u vagrant -i hosts --private-key .vagrant/machines/wordpress/virtualbox/private_key 
ERROR! Syntax Error while loading YAML.
  did not find expected '-' indicator

The error appears to have been in '/home/lamps/dev/ansible/provisioning.yml': line 7, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

      state: latest
    become: yes
    ^ here

Tentei colocar o become com hífen ou identado com 1 espaço além do apt, também sem sucesso.

3 respostas

o become deve estar alinhado (com o mesmo espaçamento) que o tasks, visto que o ansible é muito rigoroso na identação

Ahhhh entendi. Eu tentei alinhar ao hífen do apt, ao apt e ao name/state. kkkkkk

Vou testar essa tarde, valeu!

Continuo enfrentando problemas. Tanto utilizando a linha state quanto apagando-a, o ansible eh executado, diz que tudo saiu OK mas o php não eh instalado na minha VM. Seguem copias do terminal:

lamps@pc:~/dev/ansible$ ansible-playbook provisioning.yml -u vagrant -i hosts --private-key .vagrant/machines/wordpress/virtualbox/private_key 
 [WARNING]: Ignoring invalid attribute: state


PLAY [all] ***********************************************************************************************

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

TASK [php5] **********************************************************************************************
ok: [192.168.50.11]

PLAY RECAP ***********************************************************************************************
192.168.50.11              : ok=2    changed=0    unreachable=0    failed=0

e

vagrant@vagrant-ubuntu-trusty-32:~$ sudo apt list --installed | grep php

WARNING: apt does not have a stable CLI interface yet. Use with caution in scripts.

vagrant@vagrant-ubuntu-trusty-32:~$