If you are following social medias, you are probably aware of the new product that dbi services launched which is called YaK (news here). With Pascal Brand, we are working on developing new components for it.

I will share my experience on creating new components with few tips that could makes your development faster and safer.

By the way, dbi services have already components ready for subscription (on top of YaK Core): To date, the components available with an annual subscription are Oracle Database and PostgreSQL. More components will come soon.

What is a YaK Component?

YaK components are a set of playbooks/roles to deploy an application on a YaK target with the benefits of YaK Core inventory abstraction, meaning being cloud independent.

Developing New Component

Assert

While developing and testing new components, we should verify the following facts:

  1. AWS credentials (for artifacts stored in S3) not set or expired
  2. Cloud provider credentials not set
  3. Target type (server vs component)
  4. Server and cluster definition alignment

So, if playbook has to fail, it has to fail has early as possible during playbook execution. That’s why I developed a role called assertion-yak-role which will ensure all these points are correctly setup.

Checking Cloud Provider Accesses (Item 1 and 2)

For 1 and 2, it is as simple as trying to reach cloud provider and when it fails stop playbook with a self-explanatory message. Of course, this test should be done only for the selected cloud provider. So, for example, in case aws is cloud provider or artifact provider, when clause will look like:

when: artifacts.provider == 'aws_s3' or provider == 'aws'

Target Type (Item 3)

For point 3, I got inspiration from what is done inside YaK core, but in the opposite way as I used to provide wrong target type (ie “target=on_prem/srv-linux-ols-1” instead of “target=on_prem/srv-linux-ols-1/WLS_DOMAIN“).

- name: Checking Target Type
  ansible.builtin.assert:
    that:
      - target_type == 'component'
    success_msg: "Target is a component."
    fail_msg: "This playbook can only run on 'component' target type. Current is '{{ target_type }}'."

Server in Cluster (Item 4)

Now that we know assert module, we just need to use it more:

- name: Checking if Server is part of Cluster Definition
  ansible.builtin.assert:
    that:
      - wls_host in cluster
    success_msg: "{{ wls_host }} is part of cluster."
    fail_msg: "{{ wls_host }} is not part of cluster {{ cluster }}."

“cluster” is a dict variable containing all hosts of the WebLogic cluster. success_msg is the message displayed when test returns true and fail_msg when false.

Installation Summary

Additionally, I miss-configured the host with what I wanted at end of deployment (Oups). Fortunately, with YaK, this is quick-fix.

I decided to add an installation summary at end of assertion role and a short pause where I can interrupt if needed. Here is an example of output:

TASK [assertion-yak-role : Installation Summary] *************************
Thursday 06 October 2022  14:51:55 +0000 (0:00:00.071)    0:00:06.284 ****
ok: [on_prem/srv-linux-ols-1/WLS_DOMAIN] => {
    "msg": [
        "=============================================================",
        "==                                                         ==",
        "==   Installing WebLogic          12_2_1_4 (jdk1.8.0_341)  ==",
        "==   On Cloud provider            on-premises              ==",
        "==   On Host                      srv-linux-ols-1          ==",
        "==   Host is                      Admin server             ==",
        "==   Which is part of cluster     srv-linux-ols-1          ==",
        "==                                srv-linux-ols-2          ==",
        "==                                                         ==",
        "=============================================================",
        ""
    ]
}

Next Steps ?

Now, it is your turn to participate in YaK as everyone can contribute. The core component of YaK is open source and you can even create your own component!

Also don’t forget that you can try YaK here.