F5Networks / f5-ansible

Imperative Ansible modules for F5 BIG-IP products
GNU General Public License v3.0
375 stars 229 forks source link

Does this collection support more than one host per playbook? #2422

Closed cardosocristian closed 1 month ago

cardosocristian commented 1 month ago

I'm starting to use the f5_modules collection and whenever I try to use the ansible_host server field to search for more than one host in the hosts file, I can't use the playbook. The playbook only works correctly if the server field is the F5 I want to connect to. Does this collection support more than one F5 at a time in the playbook?

COMPONENT NAME

Environment

ANSIBLE VERSION
ansible [core 2.15.12]
  config file = None
  configured module search path = ['/home/cristian_cardoso/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /work/env/ansible/lib64/python3.9/site-packages/ansible
  ansible collection location = /home/cristian_cardoso/.ansible/collections:/usr/share/ansible/collections
  executable location = /work/env/ansible/bin/ansible
  python version = 3.9.19 (main, May 20 2024, 05:19:58) [GCC 8.5.0 20210514 (Red Hat 8.5.0-22)] (/work/env/ansible/bin/python3.9)
  jinja version = 3.1.4
  libyaml = True
urohit011 commented 1 month ago

Hi @cardosocristian , I didn't face any problem when using multiple hosts. My hosts file looks like the following:

[host_grp]
xx.xx.xx.xx ansible_host="xx.xx.xx.xx" f5_user=user f5_password=password
yy.yy.yy.yy ansible_host="yy.yy.yy.yy" f5_user=user f5_password=password

Are you seeing an error in your case? Could you share the error message.

cardosocristian commented 1 month ago

Hi @urohit011 After several tests, I understood how the hosts work in these modules, I did it as follows and it worked.

- name: Set up devices group on multiple hosts
  hosts: bigips
  connection: local
  gather_facts: no
  serial: 2
   vars:
    provider:
        password: "{{ f5_password }}"
        server: "{{ ansible_host }}"
        user: "{{ f5_user }}"

and the hosts file looked like this:

[bigips:children]
f5lb_1
f5lb_2

[f5lb_1]
lb1
lb2

[f5lb_2]
lb1
lb2