Commit Graph

3 Commits

Author SHA1 Message Date
James E. Blair 99d39545a6 Add an !unsafe change_message variable
In I9628e2770dda120b269612e28bb6217036942b8e we switched zuul.change from
a plain string tagged with !unsafe to base64 encoded and no !unsafe tag.
The idea was to make the inventory file parseable by external tools while
avoiding accidental interpolation of the commit message by Ansible.

That doesn't work in all cases -- it's not hard to construct a scenario
where after base64 decoding the message any further processing by Ansible
causes it to undergo interpolation.  Moreover, since then we have made
many changes to how we deal with variables; notably, the inventory.yaml
is no longer actually used by Zuul's Anisble -- it is now there only
for human and downstream processing.  We call it the "debug inventory".
The actual inventory is much more complex and in some cases has lots of
!unsafe tags in it.

Given all that, it now seems like the most straightforward way to deal
with this is to tag the message variable as !unsafe when passing it to
Zuul's Ansible, but render it as plain text in the inventory.yaml.

To address backwards compatability, this is done in a new variable called
zuul.change_message.  Since that's a more descriptive variable anyway,
we will just keep that one in the future and drop the current base64-
encoded zuul.message variable

Change-Id: Iea86de15e722bc271c1bf0540db2c9efb032500c
2023-02-09 09:07:53 -08:00
Tobias Henkel fcbb91582f
Encode zuul.message with base64
Zuul recently added zuul.message which needs to be protected against
interpretation by jinja in ansible. This was initially done by marking
it with the !unsafe tag. However this has the disadvantage that the
inventory is no longer parsable by standard yaml parsers without
teaching them the !unsafe tag.

There is a similar simple possibility that doesn't rely on this tag by
base64 encoding the commit message. Ansible has filters for decoding
this so it is still quite easy to deal with base64 encoded vars in
ansible via '{{ zuul.message | b64decode }}'.

Change-Id: I9628e2770dda120b269612e28bb6217036942b8e
2019-02-28 18:09:22 +01:00
Quique Llorente c7ec1490b0 Mark as unsafe commit message at inventory
If you run zuul at a commit with some jinja2 stuff in the comment it
fails, to bypass this this review tag the inventory yaml zuul message
with !unsafe ansible yaml tag [1].

Closes-Bug: https://storyboard.openstack.org/#!/story/2004896

[1] https://docs.ansible.com/ansible/latest/user_guide/playbooks_advanced_syntax.html#unsafe-or-raw-strings

Change-Id: Ic11c253cf23cc4d1fb80993f5722f37e4c22f6df
2019-02-13 09:42:39 +01:00