Skip to content

Instantly share code, notes, and snippets.

@hipyhop
Created February 1, 2019 01:01
Show Gist options
  • Save hipyhop/451c03ae620fbdcdf2d891ca67fc0c20 to your computer and use it in GitHub Desktop.
Save hipyhop/451c03ae620fbdcdf2d891ca67fc0c20 to your computer and use it in GitHub Desktop.
Ansible k8s append_hash weirdness
- hosts: localhost
vars:
kube_resource_configmaps:
test: "{{ lookup('template', 'test.configmap.yml') | from_yaml }}"
tasks:
- name: create configmaps
k8s:
definition: "{{ item.value }}"
append_hash: yes
loop: "{{ kube_resource_configmaps | dict2items }}"
- set_fact:
config_name: "{{ kube_resource_configmaps.test | k8s_config_resource_name }}"
- debug:
var: config_name # Here config_name should be the same as the configmap creation in Kubernetes, but it isn't.
apiVersion: v1
kind: ConfigMap
metadata:
name: test-hash
namespace: default
data:
inner.json: |-
{{ lookup('template', 'test.inner.json') | indent(4) }}
{% raw %}
{
"test": "I contain templating {{ '{{ tags }}' }}"
}
{% endraw %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment