syntax error... where there is no syntax error...

But Hello,

I have this playbook,… that used to work in a previous version of ansible, I swear it did:

cat ansible/playbooks/apt/sssdconfig.yml

`

Joost

Try:

python -c ‘import yaml,sys;yaml.safe_load(sys.stdin)’ < ansible/playbooks/apt/sssdconfig.yml

Valid Yaml is not hard but you can add a post commit hook like the above to validate the yaml for you.

I have this playbook,... that used to work in a previous version of
ansible, I swear it did:

cat ansible/playbooks/apt/sssdconfig.yml
---
- hosts: "{{hosts}}"

I wouldn't use a variable named the same as a directive.

# accelerate: true
  remote_user: root
  tasks:
  - name: install auth-client-config
    apt: name=auth-client-config state=installed
  - name: install sssd client
    apt: name=sssd state=installed
  - name: install ldap pam module
    apt: name=libpam-ldap state=installed
  - name: configure authentication
    command: /usr/sbin/auth-client-config --enablesssd --enablesssdauth --enablelocauthorize
--enablepamaccess --enablemkhomedir --update
  - name: make sure the config directory is present ( workaround for a bug
in sssd package)
    command: /bin/mkdir -p /etc/sssd
  - name: use a template sssd.conf
    copy: src=/home/florence/ansible/files/sssd.conf dest=/etc/sssd
  - name: ensure correct acl for the sssd directory
    file: path=/etc/sssd mode=0600
  - name: ensure correct acl for the sssd.conf file
    file: path=/etc/sssd/sssd.conf mode=0600
  - name: restart sssd
    service: name=sssd enabled=yes state=restarted

But now this happens:

ansible-playbook /home/florence/ansible/playbooks/apt/sssdconfig.yml -e
cal-30
ERROR! the field 'hosts' has an invalid value, which appears to include a
variable that is undefined. The error was: 'hosts' is undefined

The variable hosts is not set, and your -e should be key=value.
Are you trying to write -e hosts=cal-30 ?

Thanks Andrew latham

This

`

python -c ‘import yaml,sys;yaml.safe_load(sys.stdin)’ < ansible/playbooks/apt/sssdconfig.yml

`
has no output, so I guess syntax is correct.

Thanks Kai Stian Olstad
-e should be key=value.

That fixes it*,* thanks
I also did a test changing

`

  • hosts: “{{hosts}}”

`

into

`

  • hosts: “{{destin}}”

`

in the yaml and it looks good from this point (I only need to make sure the destination machine is switched on)

`
ansible-playbook ansible/playbooks/apt/sssdconfig.yml -e destin=cal-30

PLAY [cal-30] ******************************************************************

TASK [setup] *******************************************************************
fatal: [cal-30]: UNREACHABLE! => {“changed”: false, “msg”: “Failed to connect to the host via ssh: ssh: connect to host cal-30 port 22: Connection timed out\r\n”, “unreachable”: true}
to retry, use: --limit @/home/florence/ansible/playbooks/apt/sssdconfig.retry

PLAY RECAP *********************************************************************
cal-30 : ok=0 changed=0 unreachable=1 failed=0

`