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

Allow replacing stanley with an alternate user #208

Closed
cognifloyd opened this issue Jun 25, 2021 · 5 comments · Fixed by #220
Closed

Allow replacing stanley with an alternate user #208

cognifloyd opened this issue Jun 25, 2021 · 5 comments · Fixed by #220

Comments

@cognifloyd
Copy link
Member

In my environment, the security team has strict requirements about the naming of service user accounts, so I can't us stanley.

In the st2.config value, I can change that user, and the ssh key as shown in https://github.com/StackStorm/st2/blob/master/conf/st2.conf.sample#L317-L321

[system_user]
# SSH private key for the system user.
ssh_key_file = /home/notstanley/.ssh/stanley_rsa
# Default system user.
user = notstanley

Then, I can use a custom st2actionrunner image that adds the notstanley account and home directory.
But, the name stanley is hard-coded in a couple of places. This is for the st2actionrunner pod, but the same applies to the st2client pod as well.
https://github.com/StackStorm/stackstorm-ha/blob/aabf3dcb201a86d5ddf6717cffc9dd76267181b5/templates/deployments.yaml#L1033-L1035
https://github.com/StackStorm/stackstorm-ha/blob/aabf3dcb201a86d5ddf6717cffc9dd76267181b5/templates/deployments.yaml#L1070-L1073

I think I would add new options in values:

st2:
  # This mirrors the [system_user] section of st2.conf, but makes the values available for helm templating.
  # If you change the user, you must provide a customized st2actionrunner image that includes your user.
  system_user:
    user: stanley
    # if ssh_key_file is not defined, default is: /home/$system_user/.ssh/stanley_rsa
    #ssh_key_file:

Then, in st2-config configmap (in st2.docker.conf), add:

    {{- if index .Values "st2" "system_user" }}
    [system_user]
    user = {{ .Values.st2.system_user.user | default "stanley" }}
    {{- if index .Values "st2" "system_user" "ssh_key_file }}
    ssh_key_file = {{ .Values.st2.system_user.ssh_key_file }}
    {{- else }}
    ssh_key_file = /home/{{ .Values.st2.system_user }}/.ssh/stanley_rsa
    {{- end }}
    {{- end }}

With similar changes to templates/deployments.yaml for the ssh key mount paths.

I'm working on fixing the ssh key file permissions in #203 (to fix #84) so it would be easy to include this change in there, or I can wait till after that (or similar) is merged and add the configuration on top of it in a separate PR.

@arm4b
Copy link
Member

arm4b commented Jun 27, 2021

👍
I remember at least one request from the community about customizing the default user name.

@arm4b arm4b added the security label Jun 27, 2021
@cognifloyd
Copy link
Member Author

Shall I add this to #206?

@arm4b
Copy link
Member

arm4b commented Jun 28, 2021

I think it's better to keep them separated for the better history and faster iteration. Eg merging #206 first.

@cognifloyd
Copy link
Member Author

cognifloyd commented Jul 1, 2021

Once #206 #219 is merged, I'll submit a PR with this commit to allow an alternate system_user:
cognifloyd/stackstorm-k8s@lifecycle-hooks...configurable-stanley

@cognifloyd
Copy link
Member Author

This is implemented in #220 - but that depends on #219 being merged first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants