Ansible dictionary or local facts for blue-green deployment

I’m working on a kubernetes blue green deployment on Ansible.
I know this would probably be easier with Terraform, but we are not using it :S.

The variables I’m getting from the requestor are:

  • Application Name

  • Application Version

  • Number of replicas

The deployment steps are more or less like this:
1- Find if there is an application deployed
2a- If there is no application, deploy it as new.
2b- If there is an application, set it as blue.
2c- If the application is the same as the one deploy check the number of replicas and rescale if necessary.
3- Deploy the new application and wait for the pods to boot.
4- Once the pods are running, change the service to the new deployment.
5- Remove the blue application

What would you recommended to use, a dictionary or local facts to handle the variables?
Would be possible to use them inside the roles?

This is container-deployment.yml I’m using, this is just for a normal application deployment:


- hosts: master gather_facts: no become: true roles: - namespace <-- this step will create the namespace - app-build <-- this will create the image for the build - deployment <-- deploy the "deployment" - service <-- create the service

Any suggestion will be appreciated.

Thanks