Forum Discussion

dani_martinez_2's avatar
dani_martinez_2
Icon for Nimbostratus rankNimbostratus
May 09, 2018

host parameter in bigip_pool_member

Hello I am quite new to Automation, could someone explain what is the meaning of the field: host: "{{ ansible_default_ipv4['address'] }}", for the ansible module bigip_pool_member. I assume it retrieves a variable but how does it work or what is the value of the variable it retrieves?

 

2 Replies

  • The

    host
    parameter is the F5 device the want to pass the module task to, in this case is a variable passed it it.

    With Ansible

    gather_facts
    is set to 'on' (it is on by default) then you have access to a load of variables you can use in your playbooks.

    With

    gather_facts
    you should get a dictionary variable set named
    ansible_default_ipv4
    which would look like the following:

    "ansible_default_ipv4": {
        "address": "10.0.0.1",
        "alias": "eth0",
        "gateway": "10.0.0.254",
        "interface": "eth0",
        "macaddress": "REDACTED",
        "mtu": 1500,
        "netmask": "255.255.255.0",
        "network": "REDACTED",
        "type": "ether"
    },
    

    You can then use

    ansible_default_ipv4.address
    or
    ansible_default_ipv4['address']
    to reference the address index of the dictionary.

    In your playbooks you will need to use

    "{{ansible_default_ipv4.address}}"
    or
    "{{ansible_default_ipv4['address']}}"

    See Ansible 2.6 Playbook Vaiables for more information.

  • The

    host
    parameter is not the F5 device. Rather that is the
    server
    parameter.

    The

    host
    parameter is an alias for the
    address
    parameter which is the IP address of the pool member you are acting upon.

    The

    ansible_default_ipv4
    variable is usually the self IP address of the external vlan of the LTM.

    The use of the

    ansible_default_ipv4
    parameter in the examples is a bit confusing. It would have been better to just make up some IP addresses to represent the downstream servers in the pool.