Skip to content

Instantly share code, notes, and snippets.

@tjtoml
Created February 20, 2020 00:08
Show Gist options
  • Save tjtoml/f860ee9866e38fd5b43879d43a5ba7b7 to your computer and use it in GitHub Desktop.
Save tjtoml/f860ee9866e38fd5b43879d43a5ba7b7 to your computer and use it in GitHub Desktop.
---
- hosts: application_servers
remote_user: root
become: true
become_method: su
vars_files:
- vars/naming_convention.yml
tasks:
- debug:
msg: "{{ vm_short_name }}"
- name: blah
file:
state: directory
path: /tmp/{{ hostvars[inventory_hostname]['vm_short_name'] }}
delegate_to: database_master
# vim:ft=ansible
PLAY [application_servers] ****************************************************************************************************************************************************************
TASK [Gathering Facts] ********************************************************************************************************************************************************************
ok:
ok:
ok:
TASK [debug] ******************************************************************************************************************************************************************************
ok: =>
msg: app1
ok: =>
msg: app3
ok: =>
msg: app2
TASK [blah] *******************************************************************************************************************************************************************************
fatal: FAILED! =>
msg: |-
The task includes an option with an undefined variable. The error was: 'ansible.vars.hostvars.HostVarsVars object' has no attribute 'vm_short_name'
The error appears to be in '/home//ansible/playbooks//debug.yml': line 14, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: blah
^ here
Failure message repeated for the remaining two hosts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment