Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upJinja extrapolation for `openshift_hosted_...` vars doesn't work #5657
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
DenverJ
Nov 28, 2017
Contributor
I am also seeing this problem. Someone, please let me know if you would prefer I open a separate issue instead. I have in my inventory as below.
openshift_registry_base_hostname="openshift-registry"
openshift_hosted_registry_routehost="{{ openshift_registry_base_hostname }}.{{ ansible_domain }}"
When this goes into openshift_facts it does not get interpolated. Then when the same variable name is set sourced from the openshift facts it gets set as the raw string. Here is a simplified playbook showing the problem.
- hosts: master1.domain
tasks:
- name: Show openshift_hosted_registry_routehost
debug:
var: openshift_hosted_registry_routehost
- name: Set hosted facts
openshift_facts:
role: hosted
openshift_env: "{{ hostvars
| oo_merge_hostvars(vars, inventory_hostname)
| oo_openshift_env }}"
- name: set openshift_hosted facts
set_fact:
openshift_hosted_registry_routecertificates: "{{ ('routecertificates' in openshift.hosted.registry.keys()) | ternary(openshift.hosted.registry.routecertificates, {}) }}"
openshift_hosted_registry_routehost: "{{ openshift.hosted.registry.routehost }}"
- name: Show openshift_hosted_registry_routehost
debug:
var: openshift_hosted_registry_routehost
And the output.
PLAY [master1.domain] **************************************************************************************************************************************
TASK [Gathering Facts] *************************************************************************************************************************************************
ok: [master1.domain]
TASK [Show openshift_hosted_registry_routehost] ************************************************************************************************************************
ok: [master1.domain] => {
"openshift_hosted_registry_routehost": "openshift-registry.domain"
}
TASK [Set hosted facts] ************************************************************************************************************************************************
ok: [master1.domain]
TASK [set openshift_hosted facts] **************************************************************************************************************************************
ok: [master1.domain]
TASK [Show openshift_hosted_registry_routecertificates] ****************************************************************************************************************
ok: [master1.domain] => {
"openshift_hosted_registry_routehost": "{{ openshift_registry_base_hostname }}.{{ ansible_domain }}"
}
|
I am also seeing this problem. Someone, please let me know if you would prefer I open a separate issue instead. I have in my inventory as below.
When this goes into openshift_facts it does not get interpolated. Then when the same variable name is set sourced from the openshift facts it gets set as the raw string. Here is a simplified playbook showing the problem.
And the output.
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
/assign michaelgugino |
openshift-ci-robot
assigned
michaelgugino
Nov 28, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
michaelgugino
Nov 28, 2017
Contributor
FYI, the proper name is 'templating' for this problem. This happens when a plugin (module, action, etc) uses a variable that is not passed in as a parameter. This is an issue that plagues us in a variety of places.
|
FYI, the proper name is 'templating' for this problem. This happens when a plugin (module, action, etc) uses a variable that is not passed in as a parameter. This is an issue that plagues us in a variety of places. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
michaelgugino
Nov 29, 2017
Contributor
This has really lead down the rabbit hole: #6306
Cleaning up some openshift_facts items first, that will probably clear most of this right up.
|
This has really lead down the rabbit hole: #6306 Cleaning up some openshift_facts items first, that will probably clear most of this right up. |
tomassedovic commentedOct 4, 2017
Description
The
openshift_hosted_*variables need to be hard coded even when declared ingroup_vars/OSEv3.ymlwhich normally allows Jinja templating.See below for more details, but it seems the
openshift_factsrole is doing something really weird with the way it processes theopenshift_hosted_*vars. I tried to look into it, but got lost so even an explanation how it all works might help me.My ultimate goal of this is to be able to use a lookup plugin for specifying the volume details for the hosted registry, but this issue seems to affect more than just that usecase.
Version
Ansible version per
ansible --version:ansible 2.3.0.0The output of
git describe:openshift-ansible-3.6.22-1I tried this on master (
openshift-ansible-3.7.0-0.141.0) as well, but I can't even get that far because of an unrelated error. Running thesetupmodule after the deployment seems to show it's broken there as well.Steps To Reproduce
group_vars/OSEv3.ymlfile alongside yourinventory/hostsfileOSEv3.ymlfile. Here's a simplified version of mine:(it uses a Cinder-backed hosted registry, but the issue here is how openshift-ansible sets the local facts rather than the openstack/cinder integration)
Put a jinja code in the
openshift_hosted_registry_storage_volume_sizevariable inOSEv3.yml(note that the{{ 5 + 5 }}Givalue here is just an example. I'm using something more complex, but this illustrates the issue)Run the byo playbook:
Expected Results
The playbook should finish successfully, creating a Cinder-backed registry.
Observed Results
The playbook fails during the PV creation:
The PV config file from the error message (
/tmp/openshift-ansible-VX52l1a/persistent-volumes.ymlreveals that theopenshift_hosted_registry_storage_volume_sizewas included verbatim, not processed:(note the
storageline: it should say10Giinstead)The values seem to be coming from the local facts set by
openshift_factsrole:It seems the role that processes the
openshift_hosted_*variables is accessing the raw values from the the group_vars file as if it were actually reading and parsing the YAML. I didn't even know Ansible lets you access the unprocessed values.Note that when I add a
debug: var=openshift_hosted_registry_storage_volume_sizetask to the playbooks, it shows the correct value (10Gi) and Ansible/openshift-ansible processes all the other vars (e.g. the openstack creds environment lookups) as expected.Additional Information