2.3.2. Create VS, Pool and Members using an iApp¶
You will create a playbook to deploy VS, Pools and associated Members using iApps.
Create service playbook using iApp
Create a playbook
iapp.yaml.- Type
nano playbooks/iapp.yaml - Type the following into the
playbooks/iapp.yamlfile.
--- - name: "Declarative: Deploy / teardown web app" hosts: bigips gather_facts: False connection: local vars: vs_name: "" vs_ip: "" vs_group: "" state: "present" environment: "{{ bigip_env }}" tasks: - import_tasks: getsl.yaml when: state == "absent" - name: Check if {{ vs_name }} is deployed meta: end_play when: 'state == "absent" and vs_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/{{ vs_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.
- Type
Run this playbook.
- Type
ansible-playbook playbooks/iapp.yaml -e @creds.yaml --ask-vault-pass -e vs_name="app40" -e vs_ip="10.1.10.40" -e vs_group="appservers"
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.
- Type
Verify results in BIG-IP GUI.
Hint
You should see app40 iapp services deployed. App should be accessible on https://10.1.10.40.
Run this playbook to teardown.
- Type
ansible-playbook playbooks/iapp.yaml -e @creds.yaml --ask-vault-pass -e vs_name="app40" -e vs_ip="10.1.10.40" -e vs_group="appservers" -e state="absent"
- Type
Verify that app40 iapp should be deleted in BIG-IP GUI.
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.
For this particular exercise, the service is defined in the playbooks/f5.http.yaml file built leveraging the playbooks/f5.http.j2 file. Parameters for the name, destination (VIP), and pool members are passed through the command line through the -e vs_ip and -e vs_group mantras. The service_group refers to the app_servers defined in the ./inventory/hosts file.