I created a dummy apb using with the following structure:
{code:java} ├── apb.yml ├── catalog.json ├── Dockerfile ├── Makefile ├── playbooks │ ├── deprovision.yml │ ├── install.yml │ ├── provision.yml │ └── update.yml ├── roles │ ├── deprovision-android-sdk │ │ └── tasks │ │ └── main.yml │ ├── provision-android-sdk │ │ ├── defaults │ │ │ └── main.yml │ │ ├── tasks │ │ │ └── main.yml │ │ └── templates │ │ └── android-persistent.json.j2 │ └── update-android-sdk │ ├── defaults │ │ └── main.yml │ └── tasks │ └── main.yml {code}
This is the apb.yml file content :
{code:java} version: 1.0 name: aerogear-androidctl-apb description: This is a sample application generated by apb init bindable: False async: optional tags: - "mobile-service" metadata: displayName: AndroidCTL serviceName: aerogear-androidctl imageUrl: "https://aerogear.org/img/aerogeardigger_icon_32px_cropped.png" documentationUrl: "https://aerogear.org/digger/" providerDisplayName: "Red Hat, Inc." plans: - name: default description: This default plan deploys android-sdk pod + pv free: True metadata: {} parameters: - name: ANDROID_LICENSE_AGREEMENT default: "" pattern: ^yes$ type: string description: "Type 'yes' above to accept the Android SDK License Agreement. https://developer.android.com/studio/terms.html" title: Android SDK License Agreement required: True - name: ANDROID_INSTALL default: False type: bool description: "Auto installs Android SDK as part at startup" title: SDK Install updatable: True required: False {code}
Then I ran the following command (after provisioning the above apb):
{code:java} #!/bin/bash
BROKER_URL="$(oc get routes -o jsonpath='{.items[0].spec.host}' --namespace ansible-service-broker)"
curl -v -k \ -X PATCH \ -H "X-Broker-API-Version: 2.13" \ -H "Authorization: Bearer $(oc whoami -t)" \ -H "Content-Type: application/json" \ "https://$BROKER_URL/ansible-service-broker/v2/service_instances/a5581c1d-3430-4f1d-b4f6-75714f254e9d?accepts_incomplete=true" \ -d '{ "service_id": "f867d10c4189af43359d4b89819751e8", "plan_id": "80d63b71293a4cf07d455f19f9e90e36", "parameters": { "ANDROID_INSTALL": "true" }, "previous_values": { "plan_id": "80d63b71293a4cf07d455f19f9e90e36" } }'
{code}
This triggered a new asb service project changing the ANDROID_INSTALL variable to true and running the "update.yml" playbook which installed the android sdk itself.
A few gotchas:
* The update playbook is never executed if nothing changes parameter wise; * Fields have to be flagged as "updatable"; * The field will change its value even if the playbook fails to be executed
Note: flagging a field as updatable will automatically enable the user to run the update playbook from the openshift console.
|
|