Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Executing playbook encountered an error #9

Open
z3473 opened this issue Jan 20, 2022 · 2 comments
Open

Executing playbook encountered an error #9

z3473 opened this issue Jan 20, 2022 · 2 comments

Comments

@z3473
Copy link

z3473 commented Jan 20, 2022

ansible-playbook --syntax-check create-user.yml -e "hosts=test user_name=test"
ERROR! The field 'hosts' has an invalid value, which includes an undefined variable. The error was: 'inventory' is undefined

The error appears to be in '/etc/ansible/create-user.yml': line 5, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


  • hosts: '{{inventory}}'
    ^ here
    We could be wrong, but this one looks like it might be an issue with
    missing quotes. Always quote template expression brackets when they
    start a value. For instance:

    with_items:
    - {{ foo }}

Should be written as:

with_items:
  - "{{ foo }}"
@z3473
Copy link
Author

z3473 commented Jan 20, 2022

[root@localhost ansible]# ansible-playbook create-user.yml -e "inventory=test user_name=test"

PLAY [test] *****************************************************************************************************************

TASK [Gathering Facts] ******************************************************************************************************
fatal: [192.168.2.12]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: no such identity: .vagrant/machines/test_box/virtualbox/private_key: No such file or directory\r\nPermission denied (publickey,gssapi-keyex,gssapi-with-mic,password).", "unreachable": true}

PLAY RECAP ******************************************************************************************************************
192.168.2.12 : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0

@oo1Alan
Copy link

oo1Alan commented Oct 26, 2023

try
hosts: {{ inventory }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants