Override values.yml using helm extension for ansible

3/1/2019

I want to create a playbook for installing external helm charts provided by ZIP archive from IBM. Its required for us to override some values from values.yml by custom ones (e.g. host to docker registry.

Example from IBMs values.yml

image:
  pullPolicy: IfNotPresent
  repository: artifactory.swg.usma.ibm.com:6562

Since a non public repo was set by IBM, I uploaded the images (downloaded from IBMs releases) to my custom registry registry.example.com and want to set it in my playbook:

- name: CNX Bootstrap
  helm:
    # Port forwarding from tiller to localhost
    host: localhost
    state: present
    name: bootstrap-test
    namespace: "{{namespace}}"
    chart: 
      name: bootstrap
      source:
        type: directory
        location: /install/component-pack/IC-ComponentPack-6.0.0.7/microservices_connections/hybridcloud/helmbuilds/bootstrap
    values: 
      image.repository: "registry.example.com"

This doesn't work, the pod logs say:

Failed to pull image "artifactory.swg.usma.ibm.com:6562/bootstrap:20190204-022029": rpc error: code = Unknown desc = Get https://artifactory.swg.usma.ibm.com:6562/v1/_ping: Service Unavailable

So it's still using the wrong registry and my custom values seems to be ignored. Using helm cli, I'm able to override using --set switch like this:

helm install --name=bootstrap /install/component-pack/IC-ComponentPack-6.0.0.7/microservices_connections/hybridcloud/helmbuilds/bootstrap-0.1.0-20190204-022029.tgz --set image.repository=registry.example.com

How can I override the chart's values like the --set switch does in Ansible?

The module documentation doesn't provide any information. I only found out that pyhelm is used. But I couldn't find a way to override the default values.

-- Daniel
ansible
docker
ibm-connections
kubernetes-helm

1 Answer

4/7/2019

When PyHelm gets the values passed from your Ansible chart definition it is passed as a dictionary, which it converts to a yaml. Tiller (the server side component of Helm) expects the values yaml passed to remain nested. Thus, you need to store them as a nested dictionary in your Ansible definitions.

In your case, it would look something like:

- name: CNX Bootstrap
  helm:
    # Port forwarding from tiller to localhost
    host: localhost
    state: present
    name: bootstrap-test
    namespace: "{{namespace}}"
    chart: 
      name: bootstrap
      source:
        type: directory
        location: /install/component-pack/IC-ComponentPack-6.0.0.7/microservices_connections/hybridcloud/helmbuilds/bootstrap
    values: 
      image:
        repository: "registry.example.com"
-- yanivoliver
Source: StackOverflow