Skip to content

Instantly share code, notes, and snippets.

@oboukili
Created May 24, 2017 16:30
Show Gist options
  • Select an option

  • Save oboukili/576ff970308819bc15765c8c107a6728 to your computer and use it in GitHub Desktop.

Select an option

Save oboukili/576ff970308819bc15765c8c107a6728 to your computer and use it in GitHub Desktop.
playbook + invocation + output
---
- hosts: infrastructure
become: true
pre_tasks:
- name: debug
debug:
msg: "{{ hostvars[item] }}"
with_items: "{{ groups['infrastructure'] }}"
...
## Invocation:
ansible-playbook -i ~/Workspaces/ansible-inventory/mycloud includes/test.yml
## Output:
PLAY [infrastructure] ***********************************************************************************************************************************************************************************************
TASK [Gathering Facts] **********************************************************************************************************************************************************************************************
ok: [apps-public1]
ok: [bastion]
TASK [debug] ********************************************************************************************************************************************************************************************************
fatal: [apps-public1]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'ansible.vars.hostvars.HostVars object' has no attribute u'apps-public1'\n\nThe error appears to have been in '/home/bki/Workspaces/playbooks/test.yml': line 5, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n pre_tasks:\n - name: debug\n ^ here\n"}
fatal: [bastion]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'ansible.vars.hostvars.HostVars object' has no attribute u'apps-public1'\n\nThe error appears to have been in '/home/bki/Workspaces/playbooks/test.yml': line 5, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n pre_tasks:\n - name: debug\n ^ here\n"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment