templating a variable name in ansible 2.9 is not working as before, did I miss something in the release notes ?

19 views
Skip to first unread message

Stephen Maher

unread,
Dec 20, 2019, 10:00:08 AM12/20/19
to Ansible Project

Hi,


We have some plays that work ok in ansible <2.9, they are used to generate various repositories based on facts and they do not appear to work any longer after ansible 2.9 update - I have rolled back just the ansible package and its working again.



I've read the release notes and I'm can't see any thing specific regarding this change. Has anyone else seen the same behaviour?


Cheers.





vars.yml

----------------------------------------------------------

test:

  "test_{{ include_this_please }}":

    testing: true

    included_var: "{{ include_this_please }}"



2.9 ansible


PLAY [localhost] *****************************************************************************************************************************************************************************************


TASK [include_vars] **************************************************************************************************************************************************************************************

ok: [localhost]


TASK [debug] *********************************************************************************************************************************************************************************************

ok: [localhost] => {

    "test": {

        "test_{{ include_this_please }}": {

            "included_var": "included",

            "testing": true

        }

    }

}



2.8 ansible



PLAY [localhost] *****************************************************************************************************************************************************************************************


TASK [include_vars] **************************************************************************************************************************************************************************************

ok: [localhost]


TASK [debug] *********************************************************************************************************************************************************************************************

ok: [localhost] => {

    "test": {

        "test_included": {

            "included_var": "included",

            "testing": true

        }

    }

}


Matt Martz

unread,
Dec 20, 2019, 10:30:55 AM12/20/19
to ansible...@googlegroups.com

However, that entry specifically targeted info about loops.  But the change can affect more uses of templating.

Where is `include_this_please` coming from?  Is it a single vault encrypted value?

Effectively, we improved the "unsafe" variable system, and single vaulted values are unsafe, and should never be allowed to be templated.  So when they are involved in templating data, it prevents templating from happening.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a69cc258-5a88-45fb-8842-418e30599261%40googlegroups.com.


--
Matt Martz
@sivel
sivel.net

Stephen Maher

unread,
Dec 20, 2019, 10:56:37 AM12/20/19
to Ansible Project
Thanks Matt, I did read that but didn't see how it would effect my code. The vars are include_vars (yaml) and interspersed with facts such as ansible_distribution_major_version. 

example:

managed_yum_repos:

  "rhel-{{ ansible_distribution_major_version }}-server-rpms":

    description: "Red Hat Enterprise Linux {{ ansible_distribution_major_version }} Server (RPMs)"

    baseurl: ....



    


I have a workaround to use {{ lookup('flattened',[my_packed_variable]) }}, this lets me run with the identical vars on both versions for now.




To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages