SNAT Error While Using Ansible to Create a VS in BigIP

I am trying to create a VS using Ansible playbook. It is able to create the virtual server but not able to set SNAT setting that i wanted (Automap), getting the following error

fatal: [xxx.com]: FAILED! => {“changed”: false, “failed”: true, “msg”: “received exception: Error on setting snat : Method not found: ‘LocalLB.VirtualServer.LocalLB.VirtualServerPort.get_source_address_translation_type’”}

Version details:

  • Ansible: 2.3.0.0
  • python: 2.7.5
  • BigIP: 11.12.1

this is how my playbook looks

name: Create virtual server
 bigip_virtual_server:
   server: xxx.com
   user: admin
   password: MYPASS
   state: present
   name: VS_NAME
   destination: DEST_IP
   port: 80
   pool: POOL_NAME
   all_profiles:
     - tcp
     - http
   snat: Automap
   validate_certs: no

Any support on this would be really appreciated. Thanks!

Any support on this would be really appreciated. Thanks!

Hello,

You have to use “source-address-translation” instead snat and set it to “type automap”. It will work.

I advise you for the future to test your parameter trough tmsh:

tmsh modify ltm virtual vs-name source-address-translation { type automap }

Regards,

can you try following the procedure in this url: F5 Cloud Docs

I noticed that on the reference url, snat is defined higher up the list compare to yours, its in the bottom.

can you try modifying your playbook and somewhat copy what is in the reference url? share any errors when you run the playbook after the change.

when running your playbook, since you are getting an error, can you enable verbose logging and share the output? see this url:

hopefully, this will give more verbose output on the errors received.

see also F5 Cloud Docs

I had interchanged the modules/arguments to the way it is showed in the reference url, but had no luck, i got the same error

bigip_virtual_server:
    destination: DEST_IP
    password: MY_PASS
    name: VS_NAME
    pool: POOL_NAME
    port: 80
    server: xxx.com
    snat: Automap
    user: admin
    all_profiles:
      - tcp
      - http
    validate_certs: no

error

fatal: [xxx.com]: FAILED! => {"changed": false, "failed": true, "msg": "received exception: Error on updating Virtual Server : Error on setting snat : Method not found: 'LocalLB.VirtualServer.LocalLB.VirtualServerPort.get_source_address_translation_type'"}

I had the same job run it in verbose mode and this is the output i got

TASK [Create virtual server] *********************************************************************************************************************
task path: /etc/ansible/f5-virt.yml:6
Using module file /usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_virtual_server.py
 ESTABLISH LOCAL CONNECTION FOR USER: root
 EXEC /bin/sh -c 'echo ~ && sleep 0'
 EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1525440236.15-140334385587090 `" && echo ansible-tmp-1525440236.15-140334385587090="` echo /root/.ansible/tmp/ansible-tmp-1525440236.15-140334385587090 `" ) && sleep 0'
 PUT /tmp/tmpfOasSB TO /root/.ansible/tmp/ansible-tmp-1525440236.15-140334385587090/bigip_virtual_server.py
 EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1525440236.15-140334385587090/ /root/.ansible/tmp/ansible-tmp-1525440236.15-140334385587090/bigip_virtual_server.py && sleep 0'
 EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1525440236.15-140334385587090/bigip_virtual_server.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1525440236.15-140334385587090/" > /dev/null 2>&1 && sleep 0'
fatal: [xxx.com]: FAILED! => {
    "changed": false,
    "failed": true,
    "invocation": {
        "module_args": {
            "all_policies": null,
            "all_profiles": [
                "tcp",
                "http"
            ],
            "all_rules": null,
            "default_persistence_profile": null,
            "description": null,
            "destination": "DEST_IP",
            "enabled_vlans": null,
            "fallback_persistence_profile": null,
            "name": "VS_NAME",
            "partition": "Common",
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "pool": "POOL_NAME",
            "port": "80",
            "route_advertisement_state": null,
            "server": "xxx.com",
            "server_port": 443,
            "snat": "Automap",
            "state": "present",
            "user": "admin",
            "validate_certs": false
        }
    },
    "msg": "received exception: Error on updating Virtual Server : Error on setting snat : Method not found: 'LocalLB.VirtualServer.LocalLB.VirtualServerPort.get_source_address_translation_type'"
 }

Thanks for all your time to support this!

@anonymous007

The version of BIG-IP you’re using is to old. In other words “Plan your upgrade path”.

11.12.1 is not an actual version, so I assume you meant 11.2.1. In that case, this method (get_source_address_translation_type) was not introduced until 11.3.0.

So…basically…you’re out of luck.

You can use the bigip_command module in CLI mode for BIG-IP versions earlier than 12.x. However, the real solution as I said earlier, is to plan your upgrade.