Skip to content
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

Cannot set Server Configuration values that are only settable through config file #111

Open
dennislapchenko opened this issue Mar 20, 2023 · 8 comments

Comments

@dennislapchenko
Copy link
Contributor

dennislapchenko commented Mar 20, 2023

Slack token, for example, is currently only configured through atlantis configuration file. Any idea how to implement it with current setup?

Smoothest option is to add another cloudinit.write_files entry, right?

@bschaatsbergen
Copy link
Member

bschaatsbergen commented Mar 20, 2023

Hi @dennislapchenko,

According to https://www.runatlantis.io/docs/using-slack-hooks.html - it should be possible to set the Slack token through setting the environment variable: ATLANTIS_SLACK_TOKEN

And I believe that you can set the Slack configuration through the repo/server yaml config. This module supports passing the server config, see /examples. And for the repo config, you can set the Slack config as part of that atlantis.yaml (in your repository).

Hopefully this helps you, if not let me know!

@dennislapchenko
Copy link
Contributor Author

dennislapchenko commented Mar 20, 2023

@bschaatsbergen thanks for a swift reply. At first I also thought that its the server yaml config that it should go to. But after trying it out - came to understand its the actual atlantis config file that this has to be in. (path to which is through ATLANTIS_CONFIG). webhooks is not declared in server atlantis yaml schema (nor repo atlantis yaml, but its not even important)
This issue comment proves it: runatlantis/atlantis#2143 (comment)

@dennislapchenko
Copy link
Contributor Author

Before I attempted a fork or a PR into cloudinit, I tried to use startup_script like:

  env_vars = {
    ATLANTIS_CONFIG = "/home/atlantis/config.yaml"
  }

  startup_script = <<EOF
#!/usr/bin/env bash

cat <<YAML > $ATLANTIS_CONFIG
webhooks:
  - event: apply
    workspace-regex: .*
    kind: slack
    channel: terraform-notifications
YAML
EOF

But i do get:

Error: invalid config: reading /home/atlantis/config.yaml: open /home/atlantis/config.yaml: no such file or directory

It seems the container is starting faster than the startup script

@bschaatsbergen
Copy link
Member

bschaatsbergen commented Mar 20, 2023

Hmm thanks for elaborating. I'll take a stab this 👍🏼 @dennislapchenko

Note: the startup-script is ran on the VM, not within the container itself, the file should be copied into the disk that the container has mounted.

@dennislapchenko
Copy link
Contributor Author

@bschaatsbergen perhaps adding a cloudinit part {} for config as file is a good option? (Or could just wait until Atlantis team adds webhooks to ENV configurables oto)

Re startup-script - as seen in the example above, i was writing the file to /home/atlantis/config.yaml, and the mounted volume is /home/atlantis so it should've worked right? Perhaps container is launching earlier after all? (interesting that there is not restart after failed startup?)

@bschaatsbergen
Copy link
Member

Hi @dennislapchenko, I'll get back on this issue soon. Have you meanwhile find an alternative way to fix it?

@bschaatsbergen
Copy link
Member

I plan on checking this out soon @dennislapchenko, been a busy few weeks. Have you tackled this already?

@dennislapchenko
Copy link
Contributor Author

Hi @bschaatsbergen, unfortunately I havent. Have switched projects and here atlantis is in k8s 😄

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

No branches or pull requests

2 participants