Skip to content

Update alloy.j2 to correctly embed env file variable options #344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2025

Conversation

robigan
Copy link
Contributor

@robigan robigan commented Apr 23, 2025

Env file variable options such as --stability.level public-preview in Ansible configurations cause them to be embedded without being escaped in double quotes in the env file.

For context, I have an ansible task that looks like so:

    - name: Configure Alloy
      ansible.builtin.include_role:
        name: grafana.grafana.alloy
      vars:
        alloy_config: "{{ lookup('file', '../../Home-Compose/alloy/config.alloy') }}"
        alloy_env_file_vars:
          CUSTOM_ARGS: "--stability.level public-preview"

This causes upgrade failures like it did for me today whereby the prerm script for the alloy package attempts executing the unescaped half, causing dpkg to spit out the error /var/lib/dpkg/info/alloy.prerm: 6: /etc/default/alloy: public-preview: not found for a configuration like so

# Ansible Managed

CONFIG_FILE="/etc/alloy/config.alloy"
RESTART_ON_UPGRADE=true

CUSTOM_ARGS=--stability.level public-preview

I fixed this by adding escaped quotes to my ansible task such that they get embedded in, like so:

CUSTOM_ARGS: "\"--stability.level public-preview\""

But this would be best fixed at the source in Jinja.

This occurred to me today by upgrading from alloy 1.6.1-1 to alloy 1.8.1-1.

Env file variable options such as `--stability.level public-preview` in your Ansible configuration cause them to be embedded without being escaped in double quotes in the env file. 

This causes upgrade failures whereby the `prerm` script for the alloy package attempts executing the unescaped half, causing dpkg to spit out the error `/var/lib/dpkg/info/alloy.prerm: 6: /etc/default/alloy: public-preview: not found` for a configuration like so
```
# Ansible Managed

CONFIG_FILE="/etc/alloy/config.alloy"
RESTART_ON_UPGRADE=true

CUSTOM_ARGS=--stability.level public-preview
```
@CLAassistant
Copy link

CLAassistant commented Apr 23, 2025

CLA assistant check
All committers have signed the CLA.

@robigan
Copy link
Contributor Author

robigan commented Apr 23, 2025

CLA assistant check Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.You have signed the CLA already but the status is still pending? Let us recheck it.

How does one sign the CLA if the page doesn't load correctly? I just get this:
image
and I can't select anything or go forward.

@robigan
Copy link
Contributor Author

robigan commented Apr 23, 2025

CLA assistant check Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.You have signed the CLA already but the status is still pending? Let us recheck it.

How does one sign the CLA if the page doesn't load correctly? I just get this: image and I can't select anything or go forward.

Ok nvm I was able to, even though the page is half bugged

@voidquark
Copy link
Collaborator

Thank you, Approved 🚀

@voidquark voidquark self-assigned this Apr 23, 2025
@voidquark voidquark merged commit c008248 into grafana:main Apr 23, 2025
14 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants