f5 and ansible

I am fairly new to ansible and only reasonably proficient with f5s (day job is mainly DNS) so please forgive me if this question looks a little basic.

I’m trying to manipulate route domains with Ansible, i looked at the example in the documentation which says:

  • name: Create a route domain bigip_routedomain: name: foo id: 1234 password: secret server: lb.mydomain.com state: present user: admin delegate_to: localhost

This is obviously incomplete as there is no “hosts” section so I modified to the best of my knowledge and came up with:

  • hosts: bigip tasks:
    • name: Create a route domain bigip_routedomain: id: “1234” password: “my password” server: “bigip” state: “present” user: “brettcarr” delegate_to: localhost

Apologies had to split my question into two to avoid devcentral thinking it was spam, here is the second half…

I run this with the following command and get the following error, where am I going wrong, help really appreciated:

ansible-playbook -i ansiblehosts f5r.yaml -k SSH password:

PLAY [bigip] ****************************************************************************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************************************************************** fatal: [bigip]: FAILED! => {“changed”: false, “module_stderr”: “”, “module_stdout”: " File \“/tmp/ansible_XRSckC/ansible_module_setup.py\”, line 7\r\n from future import absolute_import, division, print_function\r\nSyntaxError: future feature absolute_import is not defined\r\n", “msg”: “MODULE FAILURE”, “rc”: 0}

First looks like you have an issue gathering facts, worth setting this to

False

.

Then I would setup and use a variable as the

provider

make it much easier to read your tasks without the same repeated elements all the time.

I have not testing the following

ansible playbook

file but I think it should do want you need.

---
- name: Add Route Domain ID 1234
  hosts: bigip
  connection: local
  gather_facts: False

  vars:
    f5Provider:
      server: "{{inventory_hostname}}"
      server_port: 443
      user: "brettcarr"
      password: "my password"
      validate_certs: no
      transport: rest

  tasks:
    - name: Create a route domain 
      bigip_routedomain:
        provider: "{{f5Provider}}"
        id: "1234"
        state: "present"
      delegate_to: localhost

Make sure you have ansible version 2.2 or above and the python F5 SDK (

f5-sdk

) installed.