I am trying to run a playbook which execute against variables stored in the host_vars. This is the solution layout:
- /host_vars/f5-test
- /inventory/hosts
- /playbook.yml
The content of the files are as follows:
/inventory/host:
[f5-test]
localhost
/host_vars/hosts
f5_user:user
f5_password:password
f5_server:server
/playbook.yml
- name: Playbook
hosts: f5-test
gather_facts: no
gather_subset: no
tasks:
- name: Taks_01
tags: "bigip-node"
bigip_node:
server: "{{f5_server}}"
user: "{{f5_user}}"
password: "{{f5_password}}"
state: "present"
partition: "Common"
host: "10.20.30.40"
name: "F5_Node"
session_state: "enabled"
description: "description"
delegate_to: localhost
However when we execute the following command:
sudo ansible-playbook playbook.yml -i inventory/hosts -vvvv
I get the following error:
task path: /home/dev/ansible/playbook.yml:9
fatal: [localhost]: FAILED! => {
"failed": true,
"msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'f5_server' is undefined\n\nThe error appears to have been in '/home/dev/ansible/playbook.yml': line 9, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n tasks:\n - name: Task_01\n ^ here\n"
}
Any idea why it is not being picked up? I set up my project in the same structure found in the F5 ansible example, which can be found here.
Thanks!