F5 Programmability Training > Automation Mini Classes > Mini Class 1 - F5 Architectures with Ansible > Module 3 – Putting it all together Source | Edit on

Lab 3 - Declarative - Create VS, Pool and Members using an iApp

You will create a playbook to deploy VS, Pools and associated Members using iApps.

Task 1 - Create service playbook using iApp

  1. Create a playbook iapp.yaml.

    • Type nano playbooks/iapp.yaml
    • Type the following into the playbooks/iapp.yaml file.
    ---
    
    - name: "Declarative: Deploy / teardown web app"
      hosts: bigips
      gather_facts: False
      connection: local
    
      vars:
        service_name: ""
        service_ip: ""
        service_group: ""
        state: "present"
    
      environment: "{{ bigip_env }}"
    
      tasks:
        - import_tasks: getsl.yaml
          when: state == "absent"
    
        - name: Check if {{ service_name }} is deployed
          meta: end_play
          when: 'state == "absent" and service_name not in (service_list.content|from_json)["items"]'
    
        - name: Build POST body
          template: src=f5.http.j2 dest=./f5.http.yaml
    
        - name: Adjust an iApp
          uri:
            url: "https://{{ inventory_hostname }}/mgmt/tm/cloud/services/iapp/{{ service_name }}"
            method: "{{ (state == 'present') | ternary('POST', 'DELETE') }}"
            body: "{{ (lookup('template','f5.http.yaml') | from_yaml) }}"
            body_format: json
            user: "{{ bigip_user }}"
            password: "{{ bigip_pass }}"
            validate_certs: no
    
    • Ctrl-x to save file.
  2. Run this playbook.

    • Type ansible-playbook playbooks/iapp.yaml -e @creds.yaml --ask-vault-pass -e service_name="app4" -e service_ip="10.1.10.40" -e service_group="appservers"

      If successful, you should see similar results

      ../../../_images/image0111.png

      Hint

      Due to our lab environment, you may encounter a timeout issue. If so, please run playbook a 2nd time and it should complete correctly.

  3. Verify results in BIG-IP GUI.

    Hint

    You should see app4 deployed with 1 pool member. App should be accessible on https://10.1.10.40.

  4. Run this playbook to teardown.

  5. Verify that app4 iapp should be deleted in BIG-IP GUI.

    • Type ansible-playbook playbooks/iapp.yaml -e @creds.yaml --ask-vault-pass -e service_name="app4" -e service_ip="10.1.10.40" -e service_group="appservers" -e state="absent"

    Note

    F5 iApps, automate the configuration of advanced L4-L7 functionality. Deploying an iApp from an Ansible playbook means the Ansible admin can deliver advanced L4-L7 services without the requirement for F5 domain-specific knowledge. You take the JSON payload and convert to YAML using online tools like http://www.json2yaml.com.