Forum Discussion
Thornid
Jul 24, 2020Nimbostratus
Basic Question on Ansible - Creating Nodes
Hello all I know this is basic but I'm starting off learning about Ansible and F5s. I'm following this lab guide: https://github.com/ansible/workshops/tree/devel/exercises/ansible_f5/1.2-add-no...
Thornid
Nimbostratus
Thanks ArvinF
Even if I explicitly tell the playbook which inventory file I get the same thing:
devlin@ubuntu-v20:~/ansible/f5/lab2$ ansible-playbook -i ~/ansible/f5/lab2/inventory bigip-node-3.yaml -vvv
ansible-playbook 2.9.6
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/devlin/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible-playbook
python version = 3.8.2 (default, Jul 16 2020, 14:00:26) [GCC 9.3.0]
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing /home/devlin/ansible/f5/lab2/inventory as it did not pass its verify_file() method
script declined parsing /home/devlin/ansible/f5/lab2/inventory as it did not pass its verify_file() method
auto declined parsing /home/devlin/ansible/f5/lab2/inventory as it did not pass its verify_file() method
Parsed /home/devlin/ansible/f5/lab2/inventory inventory source with ini plugin
PLAYBOOK: bigip-node-3.yaml ************************************************************************************************************************************************************************************************
1 plays in bigip-node-3.yaml
PLAY [BIG-IP SETUP] ********************************************************************************************************************************************************************************************************
META: ran handlers
TASK [CREATE NODES] ********************************************************************************************************************************************************************************************************
task path: /home/devlin/ansible/f5/lab2/bigip-node-3.yaml:9
fatal: [f5]: FAILED! => {
"msg": "The task includes an option with an undefined variable. The error was: \"hostvars['webservers']\" is undefined\n\nThe error appears to be in '/home/devlin/ansible/f5/lab2/bigip-node-3.yaml': line 9, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: CREATE NODES\n ^ here\n"
}
PLAY RECAP *****************************************************************************************************************************************************************************************************************
f5 : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
cjunior
Jul 24, 2020Nacreous
Hello,
I think you must loop on "webservers" group and interact on each "item":
---
- name: BIG-IP SETUP
hosts: lb
connection: local
gather_facts: false
tasks:
- name: CREATE NODES
bigip_node:
provider:
server: X.X.X.X
user: XXXX
password: XXXXXXX
server_port: 443
validate_certs: false
host: "{{hostvars[item].ansible_host}}"
name: "{{hostvars[item].inventory_hostname}}"
loop: "{{ groups[webservers] }}"
Regards.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects